From 54672a40a9d902c03097eceae8a56b9e3e615764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 8 Dec 2024 11:41:03 +0100 Subject: [PATCH] Set a period from the company of the receivable rule creating move Closes #13740 --- modules/account_receivable_rule/account.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/account_receivable_rule/account.py b/modules/account_receivable_rule/account.py index 2211d64cf4..0f498630fe 100644 --- a/modules/account_receivable_rule/account.py +++ b/modules/account_receivable_rule/account.py @@ -158,12 +158,20 @@ class AccountRuleAbstract(DeactivableMixin, ModelSQL, ModelView): def _reconcile(self, line, amount, delegate=None): pool = Pool() + Date = pool.get('ir.date') Move = pool.get('account.move') Line = pool.get('account.move.line') + Period = pool.get('account.period') debit, credit = self._debit_credit(amount) + with Transaction().set_context(company=self.company.id): + date = Date.today() + period = Period.find(self.company, date=date) + move = Move( journal=self.journal, + period=period, + date=date, origin=self, company=self.company, ) @@ -207,10 +215,16 @@ class AccountRuleAbstract(DeactivableMixin, ModelSQL, ModelView): def _move_overflow(self, amount, party): pool = Pool() + Date = pool.get('ir.date') Line = pool.get('account.move.line') Move = pool.get('account.move') + Period = pool.get('account.period') debit, credit = self._debit_credit(amount) + with Transaction().set_context(company=self.company.id): + date = Date.today() + period = Period.find(self.company, date=date) + lines = [ Line( account=self.account, @@ -227,6 +241,8 @@ class AccountRuleAbstract(DeactivableMixin, ModelSQL, ModelView): ] move = Move( journal=self.journal, + period=period, + date=date, origin=self, company=self.company, lines=lines