Skip to content
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

[FW][FIX] product: allow products to be used by branches #165307

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented May 13, 2024

Steps

  1. Have inventory installed.
  2. Have a product belonging to a company with a branch.
  3. Create a SO with this branch and add the product to it.
  4. Confirm the SO.
    ** Invalid Operation : incompatible companies on records **

Issue

While it is possible to add a product from a parent company to
a SO, we get an error when confirming the SO and creating the move because
of

self._check_company()

As the product_id field of stock.move has check_company=True, we have
an inconsistency because we are using the default domain of
_check_company_domain which is just the company itself.

odoo/odoo/models.py

Lines 3999 to 4007 in 3c7db87

def _check_company_domain(self, companies):
"""Domain to be used for company consistency between records regarding this model.
:param companies: the allowed companies for the related record
:type companies: BaseModel or list or tuple or int or unquote
"""
if not companies:
return [('company_id', '=', False)]
return ['|', ('company_id', '=', False), ('company_id', 'in', to_company_ids(companies))]

Fix

We provide a new _check_company_domain to product.product.
0479b2b made changes to allow products
to be used by branches, in particular this security rule:

<record id="product_comp_rule" model="ir.rule">
<field name="name" >Product multi-company</field>
<field name="model_id" ref="model_product_template"/>
<field name="domain_force"> ['|', ('company_id', 'parent_of', company_ids), ('company_id', '=', False)]</field>
</record>

opw-3815736

Forward-Port-Of: #165228
Forward-Port-Of: #160899

Steps
-----
1. Have inventory installed.
2. Have a product belonging to a company with a branch.
3. Create a SO with this branch and add the product to it.
4. Confirm the SO.
** Invalid Operation : incompatible companies on records **

Issue
-----
While it is possible to add a product from a parent company to
a SO, we get an error when confirming the SO and creating the move because
of
https://github.com/odoo/odoo/blob/1b0dbb3645ad8b52c5260f1cbbc4f6bdee48461e/addons/stock/models/stock_move.py#L1358
As the product_id field of stock.move has check_company=True, we have
an inconsistency because we are using the default domain of
_check_company_domain which is just the company itself.
https://github.com/odoo/odoo/blob/3c7db87ade7e99eafb44228bd038fa39429fdabc/odoo/models.py#L3999-L4007

Fix
-----
We provide a new _check_company_domain to product.product and product.template
0479b2b made changes to allow products
to be used by branches, in particular this security rule:
https://github.com/odoo/odoo/blob/5a801bc60209713a3ba5313debb4daa05c4e2405/addons/product/security/product_security.xml#L34-L38

opw-3815736

X-original-commit: 70bf644
@robodoo
Copy link
Contributor

robodoo commented May 13, 2024

@fw-bot
Copy link
Contributor Author

fw-bot commented May 13, 2024

@taqu-odoo @william-andre this PR targets master and is the last of the forward-port chain.

To merge the full chain, use

@fw-bot r+

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

@robodoo robodoo added the forwardport This PR was created by @fw-bot label May 13, 2024
@william-andre
Copy link
Contributor

@fw-bot r+

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label May 13, 2024
robodoo pushed a commit that referenced this pull request May 13, 2024
Steps
-----
1. Have inventory installed.
2. Have a product belonging to a company with a branch.
3. Create a SO with this branch and add the product to it.
4. Confirm the SO.
** Invalid Operation : incompatible companies on records **

Issue
-----
While it is possible to add a product from a parent company to
a SO, we get an error when confirming the SO and creating the move because
of
https://github.com/odoo/odoo/blob/1b0dbb3645ad8b52c5260f1cbbc4f6bdee48461e/addons/stock/models/stock_move.py#L1358
As the product_id field of stock.move has check_company=True, we have
an inconsistency because we are using the default domain of
_check_company_domain which is just the company itself.
https://github.com/odoo/odoo/blob/3c7db87ade7e99eafb44228bd038fa39429fdabc/odoo/models.py#L3999-L4007

Fix
-----
We provide a new _check_company_domain to product.product and product.template
0479b2b made changes to allow products
to be used by branches, in particular this security rule:
https://github.com/odoo/odoo/blob/5a801bc60209713a3ba5313debb4daa05c4e2405/addons/product/security/product_security.xml#L34-L38

opw-3815736

closes #165307

X-original-commit: 70bf644
Signed-off-by: William André (wan) <wan@odoo.com>
robodoo pushed a commit that referenced this pull request May 13, 2024
Steps
-----
1. Have inventory installed.
2. Have a product belonging to a company with a branch.
3. Create a SO with this branch and add the product to it.
4. Confirm the SO.
** Invalid Operation : incompatible companies on records **

Issue
-----
While it is possible to add a product from a parent company to
a SO, we get an error when confirming the SO and creating the move because
of
https://github.com/odoo/odoo/blob/1b0dbb3645ad8b52c5260f1cbbc4f6bdee48461e/addons/stock/models/stock_move.py#L1358
As the product_id field of stock.move has check_company=True, we have
an inconsistency because we are using the default domain of
_check_company_domain which is just the company itself.
https://github.com/odoo/odoo/blob/3c7db87ade7e99eafb44228bd038fa39429fdabc/odoo/models.py#L3999-L4007

Fix
-----
We provide a new _check_company_domain to product.product and product.template
0479b2b made changes to allow products
to be used by branches, in particular this security rule:
https://github.com/odoo/odoo/blob/5a801bc60209713a3ba5313debb4daa05c4e2405/addons/product/security/product_security.xml#L34-L38

opw-3815736

closes #165307

X-original-commit: 70bf644
Signed-off-by: William André (wan) <wan@odoo.com>
robodoo pushed a commit that referenced this pull request May 14, 2024
Steps
-----
1. Have inventory installed.
2. Have a product belonging to a company with a branch.
3. Create a SO with this branch and add the product to it.
4. Confirm the SO.
** Invalid Operation : incompatible companies on records **

Issue
-----
While it is possible to add a product from a parent company to
a SO, we get an error when confirming the SO and creating the move because
of
https://github.com/odoo/odoo/blob/1b0dbb3645ad8b52c5260f1cbbc4f6bdee48461e/addons/stock/models/stock_move.py#L1358
As the product_id field of stock.move has check_company=True, we have
an inconsistency because we are using the default domain of
_check_company_domain which is just the company itself.
https://github.com/odoo/odoo/blob/3c7db87ade7e99eafb44228bd038fa39429fdabc/odoo/models.py#L3999-L4007

Fix
-----
We provide a new _check_company_domain to product.product and product.template
0479b2b made changes to allow products
to be used by branches, in particular this security rule:
https://github.com/odoo/odoo/blob/5a801bc60209713a3ba5313debb4daa05c4e2405/addons/product/security/product_security.xml#L34-L38

opw-3815736

closes #165307

X-original-commit: 70bf644
Signed-off-by: William André (wan) <wan@odoo.com>
@robodoo robodoo closed this May 14, 2024
@robodoo robodoo added the 17.3 label May 14, 2024
zel-odoo pushed a commit to odoo-dev/odoo that referenced this pull request May 24, 2024
Steps
-----
1. Have inventory installed.
2. Have a product belonging to a company with a branch.
3. Create a SO with this branch and add the product to it.
4. Confirm the SO.
** Invalid Operation : incompatible companies on records **

Issue
-----
While it is possible to add a product from a parent company to
a SO, we get an error when confirming the SO and creating the move because
of
https://github.com/odoo/odoo/blob/1b0dbb3645ad8b52c5260f1cbbc4f6bdee48461e/addons/stock/models/stock_move.py#L1358
As the product_id field of stock.move has check_company=True, we have
an inconsistency because we are using the default domain of
_check_company_domain which is just the company itself.
https://github.com/odoo/odoo/blob/3c7db87ade7e99eafb44228bd038fa39429fdabc/odoo/models.py#L3999-L4007

Fix
-----
We provide a new _check_company_domain to product.product and product.template
0479b2b made changes to allow products
to be used by branches, in particular this security rule:
https://github.com/odoo/odoo/blob/5a801bc60209713a3ba5313debb4daa05c4e2405/addons/product/security/product_security.xml#L34-L38

opw-3815736

closes odoo#165307

X-original-commit: 70bf644
Signed-off-by: William André (wan) <wan@odoo.com>
@fw-bot fw-bot deleted the master-17.0-opw-3815736-stock_product_branch-taqu-x7nO-fw branch May 28, 2024 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
17.3 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.

None yet

5 participants