[MIG] stock_inventory_exclude_sublocation: Migration to 13.0

This commit is contained in:
hveficent
2019-12-30 11:11:10 +01:00
committed by joan
parent 137a0d51a1
commit 7b80aba6b0
7 changed files with 26 additions and 129 deletions

View File

@@ -14,13 +14,13 @@ Stock Inventory Exclude Sublocation
: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_inventory_exclude_sublocation :target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_inventory_exclude_sublocation
: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_inventory_exclude_sublocation :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_inventory_exclude_sublocation
: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|
@@ -55,7 +55,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_inventory_exclude_sublocation%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_inventory_exclude_sublocation%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.
@@ -71,8 +71,9 @@ Authors
Contributors Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
* Lois Rilo Antelo <lois.rilo@eficent.com> * Lois Rilo Antelo <lois.rilo@forgeflow.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com> * Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Héctor Villarreal <hector.villarreal@forgeflow.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -87,6 +88,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_inventory_exclude_sublocation>`_ project on GitHub. This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_inventory_exclude_sublocation>`_ 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

@@ -1,16 +1,15 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L. # Copyright 2017-2019 ForgeFlow S.L. (http://www.forgeflow.com)
# (http://www.eficent.com)
# Copyright 2019 Tecnativa - Pedro M. Baeza # Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "Stock Inventory Exclude Sublocation", "name": "Stock Inventory Exclude Sublocation",
"summary": "Allow to perform inventories of a location without including " "summary": "Allow to perform inventories of a location without including "
"its child locations.", "its child locations.",
"version": "12.0.1.0.1", "version": "13.0.1.0.1",
"development_status": "Mature", "development_status": "Mature",
"author": "Eficent, " "Tecnativa, " "Odoo Community Association (OCA)", "author": "ForgeFlow, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse", "website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse Management", "category": "Warehouse",
"depends": ["stock"], "depends": ["stock"],
"data": ["views/stock_inventory_view.xml"], "data": ["views/stock_inventory_view.xml"],
"license": "AGPL-3", "license": "AGPL-3",

View File

@@ -1,5 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L. # Copyright 2019 ForgeFlow S.L. (http://www.forgeflow.com)
# (http://www.eficent.com)
# Copyright 2019 Tecnativa - Pedro M. Baeza # Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@@ -28,6 +27,6 @@ class Inventory(models.Model):
return vals return vals
new_vals = [] new_vals = []
for val in vals: for val in vals:
if val["location_id"] == self.location_id.id: if val["location_id"] in self.location_ids.ids:
new_vals.append(val) new_vals.append(val)
return new_vals return new_vals

View File

@@ -1,2 +1,3 @@
* Lois Rilo Antelo <lois.rilo@eficent.com> * Lois Rilo Antelo <lois.rilo@forgeflow.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com> * Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Héctor Villarreal <hector.villarreal@forgeflow.com>

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Stock Inventory Exclude Sublocation</title> <title>Stock Inventory Exclude Sublocation</title>
<style type="text/css"> <style type="text/css">
@@ -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="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.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_inventory_exclude_sublocation"><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_inventory_exclude_sublocation"><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="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.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_inventory_exclude_sublocation"><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_inventory_exclude_sublocation"><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 extends the functionality of Inventory Adjustment to allow you to <p>This module extends the functionality of Inventory Adjustment to allow you to
exclude all the sublocations when doing an inventory adjustment for a exclude all the sublocations when doing an inventory adjustment for a
given location.</p> given location.</p>
@@ -403,7 +403,7 @@ E.g. if we apply a cycle count strategy.</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_inventory_exclude_sublocation%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_inventory_exclude_sublocation%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">
@@ -418,8 +418,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2> <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Lois Rilo Antelo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li> <li>Lois Rilo Antelo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Bhavesh Odedra &lt;<a class="reference external" href="mailto:bodedra&#64;opensourceintegrators.com">bodedra&#64;opensourceintegrators.com</a>&gt;</li> <li>Bhavesh Odedra &lt;<a class="reference external" href="mailto:bodedra&#64;opensourceintegrators.com">bodedra&#64;opensourceintegrators.com</a>&gt;</li>
<li>Héctor Villarreal &lt;<a class="reference external" href="mailto:hector.villarreal&#64;forgeflow.com">hector.villarreal&#64;forgeflow.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -429,7 +430,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_inventory_exclude_sublocation">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_inventory_exclude_sublocation">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

@@ -10,17 +10,11 @@ class TestStockInventoryExcludeSublocation(TransactionCase):
super(TestStockInventoryExcludeSublocation, self).setUp() super(TestStockInventoryExcludeSublocation, self).setUp()
self.inventory_model = self.env["stock.inventory"] self.inventory_model = self.env["stock.inventory"]
self.location_model = self.env["stock.location"] self.location_model = self.env["stock.location"]
self.lot_model = self.env["stock.production.lot"]
self.quant_model = self.env["stock.quant"]
self.package_model = self.env["stock.quant.package"]
self.res_users_model = self.env["res.users"] self.res_users_model = self.env["res.users"]
self.company = self.env.ref("base.main_company") self.company = self.env.ref("base.main_company")
self.partner = self.ref("base.res_partner_4") self.partner = self.ref("base.res_partner_4")
self.grp_stock_manager = self.env.ref("stock.group_stock_manager") self.grp_stock_manager = self.env.ref("stock.group_stock_manager")
self.grp_tracking_owner = self.env.ref("stock.group_tracking_owner")
self.grp_production_lot = self.env.ref("stock.group_production_lot")
self.grp_tracking_lot = self.env.ref("stock.group_tracking_lot")
self.user = self.res_users_model.create( self.user = self.res_users_model.create(
{ {
@@ -29,18 +23,7 @@ class TestStockInventoryExcludeSublocation(TransactionCase):
"email": "example@yourcompany.com", "email": "example@yourcompany.com",
"company_id": self.company.id, "company_id": self.company.id,
"company_ids": [(4, self.company.id)], "company_ids": [(4, self.company.id)],
"groups_id": [ "groups_id": [(6, 0, [self.grp_stock_manager.id])],
(
6,
0,
[
self.grp_stock_manager.id,
self.grp_tracking_owner.id,
self.grp_production_lot.id,
self.grp_tracking_lot.id,
],
)
],
} }
) )
@@ -68,19 +51,11 @@ class TestStockInventoryExcludeSublocation(TransactionCase):
"location_id": self.location.id, "location_id": self.location.id,
} }
) )
self.lot_a = self.lot_model.create(
{"name": "Lot for product1", "product_id": self.product1.id}
)
self.lot_b = self.lot_model.create(
{"name": "Lot for product1", "product_id": self.product2.id}
)
self.package = self.package_model.create({"name": "PACK00TEST1"})
# Add a product in each location # Add a product in each location
starting_inv = self.inventory_model.create( starting_inv = self.inventory_model.create(
{ {
"name": "Starting inventory", "name": "Starting inventory",
"filter": "product",
"line_ids": [ "line_ids": [
( (
0, 0,
@@ -90,7 +65,6 @@ class TestStockInventoryExcludeSublocation(TransactionCase):
"product_uom_id": self.env.ref("uom.product_uom_unit").id, "product_uom_id": self.env.ref("uom.product_uom_unit").id,
"product_qty": 2.0, "product_qty": 2.0,
"location_id": self.location.id, "location_id": self.location.id,
"prod_lot_id": self.lot_a.id,
}, },
), ),
( (
@@ -101,20 +75,19 @@ class TestStockInventoryExcludeSublocation(TransactionCase):
"product_uom_id": self.env.ref("uom.product_uom_unit").id, "product_uom_id": self.env.ref("uom.product_uom_unit").id,
"product_qty": 4.0, "product_qty": 4.0,
"location_id": self.sublocation.id, "location_id": self.sublocation.id,
"prod_lot_id": self.lot_b.id,
}, },
), ),
], ],
} }
) )
starting_inv.action_start()
starting_inv.action_validate() starting_inv.action_validate()
def _create_inventory_all_products(self, name, location, exclude_sublocation): def _create_inventory_all_products(self, name, location, exclude_sublocation):
inventory = self.inventory_model.create( inventory = self.inventory_model.create(
{ {
"name": name, "name": name,
"filter": "none", "location_ids": [(4, location.id)],
"location_id": location.id,
"exclude_sublocation": exclude_sublocation, "exclude_sublocation": exclude_sublocation,
} }
) )
@@ -154,80 +127,3 @@ class TestStockInventoryExcludeSublocation(TransactionCase):
1, 1,
"The products in the sublocations are not excluded", "The products in the sublocations are not excluded",
) )
def test_lot_excluding_sublocation(self):
"""Check if the sublocations are excluded when using lots."""
inventory = self.inventory_model.sudo(self.user.id).create(
{
"name": "Inventory lot",
"filter": "lot",
"location_id": self.location.id,
"lot_id": self.lot_a.id,
"exclude_sublocation": True,
}
)
inventory.action_start()
inventory.action_validate()
lines = inventory.line_ids
self.assertEqual(
len(lines),
1,
"The products in the sublocations are " "not excluded with lots.",
)
def test_product_and_owner_excluding_sublocation(self):
"""Check if sublocations are excluded when filtering by owner and
product."""
self.quant_model.create(
{
"product_id": self.product1.id,
"location_id": self.location.id,
"quantity": 1,
"owner_id": self.partner,
}
)
inventory = self.inventory_model.sudo(self.user.id).create(
{
"name": "Inventory lot",
"filter": "product_owner",
"location_id": self.location.id,
"product_id": self.product1.id,
"partner_id": self.partner,
"exclude_sublocation": True,
}
)
inventory.action_start()
lines = inventory.line_ids
self.assertEqual(
len(lines),
1,
"The products in the sublocations are "
"not excluded with product and owner filter.",
)
def test_pack_excluding_sublocation(self):
"""Check if sublocations are excluded when filtering by package."""
self.quant_model.create(
{
"product_id": self.product1.id,
"location_id": self.location.id,
"quantity": 1,
"package_id": self.package.id,
}
)
inventory = self.inventory_model.sudo(self.user.id).create(
{
"name": "Inventory lot",
"filter": "pack",
"location_id": self.location.id,
"package_id": self.package.id,
"exclude_sublocation": True,
}
)
inventory.action_start()
lines = inventory.line_ids
self.assertEqual(
len(lines),
1,
"The products in the sublocations are " "not excluded with package filter.",
)

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L. <!-- Copyright 2019 ForgeFlow S.L. (http://www.forgeflow.com)
Copyright 2019 Tecnativa - Pedro M. Baeza Copyright 2019 Tecnativa - Pedro M. Baeza
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
@@ -10,7 +10,7 @@
<field name="model">stock.inventory</field> <field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form"/> <field name="inherit_id" ref="stock.view_inventory_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="location_id" position="after"> <field name="location_ids" position="after">
<field name="exclude_sublocation" <field name="exclude_sublocation"
groups="stock.group_stock_multi_locations" groups="stock.group_stock_multi_locations"
/> />