Skip to content

Commit

Permalink
[MIG] stock_operating_unit: Migration to 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BT-nstuder committed Jan 7, 2020
1 parent df2cb07 commit 7d526e5
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 51 deletions.
12 changes: 6 additions & 6 deletions stock_operating_unit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Stock with Operating Units
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/12.0/stock_operating_unit
:target: https://github.com/OCA/operating-unit/tree/13.0/stock_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-stock_operating_unit
:target: https://translation.odoo-community.org/projects/operating-unit-13-0/operating-unit-13-0-stock_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/213/12.0
:target: https://runbot.odoo-community.org/runbot/213/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|

This module introduces the following features:

Expand Down Expand Up @@ -64,7 +64,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20stock_operating_unit%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20stock_operating_unit%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.

Expand Down Expand Up @@ -97,6 +97,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/operating-unit <https://github.com/OCA/operating-unit/tree/12.0/stock_operating_unit>`_ project on GitHub.
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/13.0/stock_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion stock_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent, "
"Serpent Consulting Services Pvt. Ltd., "
Expand Down
2 changes: 1 addition & 1 deletion stock_operating_unit/i18n/stock_operating_unit.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
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"
"Language-Team: \n"
Expand Down
4 changes: 0 additions & 4 deletions stock_operating_unit/model/stock_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class StockLocation(models.Model):

operating_unit_id = fields.Many2one("operating.unit", "Operating Unit")

@api.multi
@api.constrains("operating_unit_id")
def _check_warehouse_operating_unit(self):
for rec in self:
Expand All @@ -34,7 +33,6 @@ def _check_warehouse_operating_unit(self):
)
)

@api.multi
@api.constrains("operating_unit_id")
def _check_required_operating_unit(self):
for rec in self:
Expand All @@ -53,7 +51,6 @@ def _check_required_operating_unit(self):
)
)

@api.multi
@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for rec in self:
Expand All @@ -69,7 +66,6 @@ def _check_company_operating_unit(self):
)
)

@api.multi
@api.constrains("operating_unit_id", "location_id")
def _check_parent_operating_unit(self):
for rec in self:
Expand Down
1 change: 0 additions & 1 deletion stock_operating_unit/model/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class StockMove(models.Model):
string="Dest. Location Operating Unit",
)

@api.multi
@api.constrains("picking_id", "location_id", "location_dest_id")
def _check_stock_move_operating_unit(self):
for stock_move in self:
Expand Down
2 changes: 0 additions & 2 deletions stock_operating_unit/model/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def onchange_picking_type(self):
self.operating_unit_id = unit
return res

@api.multi
@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for rec in self:
Expand All @@ -39,7 +38,6 @@ def _check_company_operating_unit(self):
)
)

@api.multi
@api.constrains("operating_unit_id", "picking_type_id")
def _check_picking_type_operating_unit(self):
for rec in self:
Expand Down
2 changes: 0 additions & 2 deletions stock_operating_unit/model/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def _default_operating_unit(self):
default=_default_operating_unit,
)

@api.multi
@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for rec in self:
Expand All @@ -43,7 +42,6 @@ def _check_company_operating_unit(self):
class StockWarehouseOrderPoint(models.Model):
_inherit = "stock.warehouse.orderpoint"

@api.multi
@api.constrains("operating_unit_id", "warehouse_id", "location_id")
def _check_location(self):
for rec in self:
Expand Down
6 changes: 3 additions & 3 deletions stock_operating_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock with Operating Units</h1>
!! 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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/operating-unit/tree/12.0/stock_operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-stock_operating_unit"><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/213/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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/operating-unit/tree/13.0/stock_operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/operating-unit-13-0/operating-unit-13-0-stock_operating_unit"><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/213/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module introduces the following features:</p>
<ul class="simple">
<li>Adds the operating unit to the Warehouse.</li>
Expand Down Expand Up @@ -414,7 +414,7 @@ <h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20stock_operating_unit%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/operating-unit/issues/new?body=module:%20stock_operating_unit%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">
Expand All @@ -441,7 +441,7 @@ <h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<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/operating-unit/tree/12.0/stock_operating_unit">OCA/operating-unit</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/operating-unit/tree/13.0/stock_operating_unit">OCA/operating-unit</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>
Expand Down
4 changes: 2 additions & 2 deletions stock_operating_unit/tests/test_stock_operating_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def _create_user(self, login, groups, company, operating_units):

def _create_picking(self, user_id, ou_id, picking_type, src_loc_id, dest_loc_id):
"""Create a Picking."""
picking = self.PickingObj.sudo(user_id).create(
picking = self.PickingObj.with_user(user_id).create(
{
"picking_type_id": picking_type,
"location_id": src_loc_id,
"location_dest_id": dest_loc_id,
"operating_unit_id": ou_id,
}
)
self.MoveObj.sudo(user_id).create(
self.MoveObj.with_user(user_id).create(
{
"name": "a move",
"product_id": self.productA.id,
Expand Down
6 changes: 3 additions & 3 deletions stock_operating_unit/tests/test_stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
def test_stock_picking_ou(self):
"""Test Pickings of Stock Operating Unit"""
picking_ids = (
self.PickingObj.sudo(self.user1_id)
self.PickingObj.with_user(self.user1_id)
.search([("id", "=", self.picking_in1.id)])
.ids
)
self.assertNotEqual(picking_ids, [], "")
picking_ids = (
self.PickingObj.sudo(self.user2_id)
self.PickingObj.with_user(self.user2_id)
.search([("id", "=", self.picking_in2.id)])
.ids
)
self.assertNotEqual(picking_ids, [])
picking_ids = (
self.PickingObj.sudo(self.user1_id)
self.PickingObj.with_user(self.user1_id)
.search([("id", "=", self.picking_int.id)])
.ids
)
Expand Down
18 changes: 10 additions & 8 deletions stock_operating_unit/tests/test_stock_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_stock_ou_security(self):
# User 1 can list the warehouses assigned to
# Main and B2C OU
wh_ids = (
self.WarehouseObj.sudo(self.user1_id)
self.WarehouseObj.with_user(self.user1_id)
.search([("operating_unit_id", "in", [self.ou1.id, self.b2c.id])])
.ids
)
Expand All @@ -23,7 +23,7 @@ def test_stock_ou_security(self):
)
# User 1 can list the locations assigned to Main and b2c OU
location_ids = (
self.LocationObj.sudo(self.user1_id)
self.LocationObj.with_user(self.user1_id)
.search([("operating_unit_id", "in", [self.ou1.id, self.b2c.id])])
.ids
)
Expand All @@ -36,7 +36,7 @@ def test_stock_ou_security(self):
)
# User 2 cannot list the warehouses assigned to Main OU
wh_ids = (
self.WarehouseObj.sudo(self.user2_id)
self.WarehouseObj.with_user(self.user2_id)
.search([("operating_unit_id", "=", self.ou1.id)])
.ids
)
Expand All @@ -48,7 +48,7 @@ def test_stock_ou_security(self):
)
# User 2 cannot list the locations assigned to Main OU
location_ids = (
self.LocationObj.sudo(self.user2_id)
self.LocationObj.with_user(self.user2_id)
.search([("operating_unit_id", "in", [self.ou1.id])])
.ids
)
Expand All @@ -60,7 +60,9 @@ def test_stock_ou_security(self):
pickings = [self.picking_in1.id, self.picking_in2.id, self.picking_int.id]
# User 1 can list the pickings 1, 2, 3
picking_ids = (
self.PickingObj.sudo(self.user1_id).search([("id", "in", pickings)]).ids
self.PickingObj.with_user(self.user1_id)
.search([("id", "in", pickings)])
.ids
)
self.assertNotEqual(
picking_ids,
Expand All @@ -69,7 +71,7 @@ def test_stock_ou_security(self):
)
# User 1 can list the stock moves assigned to pickings 1, 2, 3
move_ids = (
self.MoveObj.sudo(self.user1_id)
self.MoveObj.with_user(self.user1_id)
.search([("picking_id", "in", pickings)])
.ids
)
Expand All @@ -80,7 +82,7 @@ def test_stock_ou_security(self):
)
# User 2 cannot list the the stock moves assigned to picking 1
move_ids = (
self.MoveObj.sudo(self.user2_id)
self.MoveObj.with_user(self.user2_id)
.search([("picking_id", "=", self.picking_in1.id)])
.ids
)
Expand All @@ -92,7 +94,7 @@ def test_stock_ou_security(self):
)
# User 2 can list the picking 1
picking_ids = (
self.PickingObj.sudo(self.user2_id)
self.PickingObj.with_user(self.user2_id)
.search([("id", "=", self.picking_in1.id)])
.ids
)
Expand Down
18 changes: 0 additions & 18 deletions stock_operating_unit/view/stock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,6 @@
</field>
</record>

<record id="view_move_picking_form" model="ir.ui.view">
<field name="name">stock.move.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_picking_form"/>
<field name="arch" type="xml">
<field name="location_id" position="after">
<field name="operating_unit_id"
domain="[('user_ids', 'in', uid)]"
groups="operating_unit.group_multi_operating_unit"/>
</field>
<field name="location_dest_id" position="after">
<field name="operating_unit_dest_id"
domain="[('user_ids', 'in', uid)]"
groups="operating_unit.group_multi_operating_unit"/>
</field>
</field>
</record>

<record id="stock_move_tree" model="ir.ui.view">
<field name="name">Stock Moves</field>
<field name="model">stock.move</field>
Expand Down

0 comments on commit 7d526e5

Please sign in to comment.