From e44f519f7786885c24cb02030f07894f9769395a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 21 Nov 2014 10:22:25 +0100 Subject: [PATCH 01/18] Add modules stock_packaging_usability and stock_packaging_usability_ul --- stock_packaging_usability/__init__.py | 23 +++++++ stock_packaging_usability/__openerp__.py | 50 +++++++++++++++ stock_packaging_usability/i18n/fr.po | 64 +++++++++++++++++++ .../i18n/stock_packaging_usability.pot | 64 +++++++++++++++++++ stock_packaging_usability/wizard/__init__.py | 23 +++++++ .../wizard/stock_transfer_details.py | 62 ++++++++++++++++++ .../wizard/stock_transfer_details.xml | 41 ++++++++++++ 7 files changed, 327 insertions(+) create mode 100644 stock_packaging_usability/__init__.py create mode 100644 stock_packaging_usability/__openerp__.py create mode 100644 stock_packaging_usability/i18n/fr.po create mode 100644 stock_packaging_usability/i18n/stock_packaging_usability.pot create mode 100644 stock_packaging_usability/wizard/__init__.py create mode 100644 stock_packaging_usability/wizard/stock_transfer_details.py create mode 100644 stock_packaging_usability/wizard/stock_transfer_details.xml diff --git a/stock_packaging_usability/__init__.py b/stock_packaging_usability/__init__.py new file mode 100644 index 00000000000..ac300d8daa6 --- /dev/null +++ b/stock_packaging_usability/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Stock Packaging Usability module for Odoo +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import wizard diff --git a/stock_packaging_usability/__openerp__.py b/stock_packaging_usability/__openerp__.py new file mode 100644 index 00000000000..89ccc8e68e1 --- /dev/null +++ b/stock_packaging_usability/__openerp__.py @@ -0,0 +1,50 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Stock Packaging Usability module for Odoo +# Copyright (C) 2014 Akretion (http://www.akretion.com). +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Stock Packaging Usability', + 'version': '1.0', + 'category': 'Warehouse Management', + 'license': 'AGPL-3', + 'summary': "Faster packaging process in Odoo", + 'description': """ +This module adds 2 buttons in the *Transfer* wizard of the picking: + +* *Put in current pack* (this button is native in v7 but not in v8) + +* *Put residual in new pack* : all the lines that are not in a package + will be put in a new package. + +So this module is a time saver when you use the packaging features of Odoo ! +For example, on a picking where all the products go in the same package, you +just have to click on the button *Put residual in new pack* and you're done: +no need to click on each line ! + +This module has been written by Alexis de Lattre from Akretion + + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['stock'], + 'data': ['wizard/stock_transfer_details.xml'], + 'installable': True, +} diff --git a/stock_packaging_usability/i18n/fr.po b/stock_packaging_usability/i18n/fr.po new file mode 100644 index 00000000000..c352ae1b1d8 --- /dev/null +++ b/stock_packaging_usability/i18n/fr.po @@ -0,0 +1,64 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_packaging_usability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-11-21 08:57+0000\n" +"PO-Revision-Date: 2014-11-21 08:57+0000\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: stock_packaging_usability +#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details +msgid "Picking wizard" +msgstr "Picking wizard" + +#. module: stock_packaging_usability +#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details_items +msgid "Picking wizard items" +msgstr "Picking wizard items" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Products To Move" +msgstr "Produits à déplacer" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Put Residual in New Pack" +msgstr "Mettre le reste dans un nouveau paquet" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Put in current pack" +msgstr "Mettre dans le paquet actuel" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Put in new pack" +msgstr "Mettre dans un nouveau paquet" + +#. module: stock_packaging_usability +#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:58 +#, python-format +msgid "There is no current package" +msgstr "Il n'y a pas de paquet actuel" + +#. module: stock_packaging_usability +#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:52 +#, python-format +msgid "This product is already in a package !" +msgstr "Ce produit est déjà dans un paquet !" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "terp-accessories-archiver+" +msgstr "terp-accessories-archiver+" + diff --git a/stock_packaging_usability/i18n/stock_packaging_usability.pot b/stock_packaging_usability/i18n/stock_packaging_usability.pot new file mode 100644 index 00000000000..b38719f355c --- /dev/null +++ b/stock_packaging_usability/i18n/stock_packaging_usability.pot @@ -0,0 +1,64 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_packaging_usability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-11-21 08:57+0000\n" +"PO-Revision-Date: 2014-11-21 08:57+0000\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: stock_packaging_usability +#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details +msgid "Picking wizard" +msgstr "" + +#. module: stock_packaging_usability +#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details_items +msgid "Picking wizard items" +msgstr "" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Products To Move" +msgstr "" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Put Residual in New Pack" +msgstr "" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Put in current pack" +msgstr "" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "Put in new pack" +msgstr "" + +#. module: stock_packaging_usability +#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:58 +#, python-format +msgid "There is no current package" +msgstr "" + +#. module: stock_packaging_usability +#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:52 +#, python-format +msgid "This product is already in a package !" +msgstr "" + +#. module: stock_packaging_usability +#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details +msgid "terp-accessories-archiver+" +msgstr "" + diff --git a/stock_packaging_usability/wizard/__init__.py b/stock_packaging_usability/wizard/__init__.py new file mode 100644 index 00000000000..63c910e4058 --- /dev/null +++ b/stock_packaging_usability/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Stock Packaging Usability module for Odoo +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import stock_transfer_details diff --git a/stock_packaging_usability/wizard/stock_transfer_details.py b/stock_packaging_usability/wizard/stock_transfer_details.py new file mode 100644 index 00000000000..b6eb2ba0b15 --- /dev/null +++ b/stock_packaging_usability/wizard/stock_transfer_details.py @@ -0,0 +1,62 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Stock Packaging Usability module for Odoo +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, api, _ +from openerp.exceptions import Warning + + +class StockTransferDetails(models.TransientModel): + _inherit = 'stock.transfer_details' + + @api.multi + def put_residual_in_new_pack(self): + for wiz in self: + items_to_update = wiz.item_ids + for item in wiz.item_ids: + if item.result_package_id: + items_to_update -= item + if not item.quantity: + items_to_update -= item + items_to_update.put_in_pack() + if self and self[0]: + return self[0].wizard_view() + + +class StockTransferDetailsItems(models.TransientModel): + _inherit = 'stock.transfer_details_items' + + @api.multi + def put_in_last_pack(self): + for packop in self: + if packop.result_package_id: + raise Warning( + _('This product is already in a package !')) + all_cur_packs_ids = [ + packop2.result_package_id.id for packop2 + in self.transfer_id.item_ids if packop2.result_package_id] + if not all_cur_packs_ids: + raise Warning( + _('There is no current package')) + all_cur_packs_ids.sort() + packop.result_package_id = all_cur_packs_ids[-1] + if self and self[0]: + return self[0].transfer_id.wizard_view() diff --git a/stock_packaging_usability/wizard/stock_transfer_details.xml b/stock_packaging_usability/wizard/stock_transfer_details.xml new file mode 100644 index 00000000000..0415dcfbb55 --- /dev/null +++ b/stock_packaging_usability/wizard/stock_transfer_details.xml @@ -0,0 +1,41 @@ + + + + + + + + + + stock_packaging_usability.stock.transfer_details + stock.transfer_details + + + + + + + + + + + + From 7d0d9942443e6e41459309ce4f87ae4230ca7b73 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 22 Jan 2015 12:48:08 +0100 Subject: [PATCH 02/18] Move module description in README.rst --- stock_packaging_usability/README.rst | 38 ++++++++++++++++++++++++ stock_packaging_usability/__openerp__.py | 16 ---------- 2 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 stock_packaging_usability/README.rst diff --git a/stock_packaging_usability/README.rst b/stock_packaging_usability/README.rst new file mode 100644 index 00000000000..e616cf1c76a --- /dev/null +++ b/stock_packaging_usability/README.rst @@ -0,0 +1,38 @@ +Stock Packaging Usability +========================= + +Usage +===== + +This module adds 2 buttons in the *Transfer* wizard of the picking: + +* *Put in current pack* (this button is native in v7 but not in v8) + +* *Put residual in new pack* : all the lines that are not in a package + will be put in a new package. + +So this module is a time saver when you use the packaging features of Odoo ! +For example, on a picking where all the products go in the same package, you +just have to click on the button *Put residual in new pack* and you're done: +no need to click on each line ! + +Credits +======= + +Contributors +------------ + +* Alexis de Lattre + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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 http://odoo-community.org. diff --git a/stock_packaging_usability/__openerp__.py b/stock_packaging_usability/__openerp__.py index 89ccc8e68e1..2cee01021ae 100644 --- a/stock_packaging_usability/__openerp__.py +++ b/stock_packaging_usability/__openerp__.py @@ -26,22 +26,6 @@ 'category': 'Warehouse Management', 'license': 'AGPL-3', 'summary': "Faster packaging process in Odoo", - 'description': """ -This module adds 2 buttons in the *Transfer* wizard of the picking: - -* *Put in current pack* (this button is native in v7 but not in v8) - -* *Put residual in new pack* : all the lines that are not in a package - will be put in a new package. - -So this module is a time saver when you use the packaging features of Odoo ! -For example, on a picking where all the products go in the same package, you -just have to click on the button *Put residual in new pack* and you're done: -no need to click on each line ! - -This module has been written by Alexis de Lattre from Akretion - - """, 'author': 'Akretion', 'website': 'http://www.akretion.com', 'depends': ['stock'], From 514e26ccfac20b9ce0aa293ed1ec6d0460b14d1f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 17 Feb 2015 10:56:23 +0100 Subject: [PATCH 03/18] Take into account the remarks of Yannick: self[0] -> self, updates in fr.po --- stock_packaging_usability/i18n/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock_packaging_usability/i18n/fr.po b/stock_packaging_usability/i18n/fr.po index c352ae1b1d8..9ef2167ac35 100644 --- a/stock_packaging_usability/i18n/fr.po +++ b/stock_packaging_usability/i18n/fr.po @@ -18,12 +18,12 @@ msgstr "" #. module: stock_packaging_usability #: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details msgid "Picking wizard" -msgstr "Picking wizard" +msgstr "" #. module: stock_packaging_usability #: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details_items msgid "Picking wizard items" -msgstr "Picking wizard items" +msgstr "" #. module: stock_packaging_usability #: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details From f214bd30f748a429b19015145942c9fe5da68ba2 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 22 May 2015 19:45:46 +0200 Subject: [PATCH 04/18] Add bug tracker link on README.rst --- stock_packaging_usability/README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stock_packaging_usability/README.rst b/stock_packaging_usability/README.rst index e616cf1c76a..6705ebaba31 100644 --- a/stock_packaging_usability/README.rst +++ b/stock_packaging_usability/README.rst @@ -16,6 +16,16 @@ For example, on a picking where all the products go in the same package, you just have to click on the button *Put residual in new pack* and you're done: no need to click on each line ! + +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 +`here `_. + + Credits ======= From afc4d3ec7f3048021693291df727a8a91a6d5306 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 15 Aug 2015 23:54:42 +0200 Subject: [PATCH 05/18] Add OCA as author in __openerp__.py --- stock_packaging_usability/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_packaging_usability/__openerp__.py b/stock_packaging_usability/__openerp__.py index 2cee01021ae..7f3c0b4831c 100644 --- a/stock_packaging_usability/__openerp__.py +++ b/stock_packaging_usability/__openerp__.py @@ -26,7 +26,7 @@ 'category': 'Warehouse Management', 'license': 'AGPL-3', 'summary': "Faster packaging process in Odoo", - 'author': 'Akretion', + 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'http://www.akretion.com', 'depends': ['stock'], 'data': ['wizard/stock_transfer_details.xml'], From f8920338b22d11b50d106c610d019f1e6ea0a242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 9 Oct 2015 10:03:14 +0200 Subject: [PATCH 06/18] prefix versions with 8.0 --- stock_packaging_usability/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_packaging_usability/__openerp__.py b/stock_packaging_usability/__openerp__.py index 7f3c0b4831c..9f0561f67ea 100644 --- a/stock_packaging_usability/__openerp__.py +++ b/stock_packaging_usability/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Stock Packaging Usability', - 'version': '1.0', + 'version': '8.0.1.0.0', 'category': 'Warehouse Management', 'license': 'AGPL-3', 'summary': "Faster packaging process in Odoo", From 175e5f92c7119abfec97c635cec6ee6bc5ef0182 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 14 Oct 2015 02:54:33 +0200 Subject: [PATCH 07/18] Make modules uninstallable --- stock_packaging_usability/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_packaging_usability/__openerp__.py b/stock_packaging_usability/__openerp__.py index 9f0561f67ea..22affe4ae3a 100644 --- a/stock_packaging_usability/__openerp__.py +++ b/stock_packaging_usability/__openerp__.py @@ -30,5 +30,5 @@ 'website': 'http://www.akretion.com', 'depends': ['stock'], 'data': ['wizard/stock_transfer_details.xml'], - 'installable': True, + 'installable': False, } From f521cea6a9580c2e3f5462c9bc05af7703357fd6 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 16:09:15 +0200 Subject: [PATCH 08/18] Rename manifest files --- stock_packaging_usability/{__openerp__.py => __manifest__.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename stock_packaging_usability/{__openerp__.py => __manifest__.py} (100%) diff --git a/stock_packaging_usability/__openerp__.py b/stock_packaging_usability/__manifest__.py similarity index 100% rename from stock_packaging_usability/__openerp__.py rename to stock_packaging_usability/__manifest__.py From 8ccbfc3ced8d897215f19511ee9535e9d744419f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 9 Feb 2018 21:55:11 +0100 Subject: [PATCH 09/18] Port stock_packaging usability to v10 --- stock_packaging_usability/README.rst | 39 +++++++----- stock_packaging_usability/__init__.py | 24 +------ stock_packaging_usability/__manifest__.py | 34 +++------- stock_packaging_usability/models/__init__.py | 3 + .../models/stock_pack_operation.py | 54 ++++++++++++++++ .../views/stock_picking.xml | 32 ++++++++++ stock_packaging_usability/wizard/__init__.py | 23 ------- .../wizard/stock_transfer_details.py | 62 ------------------- .../wizard/stock_transfer_details.xml | 41 ------------ 9 files changed, 122 insertions(+), 190 deletions(-) create mode 100644 stock_packaging_usability/models/__init__.py create mode 100644 stock_packaging_usability/models/stock_pack_operation.py create mode 100644 stock_packaging_usability/views/stock_picking.xml delete mode 100644 stock_packaging_usability/wizard/__init__.py delete mode 100644 stock_packaging_usability/wizard/stock_transfer_details.py delete mode 100644 stock_packaging_usability/wizard/stock_transfer_details.xml diff --git a/stock_packaging_usability/README.rst b/stock_packaging_usability/README.rst index 6705ebaba31..29121168a79 100644 --- a/stock_packaging_usability/README.rst +++ b/stock_packaging_usability/README.rst @@ -1,30 +1,33 @@ +.. 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 + +========================= Stock Packaging Usability ========================= Usage ===== -This module adds 2 buttons in the *Transfer* wizard of the picking: +This module adds 2 buttons in the *Operations* lines of a picking: -* *Put in current pack* (this button is native in v7 but not in v8) +* *Put in current pack* -* *Put residual in new pack* : all the lines that are not in a package - will be put in a new package. +* *Put in new pack* -So this module is a time saver when you use the packaging features of Odoo ! -For example, on a picking where all the products go in the same package, you -just have to click on the button *Put residual in new pack* and you're done: -no need to click on each line ! +It is a complement of the button *Put in Pack* which is available on the picking. With these 2 new buttons, you are not obliged to set the *Done quantity* package by package. +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/152/10.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 -`here `_. - +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 ======= @@ -37,12 +40,14 @@ Contributors Maintainer ---------- -.. image:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :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. +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 http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/stock_packaging_usability/__init__.py b/stock_packaging_usability/__init__.py index ac300d8daa6..cde864bae21 100644 --- a/stock_packaging_usability/__init__.py +++ b/stock_packaging_usability/__init__.py @@ -1,23 +1,3 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Stock Packaging Usability module for Odoo -# Copyright (C) 2014 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- -from . import wizard +from . import models diff --git a/stock_packaging_usability/__manifest__.py b/stock_packaging_usability/__manifest__.py index 22affe4ae3a..982768edc8d 100644 --- a/stock_packaging_usability/__manifest__.py +++ b/stock_packaging_usability/__manifest__.py @@ -1,34 +1,18 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Stock Packaging Usability module for Odoo -# Copyright (C) 2014 Akretion (http://www.akretion.com). -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2018 Akretion (http://www.akretion.com). +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + { 'name': 'Stock Packaging Usability', - 'version': '8.0.1.0.0', - 'category': 'Warehouse Management', + 'version': '10.0.1.0.0', + 'category': 'Warehouse', 'license': 'AGPL-3', 'summary': "Faster packaging process in Odoo", 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'http://www.akretion.com', 'depends': ['stock'], - 'data': ['wizard/stock_transfer_details.xml'], - 'installable': False, + 'data': ['views/stock_picking.xml'], + 'installable': True, } diff --git a/stock_packaging_usability/models/__init__.py b/stock_packaging_usability/models/__init__.py new file mode 100644 index 00000000000..55509b693fc --- /dev/null +++ b/stock_packaging_usability/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import stock_pack_operation diff --git a/stock_packaging_usability/models/stock_pack_operation.py b/stock_packaging_usability/models/stock_pack_operation.py new file mode 100644 index 00000000000..28170d3a0e6 --- /dev/null +++ b/stock_packaging_usability/models/stock_pack_operation.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# © 2014-2018 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import models, _ +from odoo.exceptions import UserError +from odoo.tools import float_compare, float_is_zero + + +class StockPackOperation(models.Model): + _inherit = 'stock.pack.operation' + + def put_in_new_pack(self): + self.ensure_one() + pack = self.env['stock.quant.package'].create({}) + self.put_in_target_pack(pack.id) + + def put_in_last_pack(self): + all_cur_packs_ids = [ + packop2.result_package_id.id for packop2 + in self.picking_id.pack_operation_ids if packop2.result_package_id] + if not all_cur_packs_ids: + raise UserError(_('There is no current package.')) + pack_id = max(all_cur_packs_ids) + self.put_in_target_pack(pack_id) + + def put_in_target_pack(self, pack_id): + self.ensure_one() + assert pack_id, 'pack_id is a required argument' + prec = self.env['decimal.precision'].precision_get( + 'Product Unit of Measure') + if float_is_zero(self.qty_done, precision_digits=prec): + raise UserError(_("Qty done is 0")) + if self.result_package_id: + raise UserError(_("This operation is already packaged.")) + packop_to_pack = self + if float_compare( + self.qty_done, self.product_qty, precision_digits=prec) < 0: + new_packop = self.copy( + {'product_qty': self.qty_done, 'qty_done': self.qty_done}) + self.write({ + 'product_qty': self.product_qty - self.qty_done, + 'qty_done': 0, + }) + if self.pack_lot_ids: + new_packop.write({ + 'pack_lot_ids': [(6, 0, self.pack_lot_ids.ids)]}) + new_packop._copy_remaining_pack_lot_ids(self) + packop_to_pack = new_packop + + packop_to_pack._check_serial_number() + packop_to_pack.result_package_id = pack_id diff --git a/stock_packaging_usability/views/stock_picking.xml b/stock_packaging_usability/views/stock_picking.xml new file mode 100644 index 00000000000..65e2e1991d6 --- /dev/null +++ b/stock_packaging_usability/views/stock_picking.xml @@ -0,0 +1,32 @@ + + + + + + + + stock_packaging_usability.stock.picking.form + stock.picking + + + + - - - - - - - - From 11f20ec43e44c653438d007946608f918f14fbde Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 3 Apr 2018 18:27:37 +0200 Subject: [PATCH 10/18] stock_packaging_usability: improve README.rst --- stock_packaging_usability/README.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stock_packaging_usability/README.rst b/stock_packaging_usability/README.rst index 29121168a79..1f597ed796f 100644 --- a/stock_packaging_usability/README.rst +++ b/stock_packaging_usability/README.rst @@ -6,6 +6,13 @@ Stock Packaging Usability ========================= +Configuration +============= + +Go to the Settings page of the Inventory menu and enable the option +*Record packages used on packing: pallets, boxes, ...*: it will add all +users to the group *Manage Packages*. + Usage ===== From 3c82a6f27b59b59803f8a907364ee8b6b5756850 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 6 Jul 2019 01:12:09 +0200 Subject: [PATCH 11/18] [MIG] stock_packaging_usability from v10 to v12 Add module stock_packaging_usability_pp --- stock_packaging_usability/__init__.py | 2 - stock_packaging_usability/__manifest__.py | 10 +- stock_packaging_usability/models/__init__.py | 4 +- .../models/stock_move_line.py | 80 ++++++++++++++++ .../models/stock_pack_operation.py | 54 ----------- .../readme/CONFIGURE.rst | 3 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 1 + stock_packaging_usability/readme/USAGE.rst | 7 ++ .../views/stock_move_line.xml | 34 +++++++ .../views/stock_picking.xml | 4 +- stock_packaging_usability_pp/__init__.py | 1 + stock_packaging_usability_pp/__manifest__.py | 25 +++++ stock_packaging_usability_pp/i18n/fr.po | 93 +++++++++++++++++++ .../i18n/stock_packaging_usability_ul.pot | 93 +++++++++++++++++++ .../readme/CONFIGURE.rst | 3 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 1 + stock_packaging_usability_pp/readme/USAGE.rst | 5 + .../views/product_packaging.xml | 47 ++++++++++ .../views/stock_move_line.xml | 25 +++++ .../views/stock_picking.xml | 30 ++++++ .../views/stock_quant_package.xml | 28 ++++++ .../wizard/__init__.py | 1 + .../wizard/stock_select_product_packaging.py | 36 +++++++ .../stock_select_product_packaging_view.xml | 35 +++++++ 26 files changed, 559 insertions(+), 65 deletions(-) create mode 100644 stock_packaging_usability/models/stock_move_line.py delete mode 100644 stock_packaging_usability/models/stock_pack_operation.py create mode 100644 stock_packaging_usability/readme/CONFIGURE.rst create mode 100644 stock_packaging_usability/readme/CONTRIBUTORS.rst create mode 100644 stock_packaging_usability/readme/DESCRIPTION.rst create mode 100644 stock_packaging_usability/readme/USAGE.rst create mode 100644 stock_packaging_usability/views/stock_move_line.xml create mode 100644 stock_packaging_usability_pp/__init__.py create mode 100644 stock_packaging_usability_pp/__manifest__.py create mode 100644 stock_packaging_usability_pp/i18n/fr.po create mode 100644 stock_packaging_usability_pp/i18n/stock_packaging_usability_ul.pot create mode 100644 stock_packaging_usability_pp/readme/CONFIGURE.rst create mode 100644 stock_packaging_usability_pp/readme/CONTRIBUTORS.rst create mode 100644 stock_packaging_usability_pp/readme/DESCRIPTION.rst create mode 100644 stock_packaging_usability_pp/readme/USAGE.rst create mode 100644 stock_packaging_usability_pp/views/product_packaging.xml create mode 100644 stock_packaging_usability_pp/views/stock_move_line.xml create mode 100644 stock_packaging_usability_pp/views/stock_picking.xml create mode 100644 stock_packaging_usability_pp/views/stock_quant_package.xml create mode 100644 stock_packaging_usability_pp/wizard/__init__.py create mode 100644 stock_packaging_usability_pp/wizard/stock_select_product_packaging.py create mode 100644 stock_packaging_usability_pp/wizard/stock_select_product_packaging_view.xml diff --git a/stock_packaging_usability/__init__.py b/stock_packaging_usability/__init__.py index cde864bae21..0650744f6bc 100644 --- a/stock_packaging_usability/__init__.py +++ b/stock_packaging_usability/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import models diff --git a/stock_packaging_usability/__manifest__.py b/stock_packaging_usability/__manifest__.py index 982768edc8d..88f46aa8f45 100644 --- a/stock_packaging_usability/__manifest__.py +++ b/stock_packaging_usability/__manifest__.py @@ -1,18 +1,20 @@ -# -*- coding: utf-8 -*- -# © 2014-2018 Akretion (http://www.akretion.com). +# Copyright 2014-2019 Akretion France (http://www.akretion.com). # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Stock Packaging Usability', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Warehouse', 'license': 'AGPL-3', 'summary': "Faster packaging process in Odoo", 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'http://www.akretion.com', 'depends': ['stock'], - 'data': ['views/stock_picking.xml'], + 'data': [ + 'views/stock_picking.xml', + 'views/stock_move_line.xml', + ], 'installable': True, } diff --git a/stock_packaging_usability/models/__init__.py b/stock_packaging_usability/models/__init__.py index 55509b693fc..431f51c2747 100644 --- a/stock_packaging_usability/models/__init__.py +++ b/stock_packaging_usability/models/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - -from . import stock_pack_operation +from . import stock_move_line diff --git a/stock_packaging_usability/models/stock_move_line.py b/stock_packaging_usability/models/stock_move_line.py new file mode 100644 index 00000000000..fab7451007e --- /dev/null +++ b/stock_packaging_usability/models/stock_move_line.py @@ -0,0 +1,80 @@ +# Copyright 2014-2019 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 models, _ +from odoo.exceptions import UserError +from odoo.tools import float_compare, float_is_zero + + +class StockMoveLine(models.Model): + _inherit = 'stock.move.line' + + def put_in_new_pack(self): + self.ensure_one() + pack = self.env['stock.quant.package'].create({}) + pack_level = self.env['stock.package_level'].create({ + 'package_id': pack.id, + 'picking_id': self.picking_id.id, + 'location_id': False, + 'location_dest_id': self.location_dest_id.id, + 'move_line_ids': [(6, 0, [self.id])], + }) + self._put_in_target_pack(pack, pack_level) + action = {} + if self._context.get('stock_packaging_usability_return_action'): + action = self.move_id.action_show_details() + return action + + def put_in_last_pack(self): + all_cur_packs_ids = [ + moveline2.result_package_id.id for moveline2 + in self.picking_id.move_line_ids if moveline2.result_package_id] + if not all_cur_packs_ids: + raise UserError(_('There is no current package.')) + pack_id = max(all_cur_packs_ids) + pack = self.env['stock.quant.package'].browse(pack_id) + pack_levels = self.env['stock.package_level'].search([('package_id', '=', pack_id)]) + if not pack_levels: + raise UserError(_( + "Could not find any package level linked to package '%s'.") + % pack.display_name) + if len(pack_levels) > 1: + raise UserError(_( + "There are several package levels linked to package '%s'.") + % pack.display_name) + self._put_in_target_pack(pack, pack_levels) + action = {} + if self._context.get('stock_packaging_usability_return_action'): + action = self.move_id.action_show_details() + return action + + def _put_in_target_pack(self, pack, pack_level): + self.ensure_one() + assert pack, 'pack is a required argument' + prec = self.env['decimal.precision'].precision_get( + 'Product Unit of Measure') + if float_is_zero(self.qty_done, precision_digits=prec): + raise UserError(_("Qty done is 0")) + if self.result_package_id: + raise UserError(_("This operation is already packaged.")) + moveline_to_pack = self + if float_compare( + self.qty_done, self.product_uom_qty, precision_digits=prec) < 0: + # QUESTION it is still unclear to me why we have to put + # product_uom_qty = 0 instead of product_uom_qty = self.qty_done + # in copy(). It gives good results in Detailed operations, but slightly + # wired behavior in "Operations". But, if we set + # product_uom_qty = self.qty_done, we get the error msg + # "It is not possible to unreserve more products of xx + # than you have in stock" + new_moveline = self.copy( + {'product_uom_qty': 0, 'qty_done': self.qty_done}) + self.write({ + 'product_uom_qty': self.product_uom_qty - self.qty_done, + 'qty_done': 0, + }) + moveline_to_pack = new_moveline + pack_level.move_line_ids = [(4, moveline_to_pack.id)] + moveline_to_pack.result_package_id = pack.id diff --git a/stock_packaging_usability/models/stock_pack_operation.py b/stock_packaging_usability/models/stock_pack_operation.py deleted file mode 100644 index 28170d3a0e6..00000000000 --- a/stock_packaging_usability/models/stock_pack_operation.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2014-2018 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - - -from odoo import models, _ -from odoo.exceptions import UserError -from odoo.tools import float_compare, float_is_zero - - -class StockPackOperation(models.Model): - _inherit = 'stock.pack.operation' - - def put_in_new_pack(self): - self.ensure_one() - pack = self.env['stock.quant.package'].create({}) - self.put_in_target_pack(pack.id) - - def put_in_last_pack(self): - all_cur_packs_ids = [ - packop2.result_package_id.id for packop2 - in self.picking_id.pack_operation_ids if packop2.result_package_id] - if not all_cur_packs_ids: - raise UserError(_('There is no current package.')) - pack_id = max(all_cur_packs_ids) - self.put_in_target_pack(pack_id) - - def put_in_target_pack(self, pack_id): - self.ensure_one() - assert pack_id, 'pack_id is a required argument' - prec = self.env['decimal.precision'].precision_get( - 'Product Unit of Measure') - if float_is_zero(self.qty_done, precision_digits=prec): - raise UserError(_("Qty done is 0")) - if self.result_package_id: - raise UserError(_("This operation is already packaged.")) - packop_to_pack = self - if float_compare( - self.qty_done, self.product_qty, precision_digits=prec) < 0: - new_packop = self.copy( - {'product_qty': self.qty_done, 'qty_done': self.qty_done}) - self.write({ - 'product_qty': self.product_qty - self.qty_done, - 'qty_done': 0, - }) - if self.pack_lot_ids: - new_packop.write({ - 'pack_lot_ids': [(6, 0, self.pack_lot_ids.ids)]}) - new_packop._copy_remaining_pack_lot_ids(self) - packop_to_pack = new_packop - - packop_to_pack._check_serial_number() - packop_to_pack.result_package_id = pack_id diff --git a/stock_packaging_usability/readme/CONFIGURE.rst b/stock_packaging_usability/readme/CONFIGURE.rst new file mode 100644 index 00000000000..8396e6d808f --- /dev/null +++ b/stock_packaging_usability/readme/CONFIGURE.rst @@ -0,0 +1,3 @@ +Go to the Configuration page of the Inventory menu and enable the option +*Delivery Packages* (Put your products in packs and track them): it will add all +users to the group *Manage Packages*. diff --git a/stock_packaging_usability/readme/CONTRIBUTORS.rst b/stock_packaging_usability/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..ff65d68ce6d --- /dev/null +++ b/stock_packaging_usability/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alexis de Lattre diff --git a/stock_packaging_usability/readme/DESCRIPTION.rst b/stock_packaging_usability/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..633317cadd8 --- /dev/null +++ b/stock_packaging_usability/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module makes it faster to define which product goes in which pack on an outgoing picking. diff --git a/stock_packaging_usability/readme/USAGE.rst b/stock_packaging_usability/readme/USAGE.rst new file mode 100644 index 00000000000..ba9a8f129e4 --- /dev/null +++ b/stock_packaging_usability/readme/USAGE.rst @@ -0,0 +1,7 @@ +This module adds 2 buttons in the *Operations* lines of a picking: + +* *Put in current pack* + +* *Put in new pack* + +It is a complement of the button *Put in Pack* which is available on the picking. With these 2 new buttons, you are not obliged to set the *Done quantity* package by package. diff --git a/stock_packaging_usability/views/stock_move_line.xml b/stock_packaging_usability/views/stock_move_line.xml new file mode 100644 index 00000000000..1b4668929bf --- /dev/null +++ b/stock_packaging_usability/views/stock_move_line.xml @@ -0,0 +1,34 @@ + + + + + + + + stock_packaging_usability.stock.move.line.form + stock.move.line + + + + + + + + + diff --git a/stock_packaging_usability_pp/views/stock_picking.xml b/stock_packaging_usability_pp/views/stock_picking.xml new file mode 100644 index 00000000000..5d65252694a --- /dev/null +++ b/stock_packaging_usability_pp/views/stock_picking.xml @@ -0,0 +1,30 @@ + + + + + + + + stock_packaging_usability_pp.stock.picking.form + stock.picking + + + + + + + + + diff --git a/stock_packaging_usability_pp/views/stock_quant_package.xml b/stock_packaging_usability_pp/views/stock_quant_package.xml new file mode 100644 index 00000000000..0ec4872b453 --- /dev/null +++ b/stock_packaging_usability_pp/views/stock_quant_package.xml @@ -0,0 +1,28 @@ + + + + + + + + stock_packaging_usability_pp.stock.quant.package.kanban + stock.quant.package + + + + + +
+
+ +
+
+
+
+ + +
diff --git a/stock_packaging_usability_pp/wizard/__init__.py b/stock_packaging_usability_pp/wizard/__init__.py new file mode 100644 index 00000000000..212240ca1a1 --- /dev/null +++ b/stock_packaging_usability_pp/wizard/__init__.py @@ -0,0 +1 @@ +from . import stock_select_product_packaging diff --git a/stock_packaging_usability_pp/wizard/stock_select_product_packaging.py b/stock_packaging_usability_pp/wizard/stock_select_product_packaging.py new file mode 100644 index 00000000000..9e8a2be83bc --- /dev/null +++ b/stock_packaging_usability_pp/wizard/stock_select_product_packaging.py @@ -0,0 +1,36 @@ +# Copyright 2014-2019 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 fields, models + + +class StockSelectProductPackaging(models.TransientModel): + _name = 'stock.select.product.packaging' + _description = 'Select Product Packaging' + + packaging_id = fields.Many2one('product.packaging', string='Packaging') + # required=False, because we accept that it can be left empty + + def validate(self): + self.ensure_one() + packaging = self.packaging_id + assert self.env.context.get('pack_function') is not None, \ + 'missing context key pack_function' + self = self.with_context( + default_packaging_id=(packaging and packaging.id or False)) + action = {} + if self._context.get('pack_function') == 'put_selection_in_new_pack': + assert self.env.context.get('active_model') == \ + 'stock.picking', 'Wrong underlying model' + pick = self.env['stock.picking'].browse( + self.env.context['active_id']) + pick.put_in_pack() + elif self._context.get('pack_function') == 'put_in_new_pack': + assert self.env.context.get('active_model') == \ + 'stock.move.line', 'Wrong underlying model' + ml = self.env['stock.move.line'].browse( + self.env.context['active_id']) + action = ml.put_in_new_pack() + return action diff --git a/stock_packaging_usability_pp/wizard/stock_select_product_packaging_view.xml b/stock_packaging_usability_pp/wizard/stock_select_product_packaging_view.xml new file mode 100644 index 00000000000..021f69a3aa8 --- /dev/null +++ b/stock_packaging_usability_pp/wizard/stock_select_product_packaging_view.xml @@ -0,0 +1,35 @@ + + + + + + + + stock.select.product.packaging + +
+ + + +
+
+
+
+
+ + + Select Packaging + stock.select.product.packaging + form + new + + + +
From 2988ee6817a1f6928de6ab5e4ee0f91fab19f24f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 9 Jul 2019 16:34:06 +0200 Subject: [PATCH 12/18] Add fields on product.packaging, in particular the empty weight of the packaging Fix Odoo problem with weight computation https://github.com/odoo/odoo/issues/34702 --- stock_packaging_usability_pp/__init__.py | 1 + .../models/__init__.py | 3 ++ .../models/product_packaging.py | 25 +++++++++ .../models/stock_move.py | 22 ++++++++ .../models/stock_quant_package.py | 42 +++++++++++++++ .../views/product_packaging.xml | 52 +++++++++++++++++-- 6 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 stock_packaging_usability_pp/models/__init__.py create mode 100644 stock_packaging_usability_pp/models/product_packaging.py create mode 100644 stock_packaging_usability_pp/models/stock_move.py create mode 100644 stock_packaging_usability_pp/models/stock_quant_package.py diff --git a/stock_packaging_usability_pp/__init__.py b/stock_packaging_usability_pp/__init__.py index 40272379f72..9b4296142f4 100644 --- a/stock_packaging_usability_pp/__init__.py +++ b/stock_packaging_usability_pp/__init__.py @@ -1 +1,2 @@ +from . import models from . import wizard diff --git a/stock_packaging_usability_pp/models/__init__.py b/stock_packaging_usability_pp/models/__init__.py new file mode 100644 index 00000000000..a8918ac46b4 --- /dev/null +++ b/stock_packaging_usability_pp/models/__init__.py @@ -0,0 +1,3 @@ +from . import product_packaging +from . import stock_quant_package +from . import stock_move diff --git a/stock_packaging_usability_pp/models/product_packaging.py b/stock_packaging_usability_pp/models/product_packaging.py new file mode 100644 index 00000000000..ac9390d14a5 --- /dev/null +++ b/stock_packaging_usability_pp/models/product_packaging.py @@ -0,0 +1,25 @@ +# Copyright 2019 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 fields, models +import odoo.addons.decimal_precision as dp + + +class ProductPackaging(models.Model): + _inherit = 'product.packaging' + + name = fields.Char(translate=True) + weight = fields.Float( + digits=dp.get_precision('Stock Weight'), + string='Empty Package Weight', help='Empty package weight in kg') + active = fields.Boolean(default=True) + # packaging_type is important, in particular for pallets for which + # we need a special implementation to enter the height + packaging_type = fields.Selection([ + ('unit', 'Unit'), + ('pack', 'Pack'), + ('box', 'Box'), + ('pallet', 'Pallet'), + ], string='Type') diff --git a/stock_packaging_usability_pp/models/stock_move.py b/stock_packaging_usability_pp/models/stock_move.py new file mode 100644 index 00000000000..fab70cacea9 --- /dev/null +++ b/stock_packaging_usability_pp/models/stock_move.py @@ -0,0 +1,22 @@ +# Copyright 2019 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, models + + +class StockMove(models.Model): + _inherit = 'stock.move' + + # Fixing bug https://github.com/odoo/odoo/issues/34702 + @api.depends('product_id', 'product_uom_qty', 'product_uom') + def _cal_move_weight(self): + weight_uom_categ = self.env.ref('uom.product_uom_categ_kgm') + kg_uom = self.env.ref('uom.product_uom_kgm') + for move in self: + if move.product_id.uom_id.category_id == weight_uom_categ: + move.weight = move.product_id.uom_id._compute_quantity( + move.product_qty, kg_uom) + else: + move.weight = move.product_qty * move.product_id.weight diff --git a/stock_packaging_usability_pp/models/stock_quant_package.py b/stock_packaging_usability_pp/models/stock_quant_package.py new file mode 100644 index 00000000000..7cc24e36d1f --- /dev/null +++ b/stock_packaging_usability_pp/models/stock_quant_package.py @@ -0,0 +1,42 @@ +# Copyright 2019 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, models + + +class StockQuantPackage(models.Model): + _inherit = 'stock.quant.package' + + # Fixing bug https://github.com/odoo/odoo/issues/34702 + # and take into account the weight of the packaging + @api.one + @api.depends('quant_ids') + def _compute_weight(self): + print('xxxxxxxxxxxxxxx') + weight = 0.0 + weight_uom_categ = self.env.ref('uom.product_uom_categ_kgm') + kg_uom = self.env.ref('uom.product_uom_kgm') + if self.env.context.get('picking_id'): + current_picking_move_line_ids = self.env['stock.move.line'].search( + [('result_package_id', '=', self.id), + ('picking_id', '=', self.env.context['picking_id'])]) + for ml in current_picking_move_line_ids: + if ml.product_uom_id.category_id == weight_uom_categ: + weight += ml.product_uom_id._compute_quantity( + ml.qty_done, kg_uom) + else: + weight += ml.product_uom_id._compute_quantity( + ml.qty_done, ml.product_id.uom_id) \ + * ml.product_id.weight + else: + for quant in self.quant_ids: + if quant.product_id.uom_id.category_id == weight_uom_categ: + weight += quant.product_id.uom_id._compute_quantity( + quant.quantity, kg_uom) + else: + weight += quant.quantity * quant.product_id.weight + if self.packaging_id: + weight += self.packaging_id.weight + self.weight = weight diff --git a/stock_packaging_usability_pp/views/product_packaging.xml b/stock_packaging_usability_pp/views/product_packaging.xml index fef55185f72..65114b8e467 100644 --- a/stock_packaging_usability_pp/views/product_packaging.xml +++ b/stock_packaging_usability_pp/views/product_packaging.xml @@ -16,32 +16,76 @@ product.packaging + + + + + + + + + + stock_packaging_usability_pp.product.packaging.tree + product.packaging + + + + + + + + product.packaging.search + product.packaging + + + + + + + + + + + +
From 60717472e31a511147968b8529ec4f3cacf6ed12 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 9 Jul 2019 16:38:35 +0200 Subject: [PATCH 13/18] Remove debug print --- stock_packaging_usability_pp/models/stock_quant_package.py | 1 - 1 file changed, 1 deletion(-) diff --git a/stock_packaging_usability_pp/models/stock_quant_package.py b/stock_packaging_usability_pp/models/stock_quant_package.py index 7cc24e36d1f..5e94306a513 100644 --- a/stock_packaging_usability_pp/models/stock_quant_package.py +++ b/stock_packaging_usability_pp/models/stock_quant_package.py @@ -14,7 +14,6 @@ class StockQuantPackage(models.Model): @api.one @api.depends('quant_ids') def _compute_weight(self): - print('xxxxxxxxxxxxxxx') weight = 0.0 weight_uom_categ = self.env.ref('uom.product_uom_categ_kgm') kg_uom = self.env.ref('uom.product_uom_kgm') From 4b279f7e2d17d6a307d4666656283fac0137df38 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 23 Dec 2021 18:12:12 +0100 Subject: [PATCH 14/18] [MIG] stock_packaging_usability and stock_packaging_usability_pp from v12 to v14 --- stock_packaging_usability/__manifest__.py | 10 +- stock_packaging_usability/i18n/fr.po | 74 ++++--- .../i18n/stock_packaging_usability.pot | 64 ------ .../models/stock_move_line.py | 27 +-- .../views/stock_move_line.xml | 24 ++- .../views/stock_picking.xml | 32 --- stock_packaging_usability_pp/__manifest__.py | 8 +- stock_packaging_usability_pp/i18n/fr.po | 194 ++++++++++++------ .../i18n/stock_packaging_usability_pp.pot | 157 ++++++++++++++ .../i18n/stock_packaging_usability_ul.pot | 93 --------- .../models/product_packaging.py | 5 +- .../models/stock_quant_package.py | 51 ++--- .../security/ir.model.access.csv | 2 + .../views/product_packaging.xml | 48 ++--- .../views/stock_move_line.xml | 16 +- .../views/stock_picking.xml | 17 +- .../views/stock_quant_package.xml | 2 +- .../wizard/stock_select_product_packaging.py | 14 +- 18 files changed, 443 insertions(+), 395 deletions(-) delete mode 100644 stock_packaging_usability/views/stock_picking.xml create mode 100644 stock_packaging_usability_pp/i18n/stock_packaging_usability_pp.pot delete mode 100644 stock_packaging_usability_pp/i18n/stock_packaging_usability_ul.pot create mode 100644 stock_packaging_usability_pp/security/ir.model.access.csv diff --git a/stock_packaging_usability/__manifest__.py b/stock_packaging_usability/__manifest__.py index 88f46aa8f45..9d79836a557 100644 --- a/stock_packaging_usability/__manifest__.py +++ b/stock_packaging_usability/__manifest__.py @@ -1,19 +1,19 @@ -# Copyright 2014-2019 Akretion France (http://www.akretion.com). +# Copyright 2014-2021 Akretion France (http://www.akretion.com). # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Stock Packaging Usability', - 'version': '12.0.1.0.0', - 'category': 'Warehouse', + 'version': '14.0.1.0.0', + 'category': 'Inventory/Inventory', 'license': 'AGPL-3', 'summary': "Faster packaging process in Odoo", 'author': 'Akretion,Odoo Community Association (OCA)', - 'website': 'http://www.akretion.com', + 'maintainers': ['alexis-via'], + 'website': 'https://github.com/OCA/stock-logistics-tracking', 'depends': ['stock'], 'data': [ - 'views/stock_picking.xml', 'views/stock_move_line.xml', ], 'installable': True, diff --git a/stock_packaging_usability/i18n/fr.po b/stock_packaging_usability/i18n/fr.po index 9ef2167ac35..6fe0de969b8 100644 --- a/stock_packaging_usability/i18n/fr.po +++ b/stock_packaging_usability/i18n/fr.po @@ -1,14 +1,14 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * stock_packaging_usability +# * stock_packaging_usability # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-11-21 08:57+0000\n" -"PO-Revision-Date: 2014-11-21 08:57+0000\n" -"Last-Translator: <>\n" +"POT-Creation-Date: 2021-12-23 16:50+0000\n" +"PO-Revision-Date: 2021-12-23 16:50+0000\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -16,49 +16,63 @@ msgstr "" "Plural-Forms: \n" #. module: stock_packaging_usability -#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details -msgid "Picking wizard" +#: code:addons/stock_packaging_usability/models/stock_move_line.py:0 +#, python-format +msgid "Could not find any package level linked to package '%s'." msgstr "" #. module: stock_packaging_usability -#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details_items -msgid "Picking wizard items" +#: model:ir.model.fields,field_description:stock_packaging_usability.field_stock_move_line__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: stock_packaging_usability +#: model:ir.model.fields,field_description:stock_packaging_usability.field_stock_move_line__id +msgid "ID" msgstr "" #. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Products To Move" -msgstr "Produits à déplacer" +#: model:ir.model.fields,field_description:stock_packaging_usability.field_stock_move_line____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" #. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Put Residual in New Pack" -msgstr "Mettre le reste dans un nouveau paquet" +#: model:ir.model,name:stock_packaging_usability.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "Mouvements d'article (Ligne de mouvement de stock)" #. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Put in current pack" -msgstr "Mettre dans le paquet actuel" +#: model_terms:ir.ui.view,arch_db:stock_packaging_usability.view_stock_move_line_detailed_operation_tree +#: model_terms:ir.ui.view,arch_db:stock_packaging_usability.view_stock_move_line_operation_tree +msgid "Put in Current Pack" +msgstr "" #. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Put in new pack" -msgstr "Mettre dans un nouveau paquet" +#: model_terms:ir.ui.view,arch_db:stock_packaging_usability.view_stock_move_line_detailed_operation_tree +#: model_terms:ir.ui.view,arch_db:stock_packaging_usability.view_stock_move_line_operation_tree +msgid "Put in New Pack" +msgstr "" #. module: stock_packaging_usability -#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:58 +#: code:addons/stock_packaging_usability/models/stock_move_line.py:0 #, python-format -msgid "There is no current package" -msgstr "Il n'y a pas de paquet actuel" +msgid "Qty done is 0" +msgstr "" #. module: stock_packaging_usability -#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:52 +#: code:addons/stock_packaging_usability/models/stock_move_line.py:0 #, python-format -msgid "This product is already in a package !" -msgstr "Ce produit est déjà dans un paquet !" +msgid "There are several package levels linked to package '%s'." +msgstr "" #. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "terp-accessories-archiver+" -msgstr "terp-accessories-archiver+" +#: code:addons/stock_packaging_usability/models/stock_move_line.py:0 +#, python-format +msgid "There is no current package." +msgstr "" +#. module: stock_packaging_usability +#: code:addons/stock_packaging_usability/models/stock_move_line.py:0 +#, python-format +msgid "This operation is already packaged." +msgstr "" diff --git a/stock_packaging_usability/i18n/stock_packaging_usability.pot b/stock_packaging_usability/i18n/stock_packaging_usability.pot index b38719f355c..e69de29bb2d 100644 --- a/stock_packaging_usability/i18n/stock_packaging_usability.pot +++ b/stock_packaging_usability/i18n/stock_packaging_usability.pot @@ -1,64 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * stock_packaging_usability -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-11-21 08:57+0000\n" -"PO-Revision-Date: 2014-11-21 08:57+0000\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: stock_packaging_usability -#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details -msgid "Picking wizard" -msgstr "" - -#. module: stock_packaging_usability -#: model:ir.model,name:stock_packaging_usability.model_stock_transfer_details_items -msgid "Picking wizard items" -msgstr "" - -#. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Products To Move" -msgstr "" - -#. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Put Residual in New Pack" -msgstr "" - -#. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Put in current pack" -msgstr "" - -#. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "Put in new pack" -msgstr "" - -#. module: stock_packaging_usability -#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:58 -#, python-format -msgid "There is no current package" -msgstr "" - -#. module: stock_packaging_usability -#: code:addons/stock_packaging_usability/wizard/stock_transfer_details.py:52 -#, python-format -msgid "This product is already in a package !" -msgstr "" - -#. module: stock_packaging_usability -#: view:stock.transfer_details:stock_packaging_usability.view_stock_enter_transfer_details -msgid "terp-accessories-archiver+" -msgstr "" - diff --git a/stock_packaging_usability/models/stock_move_line.py b/stock_packaging_usability/models/stock_move_line.py index fab7451007e..8eaefa9f4fc 100644 --- a/stock_packaging_usability/models/stock_move_line.py +++ b/stock_packaging_usability/models/stock_move_line.py @@ -1,4 +1,4 @@ -# Copyright 2014-2019 Akretion France (http://www.akretion.com) +# Copyright 2014-2021 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -14,18 +14,16 @@ class StockMoveLine(models.Model): def put_in_new_pack(self): self.ensure_one() pack = self.env['stock.quant.package'].create({}) + picking = self.picking_id pack_level = self.env['stock.package_level'].create({ 'package_id': pack.id, - 'picking_id': self.picking_id.id, + 'picking_id': picking.id, 'location_id': False, 'location_dest_id': self.location_dest_id.id, 'move_line_ids': [(6, 0, [self.id])], + 'company_id': picking.company_id.id, }) self._put_in_target_pack(pack, pack_level) - action = {} - if self._context.get('stock_packaging_usability_return_action'): - action = self.move_id.action_show_details() - return action def put_in_last_pack(self): all_cur_packs_ids = [ @@ -45,10 +43,6 @@ def put_in_last_pack(self): "There are several package levels linked to package '%s'.") % pack.display_name) self._put_in_target_pack(pack, pack_levels) - action = {} - if self._context.get('stock_packaging_usability_return_action'): - action = self.move_id.action_show_details() - return action def _put_in_target_pack(self, pack, pack_level): self.ensure_one() @@ -62,19 +56,12 @@ def _put_in_target_pack(self, pack, pack_level): moveline_to_pack = self if float_compare( self.qty_done, self.product_uom_qty, precision_digits=prec) < 0: - # QUESTION it is still unclear to me why we have to put - # product_uom_qty = 0 instead of product_uom_qty = self.qty_done - # in copy(). It gives good results in Detailed operations, but slightly - # wired behavior in "Operations". But, if we set - # product_uom_qty = self.qty_done, we get the error msg - # "It is not possible to unreserve more products of xx - # than you have in stock" new_moveline = self.copy( - {'product_uom_qty': 0, 'qty_done': self.qty_done}) + {'product_uom_qty': self.qty_done, 'qty_done': self.qty_done}) self.write({ 'product_uom_qty': self.product_uom_qty - self.qty_done, 'qty_done': 0, }) moveline_to_pack = new_moveline - pack_level.move_line_ids = [(4, moveline_to_pack.id)] - moveline_to_pack.result_package_id = pack.id + pack_level.write({'move_line_ids': [(4, moveline_to_pack.id)]}) + moveline_to_pack.write({'result_package_id': pack.id}) diff --git a/stock_packaging_usability/views/stock_move_line.xml b/stock_packaging_usability/views/stock_move_line.xml index 1b4668929bf..b63eb202951 100644 --- a/stock_packaging_usability/views/stock_move_line.xml +++ b/stock_packaging_usability/views/stock_move_line.xml @@ -1,6 +1,6 @@ @@ -18,13 +18,31 @@ string="Put in Current Pack" icon="fa-stack-overflow" groups="stock.group_tracking_lot" - context="{'stock_packaging_usability_return_action': True}" attrs="{'invisible': ['|', ('result_package_id', '!=', False), ('qty_done', '=', 0)]}"/> - + @@ -65,8 +39,10 @@ - - + + + + diff --git a/stock_packaging_usability_pp/views/stock_move_line.xml b/stock_packaging_usability_pp/views/stock_move_line.xml index 752f8f4b21d..754a118fdc2 100644 --- a/stock_packaging_usability_pp/views/stock_move_line.xml +++ b/stock_packaging_usability_pp/views/stock_move_line.xml @@ -1,6 +1,6 @@ @@ -16,7 +16,19 @@ + + + + + stock.move.line + + + diff --git a/stock_packaging_usability_pp/views/stock_picking.xml b/stock_packaging_usability_pp/views/stock_picking.xml index 5d65252694a..04cf5d79d7e 100644 --- a/stock_packaging_usability_pp/views/stock_picking.xml +++ b/stock_packaging_usability_pp/views/stock_picking.xml @@ -11,18 +11,23 @@ stock_packaging_usability_pp.stock.picking.form stock.picking - + - - + diff --git a/stock_packaging_usability_pp/views/stock_quant_package.xml b/stock_packaging_usability_pp/views/stock_quant_package.xml index 0ec4872b453..9b8fce94857 100644 --- a/stock_packaging_usability_pp/views/stock_quant_package.xml +++ b/stock_packaging_usability_pp/views/stock_quant_package.xml @@ -1,6 +1,6 @@ diff --git a/stock_packaging_usability_pp/wizard/stock_select_product_packaging.py b/stock_packaging_usability_pp/wizard/stock_select_product_packaging.py index 9e8a2be83bc..3260095a15f 100644 --- a/stock_packaging_usability_pp/wizard/stock_select_product_packaging.py +++ b/stock_packaging_usability_pp/wizard/stock_select_product_packaging.py @@ -1,4 +1,4 @@ -# Copyright 2014-2019 Akretion France (http://www.akretion.com) +# Copyright 2014-2021 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -8,29 +8,29 @@ class StockSelectProductPackaging(models.TransientModel): _name = 'stock.select.product.packaging' - _description = 'Select Product Packaging' + _description = 'Select Packaging' packaging_id = fields.Many2one('product.packaging', string='Packaging') # required=False, because we accept that it can be left empty def validate(self): self.ensure_one() - packaging = self.packaging_id + default_packaging_id = self.packaging_id.id or False assert self.env.context.get('pack_function') is not None, \ 'missing context key pack_function' - self = self.with_context( - default_packaging_id=(packaging and packaging.id or False)) action = {} if self._context.get('pack_function') == 'put_selection_in_new_pack': assert self.env.context.get('active_model') == \ 'stock.picking', 'Wrong underlying model' pick = self.env['stock.picking'].browse( self.env.context['active_id']) - pick.put_in_pack() + pick.with_context( + default_packaging_id=default_packaging_id).action_put_in_pack() elif self._context.get('pack_function') == 'put_in_new_pack': assert self.env.context.get('active_model') == \ 'stock.move.line', 'Wrong underlying model' ml = self.env['stock.move.line'].browse( self.env.context['active_id']) - action = ml.put_in_new_pack() + action = ml.with_context( + default_packaging_id=default_packaging_id).put_in_new_pack() return action From 6ec7e1f64dfd9acd3625d43c9168b2887a9e45d4 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 23 Dec 2021 18:14:09 +0100 Subject: [PATCH 15/18] stock_packaging_usability*: black, isort and other auto-reformatting --- .../odoo/addons/stock_packaging_usability | 1 + setup/stock_packaging_usability/setup.py | 6 ++ .../odoo/addons/stock_packaging_usability_pp | 1 + setup/stock_packaging_usability_pp/setup.py | 6 ++ stock_packaging_usability/__manifest__.py | 26 +++--- .../models/stock_move_line.py | 80 +++++++++++-------- .../views/stock_move_line.xml | 55 ++++++++----- stock_packaging_usability_pp/README.rst | 1 + stock_packaging_usability_pp/__manifest__.py | 42 +++++----- .../models/product_packaging.py | 23 +++--- .../models/stock_move.py | 11 +-- .../models/stock_quant_package.py | 32 +++++--- .../views/product_packaging.xml | 40 ++++++---- .../views/stock_move_line.xml | 13 ++- .../views/stock_picking.xml | 30 +++++-- .../views/stock_quant_package.xml | 7 +- .../wizard/stock_select_product_packaging.py | 37 +++++---- .../stock_select_product_packaging_view.xml | 21 +++-- 18 files changed, 262 insertions(+), 170 deletions(-) create mode 120000 setup/stock_packaging_usability/odoo/addons/stock_packaging_usability create mode 100644 setup/stock_packaging_usability/setup.py create mode 120000 setup/stock_packaging_usability_pp/odoo/addons/stock_packaging_usability_pp create mode 100644 setup/stock_packaging_usability_pp/setup.py create mode 100644 stock_packaging_usability_pp/README.rst diff --git a/setup/stock_packaging_usability/odoo/addons/stock_packaging_usability b/setup/stock_packaging_usability/odoo/addons/stock_packaging_usability new file mode 120000 index 00000000000..63777295a1f --- /dev/null +++ b/setup/stock_packaging_usability/odoo/addons/stock_packaging_usability @@ -0,0 +1 @@ +../../../../stock_packaging_usability \ No newline at end of file diff --git a/setup/stock_packaging_usability/setup.py b/setup/stock_packaging_usability/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/stock_packaging_usability/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/stock_packaging_usability_pp/odoo/addons/stock_packaging_usability_pp b/setup/stock_packaging_usability_pp/odoo/addons/stock_packaging_usability_pp new file mode 120000 index 00000000000..9a457ebfc03 --- /dev/null +++ b/setup/stock_packaging_usability_pp/odoo/addons/stock_packaging_usability_pp @@ -0,0 +1 @@ +../../../../stock_packaging_usability_pp \ No newline at end of file diff --git a/setup/stock_packaging_usability_pp/setup.py b/setup/stock_packaging_usability_pp/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/stock_packaging_usability_pp/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_packaging_usability/__manifest__.py b/stock_packaging_usability/__manifest__.py index 9d79836a557..eb6d5eedcfd 100644 --- a/stock_packaging_usability/__manifest__.py +++ b/stock_packaging_usability/__manifest__.py @@ -4,17 +4,17 @@ { - 'name': 'Stock Packaging Usability', - 'version': '14.0.1.0.0', - 'category': 'Inventory/Inventory', - 'license': 'AGPL-3', - 'summary': "Faster packaging process in Odoo", - 'author': 'Akretion,Odoo Community Association (OCA)', - 'maintainers': ['alexis-via'], - 'website': 'https://github.com/OCA/stock-logistics-tracking', - 'depends': ['stock'], - 'data': [ - 'views/stock_move_line.xml', - ], - 'installable': True, + "name": "Stock Packaging Usability", + "version": "14.0.1.0.0", + "category": "Inventory/Inventory", + "license": "AGPL-3", + "summary": "Faster packaging process in Odoo", + "author": "Akretion,Odoo Community Association (OCA)", + "maintainers": ["alexis-via"], + "website": "https://github.com/OCA/stock-logistics-tracking", + "depends": ["stock"], + "data": [ + "views/stock_move_line.xml", + ], + "installable": True, } diff --git a/stock_packaging_usability/models/stock_move_line.py b/stock_packaging_usability/models/stock_move_line.py index 8eaefa9f4fc..bba54b21add 100644 --- a/stock_packaging_usability/models/stock_move_line.py +++ b/stock_packaging_usability/models/stock_move_line.py @@ -3,65 +3,77 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, _ +from odoo import _, models from odoo.exceptions import UserError from odoo.tools import float_compare, float_is_zero class StockMoveLine(models.Model): - _inherit = 'stock.move.line' + _inherit = "stock.move.line" def put_in_new_pack(self): self.ensure_one() - pack = self.env['stock.quant.package'].create({}) + pack = self.env["stock.quant.package"].create({}) picking = self.picking_id - pack_level = self.env['stock.package_level'].create({ - 'package_id': pack.id, - 'picking_id': picking.id, - 'location_id': False, - 'location_dest_id': self.location_dest_id.id, - 'move_line_ids': [(6, 0, [self.id])], - 'company_id': picking.company_id.id, - }) + pack_level = self.env["stock.package_level"].create( + { + "package_id": pack.id, + "picking_id": picking.id, + "location_id": False, + "location_dest_id": self.location_dest_id.id, + "move_line_ids": [(6, 0, [self.id])], + "company_id": picking.company_id.id, + } + ) self._put_in_target_pack(pack, pack_level) def put_in_last_pack(self): all_cur_packs_ids = [ - moveline2.result_package_id.id for moveline2 - in self.picking_id.move_line_ids if moveline2.result_package_id] + moveline2.result_package_id.id + for moveline2 in self.picking_id.move_line_ids + if moveline2.result_package_id + ] if not all_cur_packs_ids: - raise UserError(_('There is no current package.')) + raise UserError(_("There is no current package.")) pack_id = max(all_cur_packs_ids) - pack = self.env['stock.quant.package'].browse(pack_id) - pack_levels = self.env['stock.package_level'].search([('package_id', '=', pack_id)]) + pack = self.env["stock.quant.package"].browse(pack_id) + pack_levels = self.env["stock.package_level"].search( + [("package_id", "=", pack_id)] + ) if not pack_levels: - raise UserError(_( - "Could not find any package level linked to package '%s'.") - % pack.display_name) + raise UserError( + _("Could not find any package level linked to package '%s'.") + % pack.display_name + ) if len(pack_levels) > 1: - raise UserError(_( - "There are several package levels linked to package '%s'.") - % pack.display_name) + raise UserError( + _("There are several package levels linked to package '%s'.") + % pack.display_name + ) self._put_in_target_pack(pack, pack_levels) def _put_in_target_pack(self, pack, pack_level): self.ensure_one() - assert pack, 'pack is a required argument' - prec = self.env['decimal.precision'].precision_get( - 'Product Unit of Measure') + assert pack, "pack is a required argument" + prec = self.env["decimal.precision"].precision_get("Product Unit of Measure") if float_is_zero(self.qty_done, precision_digits=prec): raise UserError(_("Qty done is 0")) if self.result_package_id: raise UserError(_("This operation is already packaged.")) moveline_to_pack = self - if float_compare( - self.qty_done, self.product_uom_qty, precision_digits=prec) < 0: + if ( + float_compare(self.qty_done, self.product_uom_qty, precision_digits=prec) + < 0 + ): new_moveline = self.copy( - {'product_uom_qty': self.qty_done, 'qty_done': self.qty_done}) - self.write({ - 'product_uom_qty': self.product_uom_qty - self.qty_done, - 'qty_done': 0, - }) + {"product_uom_qty": self.qty_done, "qty_done": self.qty_done} + ) + self.write( + { + "product_uom_qty": self.product_uom_qty - self.qty_done, + "qty_done": 0, + } + ) moveline_to_pack = new_moveline - pack_level.write({'move_line_ids': [(4, moveline_to_pack.id)]}) - moveline_to_pack.write({'result_package_id': pack.id}) + pack_level.write({"move_line_ids": [(4, moveline_to_pack.id)]}) + moveline_to_pack.write({"result_package_id": pack.id}) diff --git a/stock_packaging_usability/views/stock_move_line.xml b/stock_packaging_usability/views/stock_move_line.xml index b63eb202951..5d598c11f4b 100644 --- a/stock_packaging_usability/views/stock_move_line.xml +++ b/stock_packaging_usability/views/stock_move_line.xml @@ -1,10 +1,9 @@ - + - @@ -14,16 +13,22 @@ -