Skip to content

Conversation

antoine162
Copy link
Contributor

When loading a chart template on a root company, we check whether any journal items have already been created for the company, and if not, we delete the existing accounting configuration before loading the new CoA.

However, we must take care in the case of records that are shared between several companies, to just unlink them from the active company, rather than delete them (which would affect other companies as well).

This commit fixes that.

task-none

@antoine162 antoine162 requested a review from aboo-odoo October 21, 2024 08:57
@robodoo
Copy link
Contributor

robodoo commented Oct 21, 2024

Pull request status dashboard

@C3POdoo C3POdoo added the RD research & development, internal work label Oct 21, 2024
@antoine162
Copy link
Contributor Author

antoine162 commented Oct 21, 2024

can be merged already, but to unlink companies from shared accounts without error, we need #183695 that redoes the constraint. ready to merge

@antoine162 antoine162 removed the request for review from aboo-odoo October 22, 2024 11:47
@antoine162 antoine162 force-pushed the 18.0-account-chart-template-loading-do-not-delete-shared-accounts branch 2 times, most recently from 5a1b2ba to 275b89d Compare October 29, 2024 10:37
@antoine162 antoine162 force-pushed the 18.0-account-chart-template-loading-do-not-delete-shared-accounts branch 2 times, most recently from 41a094e to 8028907 Compare November 28, 2024 15:33
@antoine162 antoine162 force-pushed the 18.0-account-chart-template-loading-do-not-delete-shared-accounts branch from 8028907 to aab86cd Compare November 29, 2024 12:14
Comment on lines 212 to 215
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok if you need the groupby then, but this should work

Suggested change
for companies_to_unlink, records_for_companies in records_to_keep.grouped(lambda r: r.company_ids & children_companies).items():
if companies_to_unlink:
# Remove companies from shared records, but don't unlink them
records_for_companies.write({'company_ids': [Command.unlink(c.id) for c in companies_to_unlink]})
for records_for_companies in records_to_keep.grouped('company_ids').values():
records_for_companies.company_ids -= children_companies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does work, thanks so much! 😄

When loading a chart template on a root company, we check whether any
journal items have already been created for the company, and if not, we
delete the existing accounting configuration before loading the new CoA.

However, we must take care in the case of records that are shared
between several companies, to just unlink them from the active company,
rather than delete them (which would affect other companies as well).

This commit fixes that.

task-none
@antoine162 antoine162 force-pushed the 18.0-account-chart-template-loading-do-not-delete-shared-accounts branch from aab86cd to 4721f26 Compare November 29, 2024 14:24
Copy link
Contributor

@william-andre william-andre left a comment

Choose a reason for hiding this comment

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

@robodoo robodoo closed this in 2884302 Nov 30, 2024
@fw-bot fw-bot deleted the 18.0-account-chart-template-loading-do-not-delete-shared-accounts branch December 14, 2024 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RD research & development, internal work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants