Skip to content

Commit

Permalink
[ADD] product_expiry_ux: create module.
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc committed Nov 18, 2022
1 parent cd6597d commit 857e9d6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions product_expiry_ux/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions product_expiry_ux/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
'name': 'Products Expiration Date UX',
'version': '15.0.1.0.0',
'category': 'Inventory/Inventory',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'depends': ['product_expiry'],
'data': ['views/production_lot_views.xml'],
'demo': [],
'license': 'AGPL-3',
'installable': True,
'auto_install': True,
'application': False,
}
1 change: 1 addition & 0 deletions product_expiry_ux/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import production_lot
16 changes: 16 additions & 0 deletions product_expiry_ux/models/production_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import api, fields, models
from odoo.tools import float_compare

class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'

is_alert_date = fields.Boolean(compute='_compute_is_alert_date', help="The Alert Date has been reached")

@api.depends('alert_date')
def _compute_is_alert_date(self):
current_date = fields.Datetime.now()
for lot in self:
if lot.alert_date:
lot.is_alert_date = (lot.alert_date <= current_date)
else:
lot.is_alert_date = False
17 changes: 17 additions & 0 deletions product_expiry_ux/views/production_lot_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding='UTF-8'?>
<odoo>
<record id="view_move_form_expiry_ux" model="ir.ui.view">
<field name="name">stock.production.lot.inherit.form.ux</field>
<field name="model">stock.production.lot</field>
<field name="inherit_id" ref="product_expiry.view_move_form_expiry" />
<field name="arch" type="xml">
<xpath expr="//span[hasclass('badge-danger')]" position="replace">
<span class="badge badge-danger" attrs="{'invisible': [('product_expiry_alert', '=', False)]}">Expired</span>
</xpath>
<xpath expr="//span[hasclass('badge-danger')]" position="after">
<field name="is_alert_date" invisible="1"/>
<span class="badge badge-warning" attrs="{'invisible': [('is_alert_date', '=', False)]}">Expiration Alert</span>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 857e9d6

Please sign in to comment.