[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
This commit is contained in:
@@ -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.')
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user