-
Notifications
You must be signed in to change notification settings - Fork 30.1k
[FIX] account: When loading chart template, don't unlink shared records #184450
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] account: When loading chart template, don't unlink shared records #184450
Conversation
|
5a1b2ba
to
275b89d
Compare
41a094e
to
8028907
Compare
8028907
to
aab86cd
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.
Ok if you need the groupby then, but this should work
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 |
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.
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
aab86cd
to
4721f26
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.
@robodoo r+
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