-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] pos_operating_unit: Migration to 17.0
- Loading branch information
1 parent
50d0c93
commit c62964c
Showing
14 changed files
with
180 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,11 @@ | |
|
||
/* | ||
:Author: David Goodger ([email protected]) | ||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ | ||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ | ||
:Copyright: This stylesheet has been placed in the public domain. | ||
|
||
Default cascading style sheet for the HTML output of Docutils. | ||
Despite the name, some widely supported CSS2 features are used. | ||
|
||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to | ||
customize this style sheet. | ||
|
@@ -274,7 +275,7 @@ | |
margin-left: 2em ; | ||
margin-right: 2em } | ||
|
||
pre.code .ln { color: grey; } /* line numbers */ | ||
pre.code .ln { color: gray; } /* line numbers */ | ||
pre.code, code { background-color: #eeeeee } | ||
pre.code .comment, code .comment { color: #5C6576 } | ||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } | ||
|
@@ -300,7 +301,7 @@ | |
span.pre { | ||
white-space: pre } | ||
|
||
span.problematic { | ||
span.problematic, pre.problematic { | ||
color: red } | ||
|
||
span.section-subtitle { | ||
|
@@ -441,7 +442,9 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2> | |
<div class="section" id="maintainers"> | ||
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2> | ||
<p>This module is maintained by the OCA.</p> | ||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> | ||
<a class="reference external image-reference" href="https://odoo-community.org"> | ||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /> | ||
</a> | ||
<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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
from . import pos_order | ||
from . import pos_session | ||
from . import pos_payment | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
pos_operating_unit_ids = fields.Many2many( | ||
related="pos_config_id.operating_unit_ids", | ||
readonly=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from . import test_module | ||
from . import test_pos_operating_unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,67 @@ | ||
from odoo import fields | ||
from odoo.exceptions import AccessError | ||
from odoo.tests.common import TransactionCase | ||
from odoo.models import Command | ||
|
||
from odoo.addons.operating_unit.tests.common import OperatingUnitCommon | ||
|
||
class TestModule(TransactionCase): | ||
def setUp(self): | ||
super(TestModule, self).setUp() | ||
self.ResUsers = self.env["res.users"] | ||
self.PosOrder = self.env["pos.order"] | ||
self.pos_product = self.env.ref("point_of_sale.whiteboard_pen") | ||
self.pricelist = self.env.ref("product.list0") | ||
|
||
# Create a new pos config and open it | ||
self.pos_config = self.env.ref("point_of_sale.pos_config_main").copy() | ||
class TestPOSOperatingUnit(OperatingUnitCommon): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.PosOrder = cls.env["pos.order"] | ||
cls.pos_product = cls.env.ref("point_of_sale.whiteboard_pen") | ||
cls.pricelist = cls.env["product.pricelist"].search([], limit=1) | ||
|
||
# company | ||
self.company = self.env.ref("base.main_company") | ||
# group | ||
self.group_user = self.env.ref("base.group_user") | ||
self.group_pos_manager = self.env.ref("point_of_sale.group_pos_manager") | ||
# Main Operating Unit | ||
self.ou1 = self.env.ref("operating_unit.main_operating_unit") | ||
# B2B Operating Unit | ||
self.b2b = self.env.ref("operating_unit.b2b_operating_unit") | ||
# Create a new pos config and open it | ||
cls.pos_config = cls.env.ref("point_of_sale.pos_config_main").copy() | ||
cls.group_pos_manager = cls.env.ref("point_of_sale.group_pos_manager") | ||
cls.group_account_invoice = cls.env.ref("account.group_account_invoice") | ||
|
||
self.pos_config.operating_unit_ids = [(6, 0, [self.ou1.id])] | ||
self.pos_config.open_session_cb() | ||
cls.pos_config.operating_unit_ids = [Command.set([cls.ou1.id])] | ||
cls.pos_config.open_ui() | ||
|
||
# Create users | ||
self.user1_id = self._create_user( | ||
"user_1", | ||
[self.group_user, self.group_pos_manager], | ||
self.company, | ||
[self.ou1, self.b2b], | ||
cls.user1.write( | ||
{ | ||
"groups_id": [ | ||
Command.link(cls.group_pos_manager.id), | ||
Command.link(cls.group_account_invoice.id), | ||
], | ||
"operating_unit_ids": [Command.link(cls.b2b.id)], | ||
} | ||
) | ||
self.user2_id = self._create_user( | ||
"user_2", | ||
[self.group_user, self.group_pos_manager], | ||
self.company, | ||
[self.b2b], | ||
cls.user2.write( | ||
{ | ||
"groups_id": [ | ||
Command.link(cls.group_pos_manager.id), | ||
Command.link(cls.group_account_invoice.id), | ||
], | ||
"operating_unit_ids": [Command.set([cls.b2b.id])], | ||
} | ||
) | ||
|
||
def test_operating_unit_access_config(self): | ||
config1_ids = self.env["pos.config"].with_user(self.user1_id).search([]) | ||
config1_ids = self.env["pos.config"].with_user(self.user1).search([]) | ||
self.assertIn(self.pos_config, config1_ids) | ||
config2_ids = self.env["pos.config"].with_user(self.user2_id).search([]) | ||
config2_ids = self.env["pos.config"].with_user(self.user2).search([]) | ||
self.assertNotIn(self.pos_config, config2_ids) | ||
|
||
def test_operating_unit_access_session(self): | ||
self.pos_config.current_session_id.with_user(self.user1_id).read() | ||
self.pos_config.current_session_id.with_user(self.user1).read() | ||
with self.assertRaises(AccessError): | ||
self.pos_config.current_session_id.with_user(self.user2_id).read() | ||
self.pos_config.current_session_id.with_user(self.user2).read() | ||
|
||
def test_operating_unit_access_order_and_line_and_payment(self): | ||
order = self._create_order() | ||
order.with_user(self.user1_id).read() | ||
order.lines.with_user(self.user1_id).read() | ||
order.with_user(self.user1).read() | ||
order.lines.with_user(self.user1).read() | ||
with self.assertRaises(AccessError): | ||
order.with_user(self.user2_id).read() | ||
order.with_user(self.user2).read() | ||
with self.assertRaises(AccessError): | ||
order.lines.with_user(self.user2_id).read() | ||
order.payment_ids.with_user(self.user1_id).read() | ||
order.lines.with_user(self.user2).read() | ||
order.payment_ids.with_user(self.user1).read() | ||
with self.assertRaises(AccessError): | ||
order.payment_ids.with_user(self.user2_id).read() | ||
order.payment_ids.with_user(self.user2).read() | ||
|
||
def _create_order(self): | ||
# Create order | ||
|
@@ -71,6 +70,7 @@ def _create_order(self): | |
"id": "0006-001-0010", | ||
"to_invoice": False, | ||
"data": { | ||
"date_order": fields.Datetime.to_string(fields.Datetime.now()), | ||
"pricelist_id": self.pricelist.id, | ||
"user_id": 1, | ||
"name": "Order 0006-001-0010", | ||
|
@@ -84,6 +84,7 @@ def _create_order(self): | |
{ | ||
"product_id": self.pos_product.id, | ||
"qty": 1, | ||
"price_unit": 1000, | ||
"price_subtotal": 1000, | ||
"price_subtotal_incl": 1000, | ||
}, | ||
|
@@ -117,20 +118,3 @@ def _create_order(self): | |
result = self.PosOrder.create_from_ui([order_data]) | ||
order = self.PosOrder.browse(result[0].get("id")) | ||
return order | ||
|
||
def _create_user(self, login, groups, company, operating_units): | ||
"""Create a user.""" | ||
group_ids = [group.id for group in groups] | ||
user = self.ResUsers.with_context({"no_reset_password": True}).create( | ||
{ | ||
"name": "Chicago Purchase User", | ||
"login": login, | ||
"password": "demo", | ||
"email": "[email protected]", | ||
"company_id": company.id, | ||
"company_ids": [(4, company.id)], | ||
"operating_unit_ids": [(4, ou.id) for ou in operating_units], | ||
"groups_id": [(6, 0, group_ids)], | ||
} | ||
) | ||
return user.id |
Oops, something went wrong.