[FIX] account: deterministic sorting
The aim of this commit is to make `get_lines_in_hierarchy` yielding the lines in the same order even if 2 sequences are the same. The additionnal diff correct the iteration to get it in the same order in copy than in `get_lines_in_hierarchy`. closes odoo/odoo#93156 Task: None Pr-community: https://github.com/odoo/odoo/pull/93061 X-original-commit: decc29d59baee1398a4497097055a2332e2305d7 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -54,11 +54,7 @@ class AccountTaxReport(models.Model):
|
||||
copied_report = super(AccountTaxReport, self).copy(default=copy_default) #This copies the report without its lines
|
||||
|
||||
lines_map = {} # maps original lines to their copies (using ids)
|
||||
lines_to_treat = list(self.line_ids.filtered(lambda x: not x.parent_id))
|
||||
while lines_to_treat:
|
||||
line = lines_to_treat.pop()
|
||||
lines_to_treat += list(line.children_line_ids)
|
||||
|
||||
for line in self.get_lines_in_hierarchy():
|
||||
copy = line.copy({'parent_id': lines_map.get(line.parent_id.id, None), 'report_id': copied_report.id})
|
||||
lines_map[line.id] = copy.id
|
||||
|
||||
@@ -69,10 +65,10 @@ class AccountTaxReport(models.Model):
|
||||
ar all directly followed by their children.
|
||||
"""
|
||||
self.ensure_one()
|
||||
lines_to_treat = list(self.line_ids.filtered(lambda x: not x.parent_id).sorted(lambda x: x.sequence)) # Used as a stack, whose index 0 is the top
|
||||
lines_to_treat = list(self.line_ids.filtered(lambda x: not x.parent_id)) # Used as a stack, whose index 0 is the top
|
||||
while lines_to_treat:
|
||||
to_yield = lines_to_treat[0]
|
||||
lines_to_treat = list(to_yield.children_line_ids.sorted(lambda x: x.sequence)) + lines_to_treat[1:]
|
||||
lines_to_treat = list(to_yield.children_line_ids) + lines_to_treat[1:]
|
||||
yield to_yield
|
||||
|
||||
def get_checks_to_perform(self, amounts, carried_over):
|
||||
@@ -95,7 +91,7 @@ class AccountTaxReport(models.Model):
|
||||
class AccountTaxReportLine(models.Model):
|
||||
_name = "account.tax.report.line"
|
||||
_description = 'Account Tax Report Line'
|
||||
_order = 'sequence'
|
||||
_order = 'sequence, id'
|
||||
_parent_store = True
|
||||
|
||||
name = fields.Char(
|
||||
|
||||
Reference in New Issue
Block a user