-
-
Notifications
You must be signed in to change notification settings - Fork 844
[17.0][MIG] purchase_analytic_global: Migration to 17.0 #2668
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
base: 17.0
Are you sure you want to change the base?
[17.0][MIG] purchase_analytic_global: Migration to 17.0 #2668
Conversation
An analytic account field on the purchase order that applies the account on all the lines of the purchase order.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: purchase-workflow-14.0/purchase-workflow-14.0-purchase_analytic_global Translate-URL: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_analytic_global/
Currently translated at 100.0% (3 of 3 strings) Translation: purchase-workflow-15.0/purchase-workflow-15.0-purchase_analytic_global Translate-URL: https://translation.odoo-community.org/projects/purchase-workflow-15-0/purchase-workflow-15-0-purchase_analytic_global/es/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: purchase-workflow-15.0/purchase-workflow-15.0-purchase_analytic_global Translate-URL: https://translation.odoo-community.org/projects/purchase-workflow-15-0/purchase-workflow-15-0-purchase_analytic_global/
6988300
to
4d1247f
Compare
def _compute_analytic_distribution(self): | ||
"""If all order line have same analytic distribution set analytic_distribution. | ||
If no lines, respect value given by the user. | ||
""" | ||
for rec in self: | ||
if rec.order_line: | ||
al = rec.order_line[0].analytic_distribution or False | ||
for ol in rec.order_line: | ||
if ol.analytic_distribution != al: | ||
al = False | ||
break | ||
rec.analytic_distribution = al |
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.
hello @Luca-Policastro
what do you think about such an approach from v18 solving the same issue:
https://github.com/OCA/purchase-workflow/blob/18.0/purchase_analytic_global/models/purchase_order.py
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.
Please squash the last 2 commits
for rec in self: | ||
if rec.order_line: | ||
al = rec.order_line[0].analytic_distribution or False | ||
for ol in rec.order_line: | ||
if ol.analytic_distribution != al: | ||
al = False | ||
break | ||
rec.analytic_distribution = al |
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.
for rec in self: | |
if rec.order_line: | |
al = rec.order_line[0].analytic_distribution or False | |
for ol in rec.order_line: | |
if ol.analytic_distribution != al: | |
al = False | |
break | |
rec.analytic_distribution = al | |
for po in self: | |
if lines := po.order_line: | |
distributions = set(ln.analytic_distribution for ln in lines) | |
if len(distributions) == 1: | |
po.analytic_distribution = tuple(distributions)[0] | |
else: | |
po.analytic_distribution = False |
@api.onchange("analytic_distribution") | ||
def _onchange_analytic_distribution(self): | ||
"""When change analytic_distribution | ||
set analytic distribution on all order lines""" | ||
if self.analytic_distribution: | ||
self.order_line.update( | ||
{"analytic_distribution": self.analytic_distribution} | ||
) |
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.
Isn't this equivalent to the inverse
method that's already in place?
4d1247f
to
0e35cca
Compare
Migration done from #2393