-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] product_expiry_ux: create module.
- Loading branch information
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import production_lot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |