[IMP] stock_quant_package_move_wizard: more accurate source location on picking when all quants have the same location

This commit is contained in:
Alexis de Lattre
2025-06-23 09:29:39 +00:00
parent 836a88dfeb
commit 48d5a3b327
5 changed files with 28 additions and 24 deletions

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 16.0\n" "Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-13 21:59+0000\n" "POT-Creation-Date: 2025-06-23 09:19+0000\n"
"PO-Revision-Date: 2023-02-13 21:59+0000\n" "PO-Revision-Date: 2025-06-23 09:19+0000\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -109,6 +109,11 @@ msgstr "Lot/numéro de série"
msgid "Move" msgid "Move"
msgstr "Déplacer" 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 #. module: stock_quant_package_move_wizard
#: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action #: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action
msgid "Move to Another Location" msgid "Move to Another Location"
@@ -137,7 +142,7 @@ msgstr "Qté à déplacer"
#. module: stock_quant_package_move_wizard #. 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 #: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_id
msgid "Quant" msgid "Quant"
msgstr "Quant" msgstr ""
#. module: stock_quant_package_move_wizard #. 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 #: 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 #. module: stock_quant_package_move_wizard
#: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant #: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant
msgid "Quants" msgid "Quants"
msgstr "Quants" msgstr ""
#. module: stock_quant_package_move_wizard #. module: stock_quant_package_move_wizard
#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__origin #: 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!" "%(product_name)s to %(dest_location)s, but it is already on that location!"
msgstr "" msgstr ""
"Vous essayez de déplacer %(qty)s %(uom)s d'un quant de l'article " "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 #. module: stock_quant_package_move_wizard
#. odoo-python #. odoo-python

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 16.0\n" "Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-13 21:58+0000\n" "POT-Creation-Date: 2025-06-23 09:19+0000\n"
"PO-Revision-Date: 2023-02-13 21:58+0000\n" "PO-Revision-Date: 2025-06-23 09:19+0000\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -109,6 +109,11 @@ msgstr ""
msgid "Move" msgid "Move"
msgstr "" 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 #. module: stock_quant_package_move_wizard
#: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action #: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action
msgid "Move to Another Location" msgid "Move to Another Location"

View File

@@ -100,6 +100,11 @@ class StockQuant(models.Model):
"location_dest_id": dest_location.id, "location_dest_id": dest_location.id,
"origin": origin, "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 return vals
def move_full_quant_to(self, dest_location, picking_type=False, origin=False): def move_full_quant_to(self, dest_location, picking_type=False, origin=False):

View File

@@ -60,22 +60,9 @@ class StockQuantMoveWizard(models.TransientModel):
def run(self): def run(self):
self.ensure_one() self.ensure_one()
picking_id = False res = self.line_ids.quant_id.move_full_quant_to(
if self.picking_type_id: self.location_dest_id, self.picking_type_id, origin=self.origin)
picking_vals = self.env["stock.quant"]._prepare_move_to_stock_picking( picking_id = res['picking_id']
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"
action = {} action = {}
if picking_id and self._context.get("run_show_picking"): if picking_id and self._context.get("run_show_picking"):
action = self.env["ir.actions.actions"]._for_xml_id( action = self.env["ir.actions.actions"]._for_xml_id(

View File

@@ -35,7 +35,8 @@
</field> </field>
</group> </group>
<footer> <footer>
<button name="run" string="Move" type="object" class="btn-primary" /> <button name="run" string="Move and Show Picking" type="object" class="btn-primary" context="{'run_show_picking': True}" />
<button name="run" string="Move" type="object" />
<button string="Cancel" special="cancel" /> <button string="Cancel" special="cancel" />
</footer> </footer>
</form> </form>