[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
:alt: License: AGPL-3
.. |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
.. |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
.. |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
|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>`_.
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 <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.
@@ -93,9 +93,9 @@ Contributors
* Mathieu Vatel <mathieu@julius.fr>
* Mykhailo Panarin <m.panarin@mobilunity.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Joan Sisquella <joan.sisquella@eficent.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
* Joan Sisquella <joan.sisquella@forgeflow.com>
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@forgeflow.com>
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
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.

View File

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

View File

@@ -4,8 +4,8 @@
{
"name": "Move Stock Location",
"version": "12.0.1.2.0",
"author": "Julius Network Solutions, " "Odoo Community Association (OCA)",
"version": "13.0.1.0.0",
"author": "Julius Network Solutions, Odoo Community Association (OCA)",
"summary": "This module allows to move all stock "
"in a stock location to an other one.",
"website": "https://github.com/OCA/stock-logistics-warehouse",
@@ -17,4 +17,5 @@
"views/stock_picking_type_views.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"
name="Move to location..."
res_model="wiz.stock.move.location"
src_model="stock.quant"
binding_model="stock.quant"
view_mode="form"
context="{'origin_location_disable': True}"
target="new"
key2="client_action_multi"
groups="stock.group_stock_user"
/>

View File

@@ -131,7 +131,7 @@ msgid "Move from location..."
msgstr "Von Lagerort bewegen..."
#. 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
msgid "Move quantity can not exceed max quantity or be negative"
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..."
#. 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
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"

View File

@@ -4,9 +4,9 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -124,7 +124,7 @@ msgid "Move from location..."
msgstr ""
#. 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
msgid "Move quantity can not exceed max quantity or be negative"
msgstr ""
@@ -183,7 +183,9 @@ msgstr ""
#. module: stock_move_location
#: 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 ""
#. 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
msgid "technical field to disable the edition of origin location."
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>
* Mykhailo Panarin <m.panarin@mobilunity.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Joan Sisquella <joan.sisquella@eficent.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
* Joan Sisquella <joan.sisquella@forgeflow.com>
* Jordi Ballester Alomar <jordi.ballester@forgeflow.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 !!
!! 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
another and move only selected quants.</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>.
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
<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>
</div>
<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>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>Joan Sisquella &lt;<a class="reference external" href="mailto:joan.sisquella&#64;eficent.com">joan.sisquella&#64;eficent.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>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#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;forgeflow.com">jordi.ballester&#64;forgeflow.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>
</div>
<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
mission is to support the collaborative development of Odoo features and
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>
</div>
</div>

View File

@@ -14,56 +14,63 @@ class TestsCommon(common.SavepointCase):
product_obj = cls.env["product.product"]
cls.wizard_obj = cls.env["wiz.stock.move.location"]
cls.quant_obj = cls.env["stock.quant"]
# Enable multi-locations:
wizard = cls.env["res.config.settings"].create(
{"group_stock_multi_locations": True}
)
wizard.execute()
cls.company = cls.env.ref("base.main_company")
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(
{"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.product_no_lots = product_obj.create(
{
"name": "Pineapple",
"type": "product",
"tracking": "none",
"category_id": cls.env.ref("product.product_category_all").id,
}
{"name": "Pineapple", "type": "product", "tracking": "none"}
)
cls.product_lots = product_obj.create(
{
"name": "Pineapple",
"type": "product",
"tracking": "lot",
"category_id": cls.env.ref("product.product_category_all").id,
}
{"name": "Apple", "type": "product", "tracking": "lot"}
)
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(
{"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(
{"product_id": cls.product_lots.id}
{
"name": "lot3",
"product_id": cls.product_lots.id,
"company_id": cls.company.id,
}
)
def setup_product_amounts(self):
self.set_product_amount(self.product_no_lots, self.internal_loc_1, 123)
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.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.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):
@@ -78,3 +85,12 @@ class TestsCommon(common.SavepointCase):
),
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()
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):
"""Test a simple move."""
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"
_description = "Wizard move location"
@api.multi
def _get_default_picking_type_id(self):
company_id = self.env.context.get("company_id") or self.env.user.company_id.id
return (
@@ -63,6 +62,9 @@ class StockMoveLocationWizard(models.TransientModel):
rec.origin_location_disable = self.env.context.get(
"origin_location_disable", False
)
rec.destination_location_disable = self.env.context.get(
"destination_location_disable", False
)
if not rec.edit_locations:
rec.origin_location_disable = True
rec.destination_location_disable = True
@@ -120,7 +122,6 @@ class StockMoveLocationWizard(models.TransientModel):
}
)
@api.multi
def group_lines(self):
lines_grouped = {}
for line in self.stock_move_location_line_ids:
@@ -130,7 +131,6 @@ class StockMoveLocationWizard(models.TransientModel):
lines_grouped[line.product_id.id] |= line
return lines_grouped
@api.multi
def _create_moves(self, picking):
self.ensure_one()
groups = self.group_lines()
@@ -158,7 +158,6 @@ class StockMoveLocationWizard(models.TransientModel):
"location_move": True,
}
@api.multi
def _create_move(self, picking, lines):
self.ensure_one()
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)
return move
@api.multi
def action_move_location(self):
self.ensure_one()
picking = self._create_picking()
@@ -189,18 +187,16 @@ class StockMoveLocationWizard(models.TransientModel):
return action
def _get_group_quants(self):
location_id = self.origin_location_id.id
company = self.env["res.company"]._company_default_get("stock.inventory")
location_id = self.origin_location_id
# Using sql as search_group doesn't support aggregation functions
# leading to overhead in queries to DB
query = """
SELECT product_id, lot_id, SUM(quantity)
FROM stock_quant
WHERE location_id = %s
AND company_id = %s
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()
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()
# Apply the putaway strategy
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
)
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.tools import float_compare
from odoo.addons import decimal_precision as dp
class StockMoveLocationWizardLine(models.TransientModel):
_name = "wiz.stock.move.location.line"
@@ -31,11 +29,10 @@ class StockMoveLocationWizardLine(models.TransientModel):
domain="[('product_id','=',product_id)]",
)
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(
string="Maximum available quantity",
digits=dp.get_precision("Product Unit of Measure"),
string="Maximum available quantity", digits="Product Unit of Measure"
)
custom = fields.Boolean(string="Custom line", default=True)
@@ -78,11 +75,10 @@ class StockMoveLocationWizardLine(models.TransientModel):
self.env["stock.move.line"].create(values)
return True
@api.multi
def _get_move_line_values(self, picking, move):
self.ensure_one()
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
)
qty_todo, qty_done = self._get_available_quantity()