From 48d5a3b3276d19d13c6b0f0a6e8a9b7fbd813aed Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 23 Jun 2025 09:29:39 +0000 Subject: [PATCH] [IMP] stock_quant_package_move_wizard: more accurate source location on picking when all quants have the same location --- stock_quant_package_move_wizard/i18n/fr.po | 16 +++++++++++----- .../i18n/stock_quant_package_move_wizard.pot | 9 +++++++-- .../models/stock_quant.py | 5 +++++ .../wizards/stock_quant_move_wizard.py | 19 +++---------------- .../wizards/stock_quant_move_wizard_view.xml | 3 ++- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/stock_quant_package_move_wizard/i18n/fr.po b/stock_quant_package_move_wizard/i18n/fr.po index 2d23d3d..27b8e01 100644 --- a/stock_quant_package_move_wizard/i18n/fr.po +++ b/stock_quant_package_move_wizard/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-02-13 21:59+0000\n" -"PO-Revision-Date: 2023-02-13 21:59+0000\n" +"POT-Creation-Date: 2025-06-23 09:19+0000\n" +"PO-Revision-Date: 2025-06-23 09:19+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -109,6 +109,11 @@ msgstr "Lot/numéro de série" msgid "Move" msgstr "Déplacer" +#. module: stock_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Move and Show Picking" +msgstr "Déplacer et afficher le bon de transfert" + #. module: stock_quant_package_move_wizard #: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action msgid "Move to Another Location" @@ -137,7 +142,7 @@ msgstr "Qté à déplacer" #. module: stock_quant_package_move_wizard #: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_id msgid "Quant" -msgstr "Quant" +msgstr "" #. module: stock_quant_package_move_wizard #: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__wizard_id @@ -154,7 +159,7 @@ msgstr "" #. module: stock_quant_package_move_wizard #: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant msgid "Quants" -msgstr "Quants" +msgstr "" #. module: stock_quant_package_move_wizard #: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__origin @@ -196,7 +201,8 @@ msgid "" "%(product_name)s to %(dest_location)s, but it is already on that location!" msgstr "" "Vous essayez de déplacer %(qty)s %(uom)s d'un quant de l'article " -"%(product_name)s vers %(dest_location)s, mais il est déjà sur cet emplacement !" +"%(product_name)s vers %(dest_location)s, mais il est déjà sur cet " +"emplacement !" #. module: stock_quant_package_move_wizard #. odoo-python diff --git a/stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot b/stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot index 1ae8ef3..6aa20c1 100644 --- a/stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot +++ b/stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-02-13 21:58+0000\n" -"PO-Revision-Date: 2023-02-13 21:58+0000\n" +"POT-Creation-Date: 2025-06-23 09:19+0000\n" +"PO-Revision-Date: 2025-06-23 09:19+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -109,6 +109,11 @@ msgstr "" msgid "Move" msgstr "" +#. module: stock_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Move and Show Picking" +msgstr "" + #. module: stock_quant_package_move_wizard #: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action msgid "Move to Another Location" diff --git a/stock_quant_package_move_wizard/models/stock_quant.py b/stock_quant_package_move_wizard/models/stock_quant.py index 93c0391..8c7ee54 100644 --- a/stock_quant_package_move_wizard/models/stock_quant.py +++ b/stock_quant_package_move_wizard/models/stock_quant.py @@ -100,6 +100,11 @@ class StockQuant(models.Model): "location_dest_id": dest_location.id, "origin": origin, } + source_loc_ids = set() + for quant in self: + source_loc_ids.add(quant.location_id.id) + if len(source_loc_ids) == 1: + vals['location_id'] = list(source_loc_ids)[0] return vals def move_full_quant_to(self, dest_location, picking_type=False, origin=False): diff --git a/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py index 1064c82..7409108 100644 --- a/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py +++ b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py @@ -60,22 +60,9 @@ class StockQuantMoveWizard(models.TransientModel): def run(self): self.ensure_one() - picking_id = False - if self.picking_type_id: - picking_vals = self.env["stock.quant"]._prepare_move_to_stock_picking( - self.location_dest_id, self.picking_type_id, origin=self.origin - ) - picking_id = self.env["stock.picking"].create(picking_vals).id - smo = self.env["stock.move"] - for line in self.line_ids: - quant = line.quant_id - assert not quant.package_id - vals = quant._prepare_move_to_stock_move( - line.quantity, self.location_dest_id, picking_id, origin=self.origin - ) - new_move = smo.create(vals) - new_move._action_done() - assert new_move.state == "done" + res = self.line_ids.quant_id.move_full_quant_to( + self.location_dest_id, self.picking_type_id, origin=self.origin) + picking_id = res['picking_id'] action = {} if picking_id and self._context.get("run_show_picking"): action = self.env["ir.actions.actions"]._for_xml_id( diff --git a/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml index 0a9eedb..ea59763 100644 --- a/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml +++ b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml @@ -35,7 +35,8 @@