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

[FIX] base: set parent company only once #147912

Conversation

AH-Yussef
Copy link
Contributor

Steps to reproduce:

  • Go to Settings > Users & Companies > Companies
  • Create a new company called Child Company
  • Create a new company called Parent Company
  • Go to the Child Company
  • In General Information tab, set the Parent Company property to Parent Company
  • An Error is raised stating that "The company hierarchy cannot be changed."

Investigation:

The following commit b5d0001 changed the behavior to prevent changing/updating the company hierarchy -Parent > Child- with

if 'parent_id' in values:
raise UserError(_("The company hierarchy cannot be changed."))

opw-3660943

@AH-Yussef AH-Yussef self-assigned this Jan 3, 2024
@robodoo
Copy link
Contributor

robodoo commented Jan 3, 2024

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jan 3, 2024
@AH-Yussef AH-Yussef force-pushed the 17.0-opw-3660943-set_parent_company_only_once-alhy branch 3 times, most recently from f64a1f1 to 3e0ded8 Compare January 3, 2024 15:58
Copy link
Contributor

@nle-odoo nle-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good if it's what we want (with comment taken into account)

odoo/addons/base/tests/test_res_company.py Outdated Show resolved Hide resolved
odoo/addons/base/tests/test_res_company.py Outdated Show resolved Hide resolved
odoo/addons/base/models/res_company.py Outdated Show resolved Hide resolved
odoo/addons/base/tests/test_res_company.py Outdated Show resolved Hide resolved
@AH-Yussef AH-Yussef force-pushed the 17.0-opw-3660943-set_parent_company_only_once-alhy branch from 3e0ded8 to 4ac5490 Compare January 5, 2024 07:45
Steps to reproduce:
- Go to Settings > Users & Companies > Companies
- Create a new company called Child Company
- Create a new company called Parent Company
- Go to the Child Company
- In Gneral Information tab, set the Parent Company property to Paretn Company
- An Error is raised stating that "The company hierarchy cannot be changed."

Investigation:
The following commit odoo@b5d0001 changed the behavior to prevent changing/updating the company hierarchy -Parent > Child- with https://github.com/odoo/odoo/blob/a0741f6427514be5246a5476b5c2f1ca1c23e6e5/odoo/addons/base/models/res_company.py#L297-L298

opw-3660943
@AH-Yussef AH-Yussef force-pushed the 17.0-opw-3660943-set_parent_company_only_once-alhy branch from 4ac5490 to 275a1d5 Compare January 9, 2024 10:06
@AH-Yussef AH-Yussef marked this pull request as ready for review January 9, 2024 11:02
@C3POdoo C3POdoo requested review from a team, xmo-odoo and rco-odoo and removed request for a team January 9, 2024 11:03
Copy link
Member

@rco-odoo rco-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not look good to me. You have to think about the potential consequences.

There was a good reason for not changing the hierarchy. Assume you create both root companies A and B, like in your scenario. Then you instantiate a chart of accounts for each company. Then you make company B become a child of company A. And boom! you just fucked up the accounting, because the new accounting rules state that company B must use company A's chart of accounts. @william-andre can you confirm my claim?

IMO the right way to create the companies is:

  • create the parent company first,
  • create the child company with the right parent.

@william-andre
Copy link
Contributor

Yes. Changing the parent_id in any case is very likely to break things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

6 participants