diff --git a/.copier-answers.yml b/.copier-answers.yml index 912a05d44ed6..23134dcde81f 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -14,8 +14,10 @@ include_wkhtmltopdf: false odoo_version: 14.0 org_name: Odoo Community Association (OCA) org_slug: OCA -rebel_module_groups: [] -repo_description: 'TODO: add repo description.' +rebel_module_groups: +- product_expiry_simple +- stock_mass_scrap,stock_move_quick_lot +repo_description: Odoo Stock, Workflow and Organization repo_name: stock-logistics-workflow repo_slug: stock-logistics-workflow repo_website: https://github.com/OCA/stock-logistics-workflow diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 215b84b0f859..9637f633c538 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,9 +36,25 @@ jobs: matrix: include: - container: ghcr.io/oca/oca-ci/py3.6-odoo14.0:latest + include: "product_expiry_simple" makepot: "true" name: test with Odoo - container: ghcr.io/oca/oca-ci/py3.6-ocb14.0:latest + include: "product_expiry_simple" + name: test with OCB + - container: ghcr.io/oca/oca-ci/py3.6-odoo14.0:latest + include: "stock_mass_scrap,stock_move_quick_lot" + makepot: "true" + name: test with Odoo + - container: ghcr.io/oca/oca-ci/py3.6-ocb14.0:latest + include: "stock_mass_scrap,stock_move_quick_lot" + name: test with OCB + - container: ghcr.io/oca/oca-ci/py3.6-odoo14.0:latest + exclude: "product_expiry_simple,stock_mass_scrap,stock_move_quick_lot" + makepot: "true" + name: test with Odoo + - container: ghcr.io/oca/oca-ci/py3.6-ocb14.0:latest + exclude: "product_expiry_simple,stock_mass_scrap,stock_move_quick_lot" name: test with OCB services: postgres: @@ -49,6 +65,9 @@ jobs: POSTGRES_DB: odoo ports: - 5432:5432 + env: + INCLUDE: "${{ matrix.include }}" + EXCLUDE: "${{ matrix.exclude }}" steps: - uses: actions/checkout@v2 with: diff --git a/README.md b/README.md index b6784be3300e..9c3f778e881f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ # stock-logistics-workflow -TODO: add repo description. +Odoo Stock, Workflow and Organization diff --git a/product_expiry_simple/README.rst b/product_expiry_simple/README.rst new file mode 100644 index 000000000000..8996bb3df5b7 --- /dev/null +++ b/product_expiry_simple/README.rst @@ -0,0 +1,63 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +===================== +Product Expiry Simple +===================== + +This module is similar to the official `product_expiry `_ module that adds support for *Expiry Dates* on products, but it is both simpler and better: + +* Only one *Expiry Date* field instead of 4 fields (End of Life Date, Best before Date, Removal Date, Alert Date)! +* Use date field instead of datetime field for *Expiry Date* +* No automatic computing of Expiry Date based on a delay configured on product because it is not used most of the time (for manufacturing companies, the rules that control expiry dates are usually more complex than that ; for reseller companies, they have to copy the expiry date written on the good when they receive it in their warehouse) +* List views of production lots and quants have a color depending on expiry date: green if expiry date is in the future, red if it is in the past. +* Ability to show stats about expiry dates on quants pivot table (because, with this module, the *Expiry Date* is a related stored field on stock.quant). + +This modules keeps the main feature of the official *product_expiry* module: the support of FEFO (First Expiry First Out). + +I decided to develop this module because, after implementing *product_expiry* at several companies, I noticed that I spent more time inheriting the official *product_expiry* module to make always the same kind of changes that re-developping a simpler and better alternative. + +Configuration +============= + +No configuration needed. + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/154/11.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Alexis de Lattre +* Alan Ramos + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/product_expiry_simple/__init__.py b/product_expiry_simple/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/product_expiry_simple/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_expiry_simple/__manifest__.py b/product_expiry_simple/__manifest__.py new file mode 100644 index 000000000000..a215556223b0 --- /dev/null +++ b/product_expiry_simple/__manifest__.py @@ -0,0 +1,27 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# Copyright 2018-2021 Jarsa Sistemas (Alan Ramos ) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Product Expiry Simple", + "version": "14.0.1.0.0", + "category": "Product", + "license": "AGPL-3", + "summary": "Simpler and better alternative to the official product_expiry module", + "author": "Akretion,Jarsa Sistemas,Odoo Community Association (OCA)", + "maintainers": ["alexis-via"], + "website": "https://github.com/OCA/stock-logistics-workflow", + "depends": [ + "stock", + ], + "excludes": ["product_expiry"], + "data": [ + "data/product_removal.xml", + "views/stock_production_lot.xml", + "views/stock_quant.xml", + "views/stock_move_line.xml", + "views/stock_picking.xml", + ], + "installable": True, +} diff --git a/product_expiry_simple/data/product_removal.xml b/product_expiry_simple/data/product_removal.xml new file mode 100644 index 000000000000..2115873251c7 --- /dev/null +++ b/product_expiry_simple/data/product_removal.xml @@ -0,0 +1,7 @@ + + + + First Expiry First Out (FEFO) + fefo + + diff --git a/product_expiry_simple/i18n/de.po b/product_expiry_simple/i18n/de.po new file mode 100644 index 000000000000..073d4392d74e --- /dev/null +++ b/product_expiry_simple/i18n/de.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_expiry_simple +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-03 03:55+0000\n" +"PO-Revision-Date: 2017-12-03 03:55+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_move_line_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_production_lot_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_quant_expiry_date +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expiry Date" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Los/Serie" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Not Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_move_line +msgid "Packing Operation" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_quant +msgid "Quants" +msgstr "" diff --git a/product_expiry_simple/i18n/es.po b/product_expiry_simple/i18n/es.po new file mode 100644 index 000000000000..4ec78ae7b22d --- /dev/null +++ b/product_expiry_simple/i18n/es.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_expiry_simple +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-05 02:21+0000\n" +"PO-Revision-Date: 2018-01-05 02:21+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expired" +msgstr "Expirado" + +#. module: product_expiry_simple +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_move_line_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_production_lot_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_quant_expiry_date +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expiry Date" +msgstr "Fecha de Expiración" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lote/Nº de serie" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Not Expired" +msgstr "No Expirado" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_move_line +msgid "Packing Operation" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_quant +msgid "Quants" +msgstr "Quants" diff --git a/product_expiry_simple/i18n/it.po b/product_expiry_simple/i18n/it.po new file mode 100644 index 000000000000..65e5e2a2359f --- /dev/null +++ b/product_expiry_simple/i18n/it.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_expiry_simple +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-03 03:55+0000\n" +"PO-Revision-Date: 2017-12-03 03:55+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_move_line_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_production_lot_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_quant_expiry_date +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expiry Date" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lotto/Numero di serie" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Not Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_move_line +msgid "Packing Operation" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_quant +msgid "Quants" +msgstr "" diff --git a/product_expiry_simple/i18n/nl_NL.po b/product_expiry_simple/i18n/nl_NL.po new file mode 100644 index 000000000000..9aa97600ba4e --- /dev/null +++ b/product_expiry_simple/i18n/nl_NL.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_expiry_simple +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-17 01:29+0000\n" +"PO-Revision-Date: 2017-06-17 01:29+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expired" +msgstr "Vervallen" + +#. module: product_expiry_simple +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_move_line_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_production_lot_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_quant_expiry_date +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expiry Date" +msgstr "Vervaldatum" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_production_lot +msgid "Lot/Serial" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Not Expired" +msgstr "Niet Vervallen" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_move_line +msgid "Packing Operation" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_quant +msgid "Quants" +msgstr "" diff --git a/product_expiry_simple/i18n/product_expiry_simple.pot b/product_expiry_simple/i18n/product_expiry_simple.pot new file mode 100644 index 000000000000..bfdb9ee2f0c8 --- /dev/null +++ b/product_expiry_simple/i18n/product_expiry_simple.pot @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_expiry_simple +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_move_line_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_production_lot_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_quant_expiry_date +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expiry Date" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_production_lot +msgid "Lot/Serial" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Not Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_move_line +msgid "Packing Operation" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_quant +msgid "Quants" +msgstr "" + diff --git a/product_expiry_simple/i18n/sl.po b/product_expiry_simple/i18n/sl.po new file mode 100644 index 000000000000..8c34ab04eb41 --- /dev/null +++ b/product_expiry_simple/i18n/sl.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_expiry_simple +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-03 03:55+0000\n" +"PO-Revision-Date: 2017-12-03 03:55+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_move_line_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_production_lot_expiry_date +#: model:ir.model.fields,field_description:product_expiry_simple.field_stock_quant_expiry_date +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Expiry Date" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lot/serijska št." + +#. module: product_expiry_simple +#: model:ir.ui.view,arch_db:product_expiry_simple.quant_search_view +#: model:ir.ui.view,arch_db:product_expiry_simple.search_product_lot_filter +msgid "Not Expired" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_move_line +msgid "Packing Operation" +msgstr "" + +#. module: product_expiry_simple +#: model:ir.model,name:product_expiry_simple.model_stock_quant +msgid "Quants" +msgstr "" diff --git a/product_expiry_simple/models/__init__.py b/product_expiry_simple/models/__init__.py new file mode 100644 index 000000000000..0414e2123644 --- /dev/null +++ b/product_expiry_simple/models/__init__.py @@ -0,0 +1,4 @@ +from . import stock_production_lot +from . import stock_quant +from . import stock_move_line +from . import stock_picking diff --git a/product_expiry_simple/models/stock_move_line.py b/product_expiry_simple/models/stock_move_line.py new file mode 100644 index 000000000000..d208c8801792 --- /dev/null +++ b/product_expiry_simple/models/stock_move_line.py @@ -0,0 +1,24 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# Copyright 2018-2021 Jarsa Sistemas (Sarai Osorio ) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + expiry_date = fields.Date(string="Expiry Date") + + # When you read the code of _create_and_assign_production_lot() + # you need the defects of that method: + # 1. it's not possible to inherit the creation of the lot + # 2. it creates one lot per company/product/lot_name + # On that second point, we can consider that, for a particular product, + # lot X will always have the same expiry_date + + def _assign_production_lot(self, lot): + super()._assign_production_lot(lot) + if self[0].expiry_date: + self.lot_id.write({"expiry_date": self[0].expiry_date}) diff --git a/product_expiry_simple/models/stock_picking.py b/product_expiry_simple/models/stock_picking.py new file mode 100644 index 000000000000..cfb163c2ffd4 --- /dev/null +++ b/product_expiry_simple/models/stock_picking.py @@ -0,0 +1,35 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + show_expiry_warning = fields.Boolean(compute="_compute_show_expiry_warning") + + @api.depends( + "state", + "move_line_ids_without_package.lot_id.expiry_date", + "move_line_ids_without_package.expiry_date", + ) + def _compute_show_expiry_warning(self): + today = fields.Date.context_today(self) + for picking in self: + show = False + if picking.state in ("confirmed", "assigned"): + for mline in picking.move_line_ids_without_package: + if mline.lot_id: + if ( + mline.lot_id.expiry_date + and mline.lot_id.expiry_date < today + ): + show = True + break + elif mline.lot_name: + if mline.expiry_date and mline.expiry_date < today: + show = True + break + picking.show_expiry_warning = show diff --git a/product_expiry_simple/models/stock_production_lot.py b/product_expiry_simple/models/stock_production_lot.py new file mode 100644 index 000000000000..70666c209d11 --- /dev/null +++ b/product_expiry_simple/models/stock_production_lot.py @@ -0,0 +1,37 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# Copyright 2018-2021 Jarsa Sistemas (Alan Ramos ) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.tools.misc import format_date + + +class StockProductionLot(models.Model): + _inherit = "stock.production.lot" + + expiry_date = fields.Date(string="Expiry Date") + expired = fields.Boolean(compute="_compute_expired") + + def _compute_expired(self): + today = fields.Date.context_today(self) + for lot in self: + expired = False + if lot.expiry_date and lot.expiry_date < today: + expired = True + lot.expired = expired + + @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: + expiry_date_print = format_date(self.env, lot.expiry_date) + if lot.expiry_date < today: + dname = _("[%s Expired] %s") % (expiry_date_print, dname) + else: + dname = "[%s] %s" % (expiry_date_print, dname) + res.append((lot.id, dname)) + return res diff --git a/product_expiry_simple/models/stock_quant.py b/product_expiry_simple/models/stock_quant.py new file mode 100644 index 000000000000..0274b7240d8e --- /dev/null +++ b/product_expiry_simple/models/stock_quant.py @@ -0,0 +1,21 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# Copyright 2018-2021 Jarsa Sistemas (Alan Ramos ) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + expiry_date = fields.Date(related="lot_id.expiry_date", store=True) + expired = fields.Boolean(related="lot_id.expired") + + # method copy/pasted from the official product_expiry module + # Copyright Odoo SA + @api.model + def _get_removal_strategy_order(self, removal_strategy): + if removal_strategy == "fefo": + return "expiry_date, in_date, id" + return super()._get_removal_strategy_order(removal_strategy) diff --git a/product_expiry_simple/readme/CONTRIBUTORS.rst b/product_expiry_simple/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..29dbd507094c --- /dev/null +++ b/product_expiry_simple/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Alexis de Lattre +* Alan Ramos diff --git a/product_expiry_simple/readme/DESCRIPTION.rst b/product_expiry_simple/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..d7b8127478a7 --- /dev/null +++ b/product_expiry_simple/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +This module is similar to the official `product_expiry `_ module that adds support for *Expiry Dates* on products, but it is both simpler and better: + +* Only one *Expiry Date* field instead of 4 fields (Expiration Date, Best before Date, Removal Date, Alert Date)! +* Use date field instead of datetime field for *Expiry Date*. +* No automatic computing of Expiry Date based on a delay configured on product because it is not used most of the time (for manufacturing companies, the rules that control expiry dates are usually more complex than that ; for reseller companies, they have to copy the expiry date written on the good when they receive it in their warehouse). + +This modules keeps the main feature of the official *product_expiry* module: the support of FEFO (First Expiry First Out). + +I decided to develop this module because, after implementing *product_expiry* at several companies, I noticed that I spent more time inheriting the official *product_expiry* module to make always the same kind of changes that re-developping a simpler and better alternative. diff --git a/product_expiry_simple/static/description/icon.png b/product_expiry_simple/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/product_expiry_simple/static/description/icon.png differ diff --git a/product_expiry_simple/views/stock_move_line.xml b/product_expiry_simple/views/stock_move_line.xml new file mode 100644 index 000000000000..56f3f8f87ff1 --- /dev/null +++ b/product_expiry_simple/views/stock_move_line.xml @@ -0,0 +1,36 @@ + + + + product_expiry_simple.stock.move.line.tree + stock.move.line + + + + + + + + + product_expiry_simple.stock.move.line.tree + stock.move.line + + + + + + + + + diff --git a/product_expiry_simple/views/stock_picking.xml b/product_expiry_simple/views/stock_picking.xml new file mode 100644 index 000000000000..856298f0ad37 --- /dev/null +++ b/product_expiry_simple/views/stock_picking.xml @@ -0,0 +1,26 @@ + + + + + stock.picking + + + + + + + + + + + diff --git a/product_expiry_simple/views/stock_production_lot.xml b/product_expiry_simple/views/stock_production_lot.xml new file mode 100644 index 000000000000..b0f6aef2ce94 --- /dev/null +++ b/product_expiry_simple/views/stock_production_lot.xml @@ -0,0 +1,68 @@ + + + + + product_expiry_simple.stock.production.lot.form + stock.production.lot + + + + + + + + Expired + + + + + + product_expiry_simple.stock.production.lot.tree + stock.production.lot + + + + + + + expiry_date and expiry_date < current_date + + + + + product_expiry_simple.stock.production.lot.search + stock.production.lot + + + + + + + + + + + + + diff --git a/product_expiry_simple/views/stock_quant.xml b/product_expiry_simple/views/stock_quant.xml new file mode 100644 index 000000000000..8f1072210b46 --- /dev/null +++ b/product_expiry_simple/views/stock_quant.xml @@ -0,0 +1,95 @@ + + + + + product_expiry_simple.stock.quant.form + stock.quant + + + + + + Expired + + + + + + product_expiry_simple.stock.quant.tree + stock.quant + + + + + + + + + expiry_date and expiry_date < current_date + + + + + product_expiry_simple.stock.quant.tree.editable + stock.quant + + + + + + + + expiry_date and expiry_date < current_date + + + + + + product_expiry_simple.stock.quant.search + stock.quant + + + + + + + + + + + + + diff --git a/setup/product_expiry_simple/odoo/addons/product_expiry_simple b/setup/product_expiry_simple/odoo/addons/product_expiry_simple new file mode 120000 index 000000000000..edd445bc8233 --- /dev/null +++ b/setup/product_expiry_simple/odoo/addons/product_expiry_simple @@ -0,0 +1 @@ +../../../../product_expiry_simple \ No newline at end of file diff --git a/setup/product_expiry_simple/setup.py b/setup/product_expiry_simple/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/product_expiry_simple/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)