-
-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
product_expiry_simple: black, isort, etc...
Travis: exclude the module because it conflicts with product_expiry
- Loading branch information
1 parent
5dcf4b3
commit e8aaf4c
Showing
10 changed files
with
125 additions
and
68 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
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
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
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 |
---|---|---|
|
@@ -3,14 +3,14 @@ | |
# @author: Alexis de Lattre <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models, _ | ||
from odoo import _, api, fields, models | ||
|
||
|
||
class StockProductionLot(models.Model): | ||
_inherit = 'stock.production.lot' | ||
_inherit = "stock.production.lot" | ||
|
||
expiry_date = fields.Date(string='Expiry Date') | ||
expired = fields.Boolean(compute='_compute_expired') | ||
expiry_date = fields.Date(string="Expiry Date") | ||
expired = fields.Boolean(compute="_compute_expired") | ||
|
||
def _compute_expired(self): | ||
today = fields.Date.context_today(self) | ||
|
@@ -20,16 +20,16 @@ def _compute_expired(self): | |
expired = True | ||
lot.expired = expired | ||
|
||
@api.depends('name', 'expiry_date') | ||
@api.depends("name", "expiry_date") | ||
def name_get(self): | ||
res = [] | ||
today = fields.Date.context_today(self) | ||
for lot in self: | ||
dname = lot.name | ||
if lot.expiry_date: | ||
if lot.expiry_date < today: | ||
dname = _('[%s Expired] %s') % (lot.expiry_date, dname) | ||
dname = _("[%s Expired] %s") % (lot.expiry_date, dname) | ||
else: | ||
dname = '[%s] %s' % (lot.expiry_date, dname) | ||
dname = "[%s] %s" % (lot.expiry_date, dname) | ||
res.append((lot.id, dname)) | ||
return res |
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2017-2021 Akretion France (http://www.akretion.com/) | ||
@author: Alexis de Lattre <[email protected]> | ||
|
@@ -8,43 +8,60 @@ | |
<record id="view_production_lot_form" model="ir.ui.view"> | ||
<field name="name">product_expiry_simple.stock.production.lot.form</field> | ||
<field name="model">stock.production.lot</field> | ||
<field name="inherit_id" ref="stock.view_production_lot_form"/> | ||
<field name="inherit_id" ref="stock.view_production_lot_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="ref" position="after"> | ||
<field name="expiry_date"/> | ||
<field name="expired" invisible="1"/> | ||
<field name="expiry_date" /> | ||
<field name="expired" invisible="1" /> | ||
</field> | ||
<xpath expr="//div[hasclass('oe_title')]" position="inside"> | ||
<span class="badge badge-danger" attrs="{'invisible': [('expired', '=', False)]}">Expired</span> | ||
<span | ||
class="badge badge-danger" | ||
attrs="{'invisible': [('expired', '=', False)]}" | ||
>Expired</span> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_production_lot_tree" model="ir.ui.view"> | ||
<field name="name">product_expiry_simple.stock.production.lot.tree</field> | ||
<field name="model">stock.production.lot</field> | ||
<field name="inherit_id" ref="stock.view_production_lot_tree"/> | ||
<field name="inherit_id" ref="stock.view_production_lot_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="ref" position="after"> | ||
<field name="expiry_date" optional="show"/> | ||
<field name="expiry_date" optional="show" /> | ||
</field> | ||
<xpath expr="/tree" position="attributes"> | ||
<attribute name="decoration-danger">expiry_date and expiry_date < current_date</attribute> | ||
<attribute | ||
name="decoration-danger" | ||
>expiry_date and expiry_date < current_date</attribute> | ||
</xpath> | ||
</field> | ||
</record> | ||
<record id="search_product_lot_filter" model="ir.ui.view"> | ||
<field name="name">product_expiry_simple.stock.production.lot.search</field> | ||
<field name="model">stock.production.lot</field> | ||
<field name="inherit_id" ref="stock.search_product_lot_filter"/> | ||
<field name="inherit_id" ref="stock.search_product_lot_filter" /> | ||
<field name="arch" type="xml"> | ||
<field name="product_id" position="after"> | ||
<filter domain="[('expiry_date', '<', context_today().strftime('%Y-%m-%d'))]" name="expired" string="Expired"/> | ||
<filter domain="[('expiry_date', '>=', context_today().strftime('%Y-%m-%d'))]" name="no-expired" string="Not Expired"/> | ||
<separator/> | ||
<filter | ||
domain="[('expiry_date', '<', context_today().strftime('%Y-%m-%d'))]" | ||
name="expired" | ||
string="Expired" | ||
/> | ||
<filter | ||
domain="[('expiry_date', '>=', context_today().strftime('%Y-%m-%d'))]" | ||
name="no-expired" | ||
string="Not Expired" | ||
/> | ||
<separator /> | ||
</field> | ||
<filter name="group_by_product" position="after"> | ||
<filter context="{'group_by': 'expiry_date:month'}" name="expiry_date_groupby" string="Expiry Date"/> | ||
<filter | ||
context="{'group_by': 'expiry_date:month'}" | ||
name="expiry_date_groupby" | ||
string="Expiry Date" | ||
/> | ||
</filter> | ||
</field> | ||
</record> | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2017-2021 Akretion France (http://www.akretion.com/) | ||
@author: Alexis de Lattre <[email protected]> | ||
|
@@ -8,65 +8,87 @@ | |
<record id="view_stock_quant_form" model="ir.ui.view"> | ||
<field name="name">product_expiry_simple.stock.quant.form</field> | ||
<field name="model">stock.quant</field> | ||
<field name="inherit_id" ref="stock.view_stock_quant_form"/> | ||
<field name="inherit_id" ref="stock.view_stock_quant_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="product_id" position="before"> | ||
<!-- Cannot use context_today() nor current_date in a form view, | ||
only in a tree/search view. | ||
So I added a computed boolean field 'expired' --> | ||
<field name="expired" invisible="1"/> | ||
<span class="badge badge-danger" attrs="{'invisible': [('expired', '=', False)]}">Expired</span> | ||
<field name="expired" invisible="1" /> | ||
<span | ||
class="badge badge-danger" | ||
attrs="{'invisible': [('expired', '=', False)]}" | ||
>Expired</span> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="view_stock_quant_tree" model="ir.ui.view"> | ||
<field name="name">product_expiry_simple.stock.quant.tree</field> | ||
<field name="model">stock.quant</field> | ||
<field name="inherit_id" ref="stock.view_stock_quant_tree"/> | ||
<field name="inherit_id" ref="stock.view_stock_quant_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="lot_id" position="after"> | ||
<!-- We show expiry_date in tree view in order to do an "order by" on this column via the interface | ||
But the information is already in the lot_id column via name_get() --> | ||
<field name="expiry_date" optional="hide"/> | ||
<field name="expiry_date" optional="hide" /> | ||
</field> | ||
<!-- I prefer to continue to use the full line in red | ||
instead of using widget="badge" decoration-danger="" | ||
on the field expiry_date. That way, we can keep the field | ||
expiry_date hidden by default, which avoids the double info --> | ||
<xpath expr="/tree" position="attributes"> | ||
<attribute name="decoration-danger">expiry_date and expiry_date < current_date</attribute> | ||
<attribute | ||
name="decoration-danger" | ||
>expiry_date and expiry_date < current_date</attribute> | ||
</xpath> | ||
</field> | ||
</record> | ||
<record id="view_stock_quant_tree_editable" model="ir.ui.view"> | ||
<field name="name">product_expiry_simple.stock.quant.tree.editable</field> | ||
<field name="model">stock.quant</field> | ||
<field name="inherit_id" ref="stock.view_stock_quant_tree_editable"/> | ||
<field name="inherit_id" ref="stock.view_stock_quant_tree_editable" /> | ||
<field name="arch" type="xml"> | ||
<field name="lot_id" position="after"> | ||
<!-- We show expiry_date in tree view in order to do an "order by" on this column via the interface | ||
But the information is already in the lot_id column via name_get() --> | ||
<field name="expiry_date" optional="hide"/> | ||
<field name="expiry_date" optional="hide" /> | ||
</field> | ||
<xpath expr="/tree" position="attributes"> | ||
<attribute name="decoration-danger">expiry_date and expiry_date < current_date</attribute> | ||
<attribute | ||
name="decoration-danger" | ||
>expiry_date and expiry_date < current_date</attribute> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="quant_search_view" model="ir.ui.view"> | ||
<field name="name">product_expiry_simple.stock.quant.search</field> | ||
<field name="model">stock.quant</field> | ||
<field name="inherit_id" ref="stock.quant_search_view"/> | ||
<field name="inherit_id" ref="stock.quant_search_view" /> | ||
<field name="arch" type="xml"> | ||
<filter name="reserved" position="after"> | ||
<separator/> | ||
<filter domain="[('expiry_date', '<', context_today().strftime('%Y-%m-%d'))]" groups="stock.group_production_lot" name="expired" string="Expired"/> | ||
<filter domain="[('expiry_date', '>=', context_today().strftime('%Y-%m-%d'))]" groups="stock.group_production_lot" name="no-expired" string="Not Expired"/> | ||
<separator /> | ||
<filter | ||
domain="[('expiry_date', '<', context_today().strftime('%Y-%m-%d'))]" | ||
groups="stock.group_production_lot" | ||
name="expired" | ||
string="Expired" | ||
/> | ||
<filter | ||
domain="[('expiry_date', '>=', context_today().strftime('%Y-%m-%d'))]" | ||
groups="stock.group_production_lot" | ||
name="no-expired" | ||
string="Not Expired" | ||
/> | ||
</filter> | ||
<filter context="{'group_by': 'lot_id'}" position="after"> | ||
<filter context="{'group_by': 'expiry_date:month'}" groups="stock.group_production_lot" name="expiry_date_groupby" string="Expiry Date"/> | ||
<filter | ||
context="{'group_by': 'expiry_date:month'}" | ||
groups="stock.group_production_lot" | ||
name="expiry_date_groupby" | ||
string="Expiry Date" | ||
/> | ||
</filter> | ||
</field> | ||
</record> | ||
|
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 @@ | ||
../../../../product_expiry_simple |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |