diff options
| author | svs-odoo <svs@odoo.com> | 2019-09-09 08:21:10 +0000 |
|---|---|---|
| committer | svs-odoo <svs@odoo.com> | 2019-10-25 13:20:38 +0000 |
| commit | 287f56c5c994ee075eb473d9a6d4ecd4f2b3675e (patch) | |
| tree | 824ec235ff4bc66b22f2638e5eacce8417b96a8a | |
| parent | bd5c6d6ff00cfea0f9e0993db815dd2f7cf13e20 (diff) | |
[IMP] product_expiry: add use_expiration_date
Adds new product field, `use_expiration_date`, to know if user wants to
use expiration date on product. Only accessible when product is tracked.
Also, changes fields' name:
- product.template: life_time becomes expiration_time
- stock.production.lot: life_date becomes expiration_date
Task #1938656
4 files changed, 20 insertions, 10 deletions
diff --git a/addons/product_expiry/models/product_product.py b/addons/product_expiry/models/product_product.py index a055f650286..3dfcb1a35bd 100644 --- a/addons/product_expiry/models/product_product.py +++ b/addons/product_expiry/models/product_product.py @@ -7,7 +7,10 @@ from odoo import fields, models class ProductTemplate(models.Model): _inherit = 'product.template' - life_time = fields.Integer(string='Product Life Time', + use_expiration_date = fields.Boolean(string='Expiration Date', + help='When this box is ticked, you have the possibility to specify dates to manage' + ' product expiration, on the product and on the corresponding lot/serial numbers') + expiration_time = fields.Integer(string='Product Life Time', 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='Number of days before the goods starts deteriorating, without being dangerous yet. It will be computed using the lot/serial number.') diff --git a/addons/product_expiry/models/production_lot.py b/addons/product_expiry/models/production_lot.py index 566483eb1a1..384207fb9c4 100644 --- a/addons/product_expiry/models/production_lot.py +++ b/addons/product_expiry/models/production_lot.py @@ -7,7 +7,9 @@ from odoo import api, fields, models, SUPERUSER_ID, _ class StockProductionLot(models.Model): _inherit = 'stock.production.lot' - life_date = fields.Datetime(string='End of Life Date', + use_expiration_date = fields.Boolean( + string='Use Expiration Date', related='product_id.use_expiration_date') + expiration_date = fields.Datetime(string='End of Life Date', help='This is the date on which the goods with this Serial Number may become dangerous and must not be consumed.') use_date = fields.Datetime(string='Best before Date', help='This is the date on which the goods with this Serial Number start deteriorating, without being dangerous yet.') @@ -29,7 +31,7 @@ class StockProductionLot(models.Model): def _get_dates(self, product_id=None): """Returns dates based on number of days configured in current lot's product.""" mapped_fields = { - 'life_date': 'life_time', + 'expiration_date': 'expiration_time', 'use_date': 'use_time', 'removal_date': 'removal_time', 'alert_date': 'alert_time' diff --git a/addons/product_expiry/views/product_template_views.xml b/addons/product_expiry/views/product_template_views.xml index 70579f69a77..ae1c0bcd653 100644 --- a/addons/product_expiry/views/product_template_views.xml +++ b/addons/product_expiry/views/product_template_views.xml @@ -5,16 +5,20 @@ <field name="model">product.template</field> <field name="inherit_id" ref="stock.view_template_property_form" /> <field name="arch" type="xml"> - <group name="traceability" position="after"> - <group string="Dates" name="expiry_and_lots" groups="stock.group_production_lot" attrs="{'invisible': [('tracking', '=','none')]}"> + <group name="traceability" position="inside"> + <field name="use_expiration_date" attrs="{'invisible': [('tracking', '=','none')]}"/> + </group> + <group name="group_lots_and_weight" position="after"> + <group string="Dates" name="expiry_and_lots" groups="stock.group_production_lot" + attrs="{'invisible': ['|', ('tracking', '=','none'), ('use_expiration_date', '=', False)]}"> <label for="use_time"/> <div> <field name="use_time" class="oe_inline"/> <span> days</span> </div> - <label for="life_time"/> + <label for="expiration_time"/> <div> - <field name="life_time" class="oe_inline"/> + <field name="expiration_time" class="oe_inline"/> <span> days</span> </div> <label for="removal_time"/> diff --git a/addons/product_expiry/views/production_lot_views.xml b/addons/product_expiry/views/production_lot_views.xml index b32bcff8c49..9902df8ca3c 100644 --- a/addons/product_expiry/views/production_lot_views.xml +++ b/addons/product_expiry/views/production_lot_views.xml @@ -6,14 +6,15 @@ <field name="inherit_id" ref="stock.view_production_lot_form" /> <field name="arch" type="xml"> <xpath expr="//page[@name='description']" position="before"> - <page string="Dates"> + <page string="Dates" attrs="{'invisible': [('use_expiration_date', '=', False)]}"> + <field name="use_expiration_date" invisible="1"/> <group> <group> <field name="use_date" /> <field name="removal_date" /> </group> <group> - <field name="life_date" /> + <field name="expiration_date" /> <field name="alert_date" /> </group> </group> @@ -45,7 +46,7 @@ <xpath expr="//field[@name='create_date']" position="after"> <field name="use_date" optional="hide"/> <field name="removal_date" optional="hide"/> - <field name="life_date" optional="hide"/> + <field name="expiration_date" optional="hide"/> <field name="alert_date" optional="hide"/> </xpath> </field> |
