changeset cfdaa6098b9f in modules/analytic_account:6.0
details:
https://hg.tryton.org/modules/analytic_account?cmd=changeset&node=cfdaa6098b9f
description:
Check roots of lines per company
issue10451
review363361004
(grafted from b5a31178eb1acb43900797411c9ca65336416144)
diffstat:
line.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diffs (33 lines):
diff -r 2249f78add8a -r cfdaa6098b9f line.py
--- a/line.py Mon May 03 15:41:22 2021 +0200
+++ b/line.py Fri May 28 09:03:22 2021 +0200
@@ -2,6 +2,7 @@
# this repository contains the full copyright notices and license terms.
from decimal import Decimal
from collections import defaultdict
+from itertools import groupby
from sql import Literal
@@ -258,8 +259,11 @@
roots = AnalyticAccount.search([
('parent', '=', None),
- ])
- roots = set(roots)
+ ],
+ order=[('company', 'ASC')])
+ company2roots = {
+ company: set(roots)
+ for company, roots in groupby(roots, key=lambda r: r.company)}
for line in lines:
if not line.must_have_analytic:
@@ -272,6 +276,7 @@
for analytic_line in line.analytic_lines:
amount = analytic_line.debit - analytic_line.credit
amounts[analytic_line.account.root] += amount
+ roots = company2roots[line.move.company]
if not roots <= set(amounts.keys()):
line.analytic_state = 'draft'
continue