[MIG] stock_move_location: Migration to 13.0

This commit is contained in:
Joan Sisquella
2020-01-14 13:47:57 +01:00
committed by João Marques
parent 50d51c6f83
commit 785279db5f
15 changed files with 92 additions and 80 deletions

View File

@@ -14,13 +14,13 @@ Move Stock Location
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_move_location :target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_move_location
:alt: OCA/stock-logistics-warehouse :alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_move_location :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_move_location
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/12.0 :target: https://runbot.odoo-community.org/runbot/153/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -75,7 +75,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_move_location%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_move_location%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@@ -93,9 +93,9 @@ Contributors
* Mathieu Vatel <mathieu@julius.fr> * Mathieu Vatel <mathieu@julius.fr>
* Mykhailo Panarin <m.panarin@mobilunity.com> * Mykhailo Panarin <m.panarin@mobilunity.com>
* Sergio Teruel <sergio.teruel@tecnativa.com> * Sergio Teruel <sergio.teruel@tecnativa.com>
* Joan Sisquella <joan.sisquella@eficent.com> * Joan Sisquella <joan.sisquella@forgeflow.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@forgeflow.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -110,6 +110,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_move_location>`_ project on GitHub. This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_move_location>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,3 +4,4 @@
from . import wizard from . import wizard
from . import models from . import models
from .init_hook import enable_multi_locations

View File

@@ -4,8 +4,8 @@
{ {
"name": "Move Stock Location", "name": "Move Stock Location",
"version": "12.0.1.2.0", "version": "13.0.1.0.0",
"author": "Julius Network Solutions, " "Odoo Community Association (OCA)", "author": "Julius Network Solutions, Odoo Community Association (OCA)",
"summary": "This module allows to move all stock " "summary": "This module allows to move all stock "
"in a stock location to an other one.", "in a stock location to an other one.",
"website": "https://github.com/OCA/stock-logistics-warehouse", "website": "https://github.com/OCA/stock-logistics-warehouse",
@@ -17,4 +17,5 @@
"views/stock_picking_type_views.xml", "views/stock_picking_type_views.xml",
"wizard/stock_move_location.xml", "wizard/stock_move_location.xml",
], ],
"post_init_hook": "enable_multi_locations",
} }

3
stock_move_location/data/stock_quant_view.xml Executable file → Normal file
View File

@@ -5,11 +5,10 @@
<act_window id="wiz_stock_quant_location_action" <act_window id="wiz_stock_quant_location_action"
name="Move to location..." name="Move to location..."
res_model="wiz.stock.move.location" res_model="wiz.stock.move.location"
src_model="stock.quant" binding_model="stock.quant"
view_mode="form" view_mode="form"
context="{'origin_location_disable': True}" context="{'origin_location_disable': True}"
target="new" target="new"
key2="client_action_multi"
groups="stock.group_stock_user" groups="stock.group_stock_user"
/> />

View File

@@ -131,7 +131,7 @@ msgid "Move from location..."
msgstr "Von Lagerort bewegen..." msgstr "Von Lagerort bewegen..."
#. module: stock_move_location #. module: stock_move_location
#: code:addons/stock_move_location/wizard/stock_move_location_line.py:65 #: code:addons/stock_move_location/wizard/stock_move_location_line.py:0
#, python-format #, python-format
msgid "Move quantity can not exceed max quantity or be negative" msgid "Move quantity can not exceed max quantity or be negative"
msgstr "Die Menge darf nicht die Bestandsmenge überschreiten oder negativ sein" msgstr "Die Menge darf nicht die Bestandsmenge überschreiten oder negativ sein"

View File

@@ -131,7 +131,7 @@ msgid "Move from location..."
msgstr "Mover desde ubicación..." msgstr "Mover desde ubicación..."
#. module: stock_move_location #. module: stock_move_location
#: code:addons/stock_move_location/wizard/stock_move_location_line.py:65 #: code:addons/stock_move_location/wizard/stock_move_location_line.py:0
#, python-format #, python-format
msgid "Move quantity can not exceed max quantity or be negative" msgid "Move quantity can not exceed max quantity or be negative"
msgstr "La cantidad movida no puede superar la cantidad máxima o ser negativo" msgstr "La cantidad movida no puede superar la cantidad máxima o ser negativo"

View File

@@ -1,12 +1,12 @@
# Translation of Odoo Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * stock_move_location # * stock_move_location
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@@ -124,7 +124,7 @@ msgid "Move from location..."
msgstr "" msgstr ""
#. module: stock_move_location #. module: stock_move_location
#: code:addons/stock_move_location/wizard/stock_move_location_line.py:65 #: code:addons/stock_move_location/wizard/stock_move_location_line.py:0
#, python-format #, python-format
msgid "Move quantity can not exceed max quantity or be negative" msgid "Move quantity can not exceed max quantity or be negative"
msgstr "" msgstr ""
@@ -183,7 +183,9 @@ msgstr ""
#. module: stock_move_location #. module: stock_move_location
#: model:ir.model.fields,help:stock_move_location.field_stock_picking_type__show_move_onhand #: model:ir.model.fields,help:stock_move_location.field_stock_picking_type__show_move_onhand
msgid "Show a button 'Move On Hand' in the Inventory Dashboard to initiate the process to move the products in stock at the origin location." msgid ""
"Show a button 'Move On Hand' in the Inventory Dashboard to initiate the "
"process to move the products in stock at the origin location."
msgstr "" msgstr ""
#. module: stock_move_location #. module: stock_move_location
@@ -220,4 +222,3 @@ msgstr ""
#: model:ir.model.fields,help:stock_move_location.field_wiz_stock_move_location__origin_location_disable #: model:ir.model.fields,help:stock_move_location.field_wiz_stock_move_location__origin_location_disable
msgid "technical field to disable the edition of origin location." msgid "technical field to disable the edition of origin location."
msgstr "" msgstr ""

View File

@@ -0,0 +1,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import SUPERUSER_ID, api
def enable_multi_locations(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
ResConfig = env["res.config.settings"]
default_values = ResConfig.default_get(list(ResConfig.fields_get()))
default_values.update({"group_stock_multi_locations": True})
ResConfig.create(default_values).execute()

View File

@@ -1,6 +1,6 @@
* Mathieu Vatel <mathieu@julius.fr> * Mathieu Vatel <mathieu@julius.fr>
* Mykhailo Panarin <m.panarin@mobilunity.com> * Mykhailo Panarin <m.panarin@mobilunity.com>
* Sergio Teruel <sergio.teruel@tecnativa.com> * Sergio Teruel <sergio.teruel@tecnativa.com>
* Joan Sisquella <joan.sisquella@eficent.com> * Joan Sisquella <joan.sisquella@forgeflow.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@forgeflow.com>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_move_location"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_move_location"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_move_location"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_move_location"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to move entire location of products from one place to <p>This module allows to move entire location of products from one place to
another and move only selected quants.</p> another and move only selected quants.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@@ -424,7 +424,7 @@ and you will be directed to the wizard.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_move_location%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_move_location%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -441,9 +441,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Mathieu Vatel &lt;<a class="reference external" href="mailto:mathieu&#64;julius.fr">mathieu&#64;julius.fr</a>&gt;</li> <li>Mathieu Vatel &lt;<a class="reference external" href="mailto:mathieu&#64;julius.fr">mathieu&#64;julius.fr</a>&gt;</li>
<li>Mykhailo Panarin &lt;<a class="reference external" href="mailto:m.panarin&#64;mobilunity.com">m.panarin&#64;mobilunity.com</a>&gt;</li> <li>Mykhailo Panarin &lt;<a class="reference external" href="mailto:m.panarin&#64;mobilunity.com">m.panarin&#64;mobilunity.com</a>&gt;</li>
<li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</li> <li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</li>
<li>Joan Sisquella &lt;<a class="reference external" href="mailto:joan.sisquella&#64;eficent.com">joan.sisquella&#64;eficent.com</a>&gt;</li> <li>Joan Sisquella &lt;<a class="reference external" href="mailto:joan.sisquella&#64;forgeflow.com">joan.sisquella&#64;forgeflow.com</a>&gt;</li>
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficent.com">jordi.ballester&#64;eficent.com</a>&gt;</li> <li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li> <li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -453,7 +453,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_move_location">OCA/stock-logistics-warehouse</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_move_location">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -14,56 +14,63 @@ class TestsCommon(common.SavepointCase):
product_obj = cls.env["product.product"] product_obj = cls.env["product.product"]
cls.wizard_obj = cls.env["wiz.stock.move.location"] cls.wizard_obj = cls.env["wiz.stock.move.location"]
cls.quant_obj = cls.env["stock.quant"] cls.quant_obj = cls.env["stock.quant"]
cls.company = cls.env.ref("base.main_company")
# Enable multi-locations:
wizard = cls.env["res.config.settings"].create(
{"group_stock_multi_locations": True}
)
wizard.execute()
cls.internal_loc_1 = cls.location_obj.create( cls.internal_loc_1 = cls.location_obj.create(
{"name": "INT_1", "usage": "internal", "active": True} {
"name": "INT_1",
"usage": "internal",
"active": True,
"company_id": cls.company.id,
}
) )
cls.internal_loc_2 = cls.location_obj.create( cls.internal_loc_2 = cls.location_obj.create(
{"name": "INT_2", "usage": "internal", "active": True} {
"name": "INT_2",
"usage": "internal",
"active": True,
"company_id": cls.company.id,
}
) )
cls.uom_unit = cls.env.ref("uom.product_uom_unit") cls.uom_unit = cls.env.ref("uom.product_uom_unit")
cls.product_no_lots = product_obj.create( cls.product_no_lots = product_obj.create(
{ {"name": "Pineapple", "type": "product", "tracking": "none"}
"name": "Pineapple",
"type": "product",
"tracking": "none",
"category_id": cls.env.ref("product.product_category_all").id,
}
) )
cls.product_lots = product_obj.create( cls.product_lots = product_obj.create(
{ {"name": "Apple", "type": "product", "tracking": "lot"}
"name": "Pineapple",
"type": "product",
"tracking": "lot",
"category_id": cls.env.ref("product.product_category_all").id,
}
) )
cls.lot1 = cls.env["stock.production.lot"].create( cls.lot1 = cls.env["stock.production.lot"].create(
{"product_id": cls.product_lots.id} {
"name": "lot1",
"product_id": cls.product_lots.id,
"company_id": cls.company.id,
}
) )
cls.lot2 = cls.env["stock.production.lot"].create( cls.lot2 = cls.env["stock.production.lot"].create(
{"product_id": cls.product_lots.id} {
"name": "lot2",
"product_id": cls.product_lots.id,
"company_id": cls.company.id,
}
) )
cls.lot3 = cls.env["stock.production.lot"].create( cls.lot3 = cls.env["stock.production.lot"].create(
{"product_id": cls.product_lots.id} {
"name": "lot3",
"product_id": cls.product_lots.id,
"company_id": cls.company.id,
}
) )
def setup_product_amounts(self): def setup_product_amounts(self):
self.set_product_amount(self.product_no_lots, self.internal_loc_1, 123) self.set_product_amount(self.product_no_lots, self.internal_loc_1, 123)
self.set_product_amount( self.set_product_amount(
self.product_lots, self.internal_loc_1, 1, lot_id=self.lot1 self.product_lots, self.internal_loc_1, 1.0, lot_id=self.lot1
) )
self.set_product_amount( self.set_product_amount(
self.product_lots, self.internal_loc_1, 1, lot_id=self.lot2 self.product_lots, self.internal_loc_1, 1.0, lot_id=self.lot2
) )
self.set_product_amount( self.set_product_amount(
self.product_lots, self.internal_loc_1, 1, lot_id=self.lot3 self.product_lots, self.internal_loc_1, 1.0, lot_id=self.lot3
) )
def set_product_amount(self, product, location, amount, lot_id=None): def set_product_amount(self, product, location, amount, lot_id=None):
@@ -78,3 +85,12 @@ class TestsCommon(common.SavepointCase):
), ),
amount, amount,
) )
def _create_wizard(self, origin_location, destination_location):
move_location_wizard = self.env["wiz.stock.move.location"]
return move_location_wizard.create(
{
"origin_location_id": origin_location.id,
"destination_location_id": destination_location.id,
}
)

View File

@@ -12,14 +12,6 @@ class TestMoveLocation(TestsCommon):
super().setUp() super().setUp()
self.setup_product_amounts() self.setup_product_amounts()
def _create_wizard(self, origin_location, destination_location):
return self.wizard_obj.create(
{
"origin_location_id": origin_location.id,
"destination_location_id": destination_location.id,
}
)
def test_move_location_wizard(self): def test_move_location_wizard(self):
"""Test a simple move.""" """Test a simple move."""
wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2) wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2)

View File

@@ -11,7 +11,6 @@ class StockMoveLocationWizard(models.TransientModel):
_name = "wiz.stock.move.location" _name = "wiz.stock.move.location"
_description = "Wizard move location" _description = "Wizard move location"
@api.multi
def _get_default_picking_type_id(self): def _get_default_picking_type_id(self):
company_id = self.env.context.get("company_id") or self.env.user.company_id.id company_id = self.env.context.get("company_id") or self.env.user.company_id.id
return ( return (
@@ -63,6 +62,9 @@ class StockMoveLocationWizard(models.TransientModel):
rec.origin_location_disable = self.env.context.get( rec.origin_location_disable = self.env.context.get(
"origin_location_disable", False "origin_location_disable", False
) )
rec.destination_location_disable = self.env.context.get(
"destination_location_disable", False
)
if not rec.edit_locations: if not rec.edit_locations:
rec.origin_location_disable = True rec.origin_location_disable = True
rec.destination_location_disable = True rec.destination_location_disable = True
@@ -120,7 +122,6 @@ class StockMoveLocationWizard(models.TransientModel):
} }
) )
@api.multi
def group_lines(self): def group_lines(self):
lines_grouped = {} lines_grouped = {}
for line in self.stock_move_location_line_ids: for line in self.stock_move_location_line_ids:
@@ -130,7 +131,6 @@ class StockMoveLocationWizard(models.TransientModel):
lines_grouped[line.product_id.id] |= line lines_grouped[line.product_id.id] |= line
return lines_grouped return lines_grouped
@api.multi
def _create_moves(self, picking): def _create_moves(self, picking):
self.ensure_one() self.ensure_one()
groups = self.group_lines() groups = self.group_lines()
@@ -158,7 +158,6 @@ class StockMoveLocationWizard(models.TransientModel):
"location_move": True, "location_move": True,
} }
@api.multi
def _create_move(self, picking, lines): def _create_move(self, picking, lines):
self.ensure_one() self.ensure_one()
move = self.env["stock.move"].create(self._get_move_values(picking, lines)) move = self.env["stock.move"].create(self._get_move_values(picking, lines))
@@ -167,7 +166,6 @@ class StockMoveLocationWizard(models.TransientModel):
line.create_move_lines(picking, move) line.create_move_lines(picking, move)
return move return move
@api.multi
def action_move_location(self): def action_move_location(self):
self.ensure_one() self.ensure_one()
picking = self._create_picking() picking = self._create_picking()
@@ -189,18 +187,16 @@ class StockMoveLocationWizard(models.TransientModel):
return action return action
def _get_group_quants(self): def _get_group_quants(self):
location_id = self.origin_location_id.id location_id = self.origin_location_id
company = self.env["res.company"]._company_default_get("stock.inventory")
# Using sql as search_group doesn't support aggregation functions # Using sql as search_group doesn't support aggregation functions
# leading to overhead in queries to DB # leading to overhead in queries to DB
query = """ query = """
SELECT product_id, lot_id, SUM(quantity) SELECT product_id, lot_id, SUM(quantity)
FROM stock_quant FROM stock_quant
WHERE location_id = %s WHERE location_id = %s
AND company_id = %s
GROUP BY product_id, lot_id GROUP BY product_id, lot_id
""" """
self.env.cr.execute(query, (location_id, company.id)) self.env.cr.execute(query, (location_id.id,))
return self.env.cr.dictfetchall() return self.env.cr.dictfetchall()
def _get_stock_move_location_lines_values(self): def _get_stock_move_location_lines_values(self):
@@ -210,7 +206,7 @@ class StockMoveLocationWizard(models.TransientModel):
product = product_obj.browse(group.get("product_id")).exists() product = product_obj.browse(group.get("product_id")).exists()
# Apply the putaway strategy # Apply the putaway strategy
location_dest_id = ( location_dest_id = (
self.destination_location_id.get_putaway_strategy(product).id self.destination_location_id._get_putaway_strategy(product).id
or self.destination_location_id.id or self.destination_location_id.id
) )
product_data.append( product_data.append(

0
stock_move_location/wizard/stock_move_location.xml Executable file → Normal file
View File

View File

@@ -6,8 +6,6 @@ from odoo import _, api, fields, models
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from odoo.tools import float_compare from odoo.tools import float_compare
from odoo.addons import decimal_precision as dp
class StockMoveLocationWizardLine(models.TransientModel): class StockMoveLocationWizardLine(models.TransientModel):
_name = "wiz.stock.move.location.line" _name = "wiz.stock.move.location.line"
@@ -31,11 +29,10 @@ class StockMoveLocationWizardLine(models.TransientModel):
domain="[('product_id','=',product_id)]", domain="[('product_id','=',product_id)]",
) )
move_quantity = fields.Float( move_quantity = fields.Float(
string="Quantity to move", digits=dp.get_precision("Product Unit of Measure") string="Quantity to move", digits="Product Unit of Measure"
) )
max_quantity = fields.Float( max_quantity = fields.Float(
string="Maximum available quantity", string="Maximum available quantity", digits="Product Unit of Measure"
digits=dp.get_precision("Product Unit of Measure"),
) )
custom = fields.Boolean(string="Custom line", default=True) custom = fields.Boolean(string="Custom line", default=True)
@@ -78,11 +75,10 @@ class StockMoveLocationWizardLine(models.TransientModel):
self.env["stock.move.line"].create(values) self.env["stock.move.line"].create(values)
return True return True
@api.multi
def _get_move_line_values(self, picking, move): def _get_move_line_values(self, picking, move):
self.ensure_one() self.ensure_one()
location_dest_id = ( location_dest_id = (
self.destination_location_id.get_putaway_strategy(self.product_id).id self.destination_location_id._get_putaway_strategy(self.product_id).id
or self.destination_location_id.id or self.destination_location_id.id
) )
qty_todo, qty_done = self._get_available_quantity() qty_todo, qty_done = self._get_available_quantity()