-
-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[17.0][FIX] account_invoice_section_sale_order: FWD port and fix test-case #1871
Open
LucasTran380381
wants to merge
5
commits into
OCA:17.0
Choose a base branch
from
LucasTran380381:17.0-fix-account_invoice_section_sale_order
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66f44ba
account_invoice_section_sale_order: Fix read/write access
mmequignon 0b27584
account_invoice_section_sale_order: fix access right tests not running
simahawk 2f890a3
account_invoice_section_sale_order: fix access right on move line write
simahawk 678ad54
[FIX] account_invoice_section_sale_order check line_ids exists
sergiocorato 17292ca
[FIX] account_invoice_section_sale_order: fix test-case test_create_i…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,2 @@ | ||
from . import test_invoice_group_by_sale_order | ||
from . import test_access_rights |
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,84 @@ | ||
from odoo.tests import tagged | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
@tagged("-at_install", "post_install") | ||
class Common(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) | ||
cls.setUpClassOrder() | ||
|
||
@classmethod | ||
def setUpClassOrder(cls): | ||
cls.partner_1 = cls.env.ref("base.res_partner_1") | ||
cls.product_1 = cls.env.ref("product.product_product_1") | ||
cls.product_2 = cls.env.ref("product.product_product_2") | ||
cls.product_1.invoice_policy = "order" | ||
cls.product_2.invoice_policy = "order" | ||
cls.order1_p1 = cls.env["sale.order"].create( | ||
{ | ||
"partner_id": cls.partner_1.id, | ||
"partner_shipping_id": cls.partner_1.id, | ||
"partner_invoice_id": cls.partner_1.id, | ||
"client_order_ref": "ref123", | ||
"order_line": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": "order 1 line 1", | ||
"product_id": cls.product_1.id, | ||
"price_unit": 20, | ||
"product_uom_qty": 1, | ||
"product_uom": cls.product_1.uom_id.id, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": "order 1 line 2", | ||
"product_id": cls.product_2.id, | ||
"price_unit": 20, | ||
"product_uom_qty": 1, | ||
"product_uom": cls.product_1.uom_id.id, | ||
}, | ||
), | ||
], | ||
} | ||
) | ||
cls.order1_p1.action_confirm() | ||
cls.order2_p1 = cls.env["sale.order"].create( | ||
{ | ||
"partner_id": cls.partner_1.id, | ||
"partner_shipping_id": cls.partner_1.id, | ||
"partner_invoice_id": cls.partner_1.id, | ||
"order_line": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": "order 2 line 1", | ||
"product_id": cls.product_1.id, | ||
"price_unit": 20, | ||
"product_uom_qty": 1, | ||
"product_uom": cls.product_1.uom_id.id, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": "order 2 line 2", | ||
"product_id": cls.product_2.id, | ||
"price_unit": 20, | ||
"product_uom_qty": 1, | ||
"product_uom": cls.product_1.uom_id.id, | ||
}, | ||
), | ||
], | ||
} | ||
) | ||
cls.order2_p1.action_confirm() |
60 changes: 60 additions & 0 deletions
60
account_invoice_section_sale_order/tests/test_access_rights.py
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,60 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo.tests import tagged | ||
|
||
from .common import Common | ||
|
||
|
||
@tagged("-at_install", "post_install") | ||
class TestAccessRights(Common): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) | ||
cls.setUpClassUser() | ||
|
||
@classmethod | ||
def setUpClassUser(cls): | ||
cls.create_only_group = cls.env["res.groups"].create( | ||
{"name": "Create Only Group"} | ||
) | ||
cls.sale_manager_group = cls.env.ref("sales_team.group_sale_manager") | ||
cls.env["ir.model.access"].create( | ||
[ | ||
{ | ||
"name": "invoice_create_only", | ||
"model_id": cls.env.ref("account.model_account_move").id, | ||
"group_id": cls.create_only_group.id, | ||
"perm_read": 0, | ||
"perm_write": 0, | ||
"perm_create": 1, | ||
"perm_unlink": 0, | ||
}, | ||
{ | ||
"name": "invoice_line_create_only", | ||
"model_id": cls.env.ref("account.model_account_move_line").id, | ||
"group_id": cls.create_only_group.id, | ||
"perm_read": 0, | ||
"perm_write": 0, | ||
"perm_create": 1, | ||
"perm_unlink": 0, | ||
}, | ||
] | ||
) | ||
cls.create_only_user = cls.env["res.users"].create( | ||
{ | ||
"name": "Create Only User", | ||
"login": "[email protected]", | ||
"groups_id": [ | ||
(6, 0, (cls.create_only_group | cls.sale_manager_group).ids), | ||
], | ||
} | ||
) | ||
|
||
def test_access_rights(self): | ||
orders = self.order1_p1 + self.order2_p1 | ||
# We're testing that no exception is raised while creating invoices | ||
# with a user having only create access on the invoices models | ||
invoice_ids = orders.with_user(self.create_only_user)._create_invoices() | ||
self.assertTrue(bool(invoice_ids)) |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you removing this extra indent bit on purpose? I don't see it in the original fixes that you are porting here, but then again it was introduced in the migration of v15 (439ff49) and the fixes ported here are from 14.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It ported from commit
https://github.com/OCA/account-invoicing/pull/1774
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where in #1774 the extra indent is removed. Again, that patch is on 14.0 whereas the extra indent was only introduced in 15 if I understand correctly.