diff options
| author | Ravi Patel <rap@odoo.com> | 2016-07-18 18:14:49 +0530 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2016-10-20 15:37:51 +0200 |
| commit | 5bd4514c6fec80cfc3d7e5353d4e54c8a7b2ed31 (patch) | |
| tree | 798786338512638fda5ef421030a4667f0ac2876 | |
| parent | 95de49a9ab1563e8662044a1eabd652d2740a04f (diff) | |
[IMP] prodcut_expiry: 'Product Alert Time' improvement
- Hide life_time, use_time, removal_time and alert_time if tracking = no tracking
- Change the tooltip of these fields(life_time, use_time, removal_time, alert_time)
- Add filter 'Expiration Alert' on the Lot/Serial Number list view based on the lot/sn alert date
- Add a tag 'Expiration alert' when the alert_date is reached.
4 files changed, 48 insertions, 9 deletions
diff --git a/addons/product_expiry/models/product_product.py b/addons/product_expiry/models/product_product.py index 709a3127619..86094cfed16 100644 --- a/addons/product_expiry/models/product_product.py +++ b/addons/product_expiry/models/product_product.py @@ -8,10 +8,10 @@ class ProductTemplate(models.Model): _inherit = 'product.template' life_time = fields.Integer(string='Product Life Time', - help='When a new a Serial Number is issued, this is the number of days before the goods may become dangerous and must not be consumed.') + help='Number of days before the goods may become dangerous and must not be consumed. It will be computed on the lot/serial number.') use_time = fields.Integer(string='Product Use Time', - help='When a new a Serial Number is issued, this is the number of days before the goods starts deteriorating, without being dangerous yet.') + help='Number of days before the goods starts deteriorating, without being dangerous yet. It will be computed on the lot/serial number.') removal_time = fields.Integer(string='Product Removal Time', - help='When a new a Serial Number is issued, this is the number of days before the goods should be removed from the stock.') + help='Number of days before the goods should be removed from the stock. It will be computed on the lot/serial number.') alert_time = fields.Integer(string='Product Alert Time', - help='When a new a Serial Number is issued, this is the number of days before an alert should be notified.') + help='Number of days before an alert should be raised on the lot/serial number.') diff --git a/addons/product_expiry/models/production_lot.py b/addons/product_expiry/models/production_lot.py index d6d1b0fa7b9..95e37a31deb 100644 --- a/addons/product_expiry/models/production_lot.py +++ b/addons/product_expiry/models/production_lot.py @@ -15,6 +15,13 @@ class StockProductionLot(models.Model): help='This is the date on which the goods with this Serial Number should be removed from the stock.') alert_date = fields.Datetime(string='Alert Date', help="This is the date on which an alert should be notified about the goods with this Serial Number.") + product_expiry_alert = fields.Boolean(compute='_compute_product_expiry_alert', help="The Alert Date has been reached.") + + @api.depends('alert_date') + def _compute_product_expiry_alert(self): + current_date = fields.Datetime.now() + for lot in self.filtered(lambda l: l.alert_date): + lot.product_expiry_alert = lot.alert_date <= current_date def _get_dates(self, product_id=None): """Returns dates based on number of days configured in current lot's product.""" diff --git a/addons/product_expiry/views/product_template_views.xml b/addons/product_expiry/views/product_template_views.xml index 9f654eb192c..a8587dbb530 100644 --- a/addons/product_expiry/views/product_template_views.xml +++ b/addons/product_expiry/views/product_template_views.xml @@ -6,11 +6,27 @@ <field name="inherit_id" ref="stock.view_template_property_form" /> <field name="arch" type="xml"> <group name="stock_property" position="after"> - <group name="expiry_and_lots" groups="stock.group_production_lot"> - <field name="life_time" /> - <field name="use_time" /> - <field name="removal_time" /> - <field name="alert_time" /> + <group name="expiry_and_lots" groups="stock.group_production_lot" attrs="{'invisible': [('tracking','=','none')]}"> + <label for="life_time"/> + <div class="o_row"> + <field name="life_time" /> + <span>days</span> + </div> + <label for="use_time"/> + <div class="o_row"> + <field name="use_time" /> + <span>days</span> + </div> + <label for="removal_time"/> + <div class="o_row"> + <field name="removal_time" /> + <span>days</span> + </div> + <label for="alert_time"/> + <div class="o_row"> + <field name="alert_time" /> + <span>days</span> + </div> </group> </group> </field> diff --git a/addons/product_expiry/views/production_lot_views.xml b/addons/product_expiry/views/production_lot_views.xml index 92b2040de6a..1209d32706a 100644 --- a/addons/product_expiry/views/production_lot_views.xml +++ b/addons/product_expiry/views/production_lot_views.xml @@ -16,7 +16,23 @@ <field name="alert_date" /> </group> </group> + </xpath> + <xpath expr="//div[@class='oe_title']" position="inside"> + <field name="product_expiry_alert" invisible="1"/> + <span class="label label-danger" attrs="{'invisible': [('product_expiry_alert', '=', False)]}">Expiration Alert</span> </xpath> </field> </record> + + <record id="search_product_lot_filter_inherit_product_expiry" model="ir.ui.view"> + <field name="name">stock.production.lot.search.inherit</field> + <field name="model">stock.production.lot</field> + <field name="inherit_id" ref="stock.search_product_lot_filter"/> + <field name="arch" type="xml"> + <xpath expr="//field[@name='product_id']" position="after"> + <filter string="Expiration alerts" domain="[('alert_date', '<=', time.strftime('%Y-%m-%d %H:%M:%S'))]"/> + </xpath> + </field> + </record> + </odoo> |
