[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.
This commit is contained in:
committed by
Yannick Tivisse
parent
95de49a9ab
commit
5bd4514c6f
@@ -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.')
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user