From 6838edb95bb125ae8f5b9d488348ed5fa0094db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 31 Aug 2018 14:58:05 +0200 Subject: [PATCH] Add support for chart of account evolution * Add replacement account * Add period on account and tax code issue7417 review45671002 --- commission.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/commission.py b/commission.py index 99b8abd3ef..29a237f8b0 100644 --- a/commission.py +++ b/commission.py @@ -5,6 +5,7 @@ from trytond.pool import PoolMeta, Pool from trytond.model import ModelView, fields from trytond.pyson import Eval, Bool +from trytond.transaction import Transaction __all__ = ['Agent', 'Commission'] @@ -75,14 +76,15 @@ class Commission(metaclass=PoolMeta): amount = Currency.compute(self.currency, self.amount, self.agent.company.currency) line = Line() - if self.type_ == 'in': - line.credit = amount if amount > 0 else 0 - line.debit = amount if amount < 0 else 0 - line.account = self.product.account_revenue_used - else: - line.debit = amount if amount > 0 else 0 - line.credit = amount if amount < 0 else 0 - line.account = self.product.account_expense_used + with Transaction().set_context(date=date): + if self.type_ == 'in': + line.credit = amount if amount > 0 else 0 + line.debit = amount if amount < 0 else 0 + line.account = self.product.account_revenue_used + else: + line.debit = amount if amount > 0 else 0 + line.credit = amount if amount < 0 else 0 + line.account = self.product.account_expense_used if line.account.party_required: line.party = self.agent.party # XXX second currency?