Skip to content

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Jan 29, 2024

The account module adds the tax_string field to product forms:

<span class="ml-2"/><field name="tax_string"/>

That field calls Model(account.tax).compute_all():

res = self.taxes_id.compute_all(price, product=self, partner=self.env['res.partner'])

That method needs access to account.account.tag records:

product_tag_ids = product.account_tag_ids.ids if product else []
repartition_line_tags = repartition_line.tag_ids
'tag_ids': (repartition_line_tags + subsequent_tags).ids + product_tag_ids,
'base_tags': base_rep_lines.tag_ids.ids + product_tag_ids,

Internal users were able to read account.tax and account.tax.repartition.line records, but they couldn't read account.account.tag records.

So, this lead to the absurd situation where a user with permissions to read products (like stock, PoS or event users) couldn't be able to see the product form anymore whenever that product happened to have a tax with a repartition line with a tag:

2023-12-12.11-59-50.mp4

This is a regression from Odoo 14, introduced in #74138 and #73602.

I'm granting all internal users read permission over account.account.tag, just like the one they have for account.tax and account.tax.repartition.line. BTW that's the fix suggested by Odoo helpdesk.

@moduon MT-4390
OPW-3636032


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #149306
Forward-Port-Of: #146787

@robodoo
Copy link
Contributor

robodoo commented Jan 29, 2024

Pull request status dashboard.

@fw-bot
Copy link
Contributor Author

fw-bot commented Jan 29, 2024

@yajo @csnauwaert cherrypicking of pull request #146787 failed.

stdout:

Auto-merging addons/account/security/ir.model.access.csv
Auto-merging addons/account/tests/__init__.py
Auto-merging addons/mrp/models/product.py
CONFLICT (content): Merge conflict in addons/mrp/models/product.py

stderr:

17:33:12.718982 git.c:463               trace: built-in: git cherry-pick 4b286e9820c61fcda55d1a51f1a6fbd163005a93
error: could not apply 4b286e9820c6... [FIX] account: allow users to see products after configuring taxes
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
----------
status:

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added forwardport This PR was created by @fw-bot conflict There was an error while creating this forward-port PR labels Jan 29, 2024
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jan 29, 2024
The `account` module adds the `tax_string` field to product forms:
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/views/product_view.xml#L76

That field calls `Model(account.tax).compute_all()`:
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/product.py#L71

That method needs access to `account.account.tag` records:
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L563
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L632
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L648
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L671

Internal users were able to read `account.tax` and `account.tax.repartition.line` records, but they couldn't read `account.account.tag` records.

So, this lead to the absurd situation where a user with permissions to read products (like stock, PoS or event users) couldn't be able to see the product form anymore whenever that product happened to have a tax with a repartition line with a tag.

This is a regression from Odoo 14, introduced in odoo#74138 and odoo#73602.

I'm granting all internal users read permission over `account.account.tag`, just like the one they have for `account.tax` and `account.tax.repartition.line`. BTW that's the fix suggested by Odoo helpdesk.

Funny enough, while exercising the test, I also noticed that a similar situation happens with MRP. When installed, other users that would normally be able to browse products, would no longer have access. The fix is incouded too; otherwise the test wouldn't pass.

@moduon MT-4390
OPW-3636032

X-original-commit: 9c7028b
@csnauwaert csnauwaert force-pushed the saas-16.2-15.0-account-fix_tag_access-eaw0-fw branch from ac76ab2 to b39ba3f Compare January 31, 2024 08:47
@csnauwaert
Copy link
Contributor

@robodoo r+

robodoo pushed a commit that referenced this pull request Jan 31, 2024
The `account` module adds the `tax_string` field to product forms:
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/views/product_view.xml#L76

That field calls `Model(account.tax).compute_all()`:
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/product.py#L71

That method needs access to `account.account.tag` records:
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L563
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L632
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L648
https://github.com/odoo/odoo/blob/ceb8b785fba1055deeff8d9075ccc707f2317278/addons/account/models/account_tax.py#L671

Internal users were able to read `account.tax` and `account.tax.repartition.line` records, but they couldn't read `account.account.tag` records.

So, this lead to the absurd situation where a user with permissions to read products (like stock, PoS or event users) couldn't be able to see the product form anymore whenever that product happened to have a tax with a repartition line with a tag.

This is a regression from Odoo 14, introduced in #74138 and #73602.

I'm granting all internal users read permission over `account.account.tag`, just like the one they have for `account.tax` and `account.tax.repartition.line`. BTW that's the fix suggested by Odoo helpdesk.

Funny enough, while exercising the test, I also noticed that a similar situation happens with MRP. When installed, other users that would normally be able to browse products, would no longer have access. The fix is incouded too; otherwise the test wouldn't pass.

@moduon MT-4390
OPW-3636032

closes #151639

X-original-commit: 9c7028b
Signed-off-by: Cedric Snauwaert <csn@odoo.com>
@robodoo robodoo closed this Jan 31, 2024
@fw-bot fw-bot deleted the saas-16.2-15.0-account-fix_tag_access-eaw0-fw branch February 14, 2024 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants