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
[FIX] base: set parent company only once #147912
Conversation
f64a1f1
to
3e0ded8
Compare
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.
looks good if it's what we want (with comment taken into account)
3e0ded8
to
4ac5490
Compare
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
4ac5490
to
275a1d5
Compare
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.
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.
Yes. Changing the parent_id in any case is very likely to break things. |
Steps to reproduce:
Investigation:
The following commit b5d0001 changed the behavior to prevent changing/updating the company hierarchy -Parent > Child- with
odoo/odoo/addons/base/models/res_company.py
Lines 297 to 298 in a0741f6
opw-3660943