From c9a2dfaafc0b774a5ff92e7e167f360aa8c6f396 Mon Sep 17 00:00:00 2001 From: sergio-teruel Date: Fri, 13 Dec 2024 09:56:44 +0100 Subject: [PATCH] [IMP] delivery_package_number: Allow force set package number at partner level and picking operation TT51855 --- delivery_package_number/__manifest__.py | 1 + .../i18n/delivery_package_number.pot | 21 +++++++++++- delivery_package_number/i18n/es.po | 33 ++++++++++++++----- delivery_package_number/models/__init__.py | 1 + delivery_package_number/models/res_partner.py | 9 +++++ .../models/stock_picking.py | 6 +++- .../models/stock_picking_type.py | 7 +++- .../views/res_partner_view.xml | 12 +++++++ .../stock_number_package_validate_wiz.py | 7 ++-- ...stock_number_package_validate_wiz_view.xml | 1 + 10 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 delivery_package_number/models/res_partner.py create mode 100644 delivery_package_number/views/res_partner_view.xml diff --git a/delivery_package_number/__manifest__.py b/delivery_package_number/__manifest__.py index b95dbd5e87..a9c21b85a5 100644 --- a/delivery_package_number/__manifest__.py +++ b/delivery_package_number/__manifest__.py @@ -15,6 +15,7 @@ "security/ir.model.access.csv", "data/paperformat_data.xml", "reports/report_package_number.xml", + "views/res_partner_view.xml", "views/stock_picking_type_views.xml", "views/stock_picking_views.xml", "wizard/stock_number_package_validate_wiz_view.xml", diff --git a/delivery_package_number/i18n/delivery_package_number.pot b/delivery_package_number/i18n/delivery_package_number.pot index b14661501d..d85278d55a 100644 --- a/delivery_package_number/i18n/delivery_package_number.pot +++ b/delivery_package_number/i18n/delivery_package_number.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-20 08:52+0000\n" +"PO-Revision-Date: 2024-12-20 08:52+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -13,6 +15,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: delivery_package_number +#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__always +msgid "Always" +msgstr "" + #. module: delivery_package_number #: model_terms:ir.ui.view,arch_db:delivery_package_number.view_number_package_validate msgid "Apply" @@ -33,6 +40,11 @@ msgstr "" msgid "Cancel" msgstr "" +#. module: delivery_package_number +#: model:ir.model,name:delivery_package_number.model_res_partner +msgid "Contact" +msgstr "" + #. module: delivery_package_number #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__create_uid #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__create_uid @@ -57,6 +69,8 @@ msgid "Display Name" msgstr "" #. module: delivery_package_number +#: model:ir.model.fields,field_description:delivery_package_number.field_res_partner__force_set_number_of_packages +#: model:ir.model.fields,field_description:delivery_package_number.field_res_users__force_set_number_of_packages #: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking_type__force_set_number_of_packages msgid "Force Set Number Of Packages" msgstr "" @@ -91,12 +105,12 @@ msgid "Last Updated on" msgstr "" #. module: delivery_package_number +#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__number_of_packages msgid "Number Of Packages" msgstr "" #. module: delivery_package_number -#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages #: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking__number_of_packages msgid "Number of Packages" msgstr "" @@ -111,6 +125,11 @@ msgstr "" msgid "Number of packages:" msgstr "" +#. module: delivery_package_number +#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__partner +msgid "Partner condition" +msgstr "" + #. module: delivery_package_number #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__pick_ids msgid "Pick" diff --git a/delivery_package_number/i18n/es.po b/delivery_package_number/i18n/es.po index eb66a59b4e..5caab0a008 100644 --- a/delivery_package_number/i18n/es.po +++ b/delivery_package_number/i18n/es.po @@ -6,16 +6,21 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-08-16 08:40+0000\n" -"PO-Revision-Date: 2024-02-25 19:36+0000\n" -"Last-Translator: Ivorra78 \n" +"POT-Creation-Date: 2024-12-20 08:52+0000\n" +"PO-Revision-Date: 2024-12-20 09:53+0100\n" +"Last-Translator: Sergio Teruel \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.17\n" +"X-Generator: Poedit 3.0.1\n" + +#. module: delivery_package_number +#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__always +msgid "Always" +msgstr "Siempre" #. module: delivery_package_number #: model_terms:ir.ui.view,arch_db:delivery_package_number.view_number_package_validate @@ -37,6 +42,11 @@ msgstr "Confirmación de pedido pendiente" msgid "Cancel" msgstr "Cancelar" +#. module: delivery_package_number +#: model:ir.model,name:delivery_package_number.model_res_partner +msgid "Contact" +msgstr "Contacto" + #. module: delivery_package_number #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__create_uid #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__create_uid @@ -61,6 +71,8 @@ msgid "Display Name" msgstr "Mostrar Nombre" #. module: delivery_package_number +#: model:ir.model.fields,field_description:delivery_package_number.field_res_partner__force_set_number_of_packages +#: model:ir.model.fields,field_description:delivery_package_number.field_res_users__force_set_number_of_packages #: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking_type__force_set_number_of_packages msgid "Force Set Number Of Packages" msgstr "Forzar Establecer Número De Paquetes" @@ -95,12 +107,12 @@ msgid "Last Updated on" msgstr "Última Actualización el" #. module: delivery_package_number +#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__number_of_packages msgid "Number Of Packages" msgstr "Número de Bultos" #. module: delivery_package_number -#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages #: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking__number_of_packages msgid "Number of Packages" msgstr "Número de Bultos" @@ -115,20 +127,25 @@ msgstr "Número de paquetes" msgid "Number of packages:" msgstr "Número de paquetes:" +#. module: delivery_package_number +#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__partner +msgid "Partner condition" +msgstr "Condición en el contacto" + #. module: delivery_package_number #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__pick_ids msgid "Pick" -msgstr "Escoja" +msgstr "Recogida" #. module: delivery_package_number #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__picking_id msgid "Picking" -msgstr "Recogiendo" +msgstr "Albarán" #. module: delivery_package_number #: model:ir.model,name:delivery_package_number.model_stock_picking_type msgid "Picking Type" -msgstr "Tipo de Recogida" +msgstr "Tipo de operación" #. module: delivery_package_number #: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__print_package_label diff --git a/delivery_package_number/models/__init__.py b/delivery_package_number/models/__init__.py index f6db7b252c..5f775ae0d6 100644 --- a/delivery_package_number/models/__init__.py +++ b/delivery_package_number/models/__init__.py @@ -1,2 +1,3 @@ +from . import res_partner from . import stock_picking_type from . import stock_picking diff --git a/delivery_package_number/models/res_partner.py b/delivery_package_number/models/res_partner.py new file mode 100644 index 0000000000..7549f3fdcb --- /dev/null +++ b/delivery_package_number/models/res_partner.py @@ -0,0 +1,9 @@ +# Copyright 2024 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + force_set_number_of_packages = fields.Boolean() diff --git a/delivery_package_number/models/stock_picking.py b/delivery_package_number/models/stock_picking.py index 423274d8b3..dc7fadc518 100644 --- a/delivery_package_number/models/stock_picking.py +++ b/delivery_package_number/models/stock_picking.py @@ -45,7 +45,11 @@ def _compute_ask_number_of_packages(self): picking.ask_number_of_packages = bool( picking.carrier_id and not picking.package_ids - or picking.picking_type_id.force_set_number_of_packages + or picking.picking_type_id.force_set_number_of_packages == "always" + or ( + picking.picking_type_id.force_set_number_of_packages == "partner" + and picking.partner_id.force_set_number_of_packages + ) ) def _get_pickings_to_set_number_of_packages(self): diff --git a/delivery_package_number/models/stock_picking_type.py b/delivery_package_number/models/stock_picking_type.py index 615cf68d46..756b5c2e2b 100644 --- a/delivery_package_number/models/stock_picking_type.py +++ b/delivery_package_number/models/stock_picking_type.py @@ -6,7 +6,12 @@ class StockPickingType(models.Model): _inherit = "stock.picking.type" - force_set_number_of_packages = fields.Boolean() + force_set_number_of_packages = fields.Selection( + [ + ("always", "Always"), + ("partner", "Partner condition"), + ] + ) report_number_of_packages = fields.Many2one( "ir.actions.report", default=lambda self: self.env.ref( diff --git a/delivery_package_number/views/res_partner_view.xml b/delivery_package_number/views/res_partner_view.xml new file mode 100644 index 0000000000..a6e2eda4fe --- /dev/null +++ b/delivery_package_number/views/res_partner_view.xml @@ -0,0 +1,12 @@ + + + + res.partner + + + + + + + + diff --git a/delivery_package_number/wizard/stock_number_package_validate_wiz.py b/delivery_package_number/wizard/stock_number_package_validate_wiz.py index 64f1f24d45..42a27d64a9 100644 --- a/delivery_package_number/wizard/stock_number_package_validate_wiz.py +++ b/delivery_package_number/wizard/stock_number_package_validate_wiz.py @@ -42,9 +42,10 @@ def process(self): if self.number_of_packages: self.pick_ids.write({"number_of_packages": self.number_of_packages}) # put context key for avoiding `base_delivery_carrier_label` auto-packaging feature - self.pick_ids.with_context( - set_default_package=False, bypass_set_number_of_packages=True - ).button_validate() + if not self.env.context.get("skip_picking_validate", False): + self.pick_ids.with_context( + set_default_package=False, bypass_set_number_of_packages=True + ).button_validate() if self.print_package_label: return self._print_package_label() diff --git a/delivery_package_number/wizard/stock_number_package_validate_wiz_view.xml b/delivery_package_number/wizard/stock_number_package_validate_wiz_view.xml index 2ac077efc9..b04cbfa7c5 100644 --- a/delivery_package_number/wizard/stock_number_package_validate_wiz_view.xml +++ b/delivery_package_number/wizard/stock_number_package_validate_wiz_view.xml @@ -17,6 +17,7 @@ name="stock_number_package_validation_line_ids" attrs="{'invisible': [('stock_number_package_validation_line_ids', '=', [])]}" nolabel="1" + force_save="1" >