Set a period from the company of the receivable rule creating move

Closes #13740
This commit is contained in:
Cédric Krier committed 2024-12-08 11:41:03 +01:00
1 parent 58647f9ee7
commit 54672a40a9
1 file changed
+16
@@ -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