From 0083253dddf430b9f3172ef20c79d4f45b2f5d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 23 Jan 2022 12:54:56 +0100 Subject: [PATCH] Ensure to set correct company context when calling today issue11046 review370421002 --- account.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/account.py b/account.py index 0556167586..7e15e22b1c 100644 --- a/account.py +++ b/account.py @@ -1,6 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. from decimal import ROUND_DOWN, ROUND_HALF_EVEN, Decimal +from itertools import groupby from operator import itemgetter from trytond import backend @@ -403,6 +404,12 @@ class LandedCost(Workflow, ModelSQL, ModelView, MatchMixin): landed_cost._stock_move_filter_unused(stock_moves) getattr(landed_cost, 'allocate_cost_by_%s' % landed_cost.allocation_method)() + for company, c_landed_costs in groupby( + landed_costs, key=lambda l: l.company): + with Transaction().set_context(company=company.id): + today = Date.today() + for landed_cost in c_landed_costs: + landed_cost.posted_date = today landed_cost.posted_date = today # Use save as allocate methods may modify the records cls.save(landed_costs)