diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index ee3acf409ef..2d5793569f1 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4321,6 +4321,15 @@ class AccountPartialReconcile(models.Model): def _get_amount_tax_cash_basis(self, amount, line): return line.company_id.currency_id.round(amount) + def _set_tax_cash_basis_entry_date(self, move_date, newly_created_move): + if move_date > (self.company_id.period_lock_date or date.min) and newly_created_move.date != move_date: + # The move date should be the maximum date between payment and invoice (in case + # of payment in advance). However, we should make sure the move date is not + # recorded before the period lock date as the tax statement for this period is + # probably already sent to the estate. + newly_created_move.write({'date': move_date}) + newly_created_move.recompute(['name']) + def create_tax_cash_basis_entry(self, percentage_before_rec): self.ensure_one() move_date = self.debit_move_id.date @@ -4416,13 +4425,7 @@ class AccountPartialReconcile(models.Model): 'partner_id': line.partner_id.id, }) if newly_created_move: - if move_date > (self.company_id.period_lock_date or date.min) and newly_created_move.date != move_date: - # The move date should be the maximum date between payment and invoice (in case - # of payment in advance). However, we should make sure the move date is not - # recorded before the period lock date as the tax statement for this period is - # probably already sent to the estate. - newly_created_move.write({'date': move_date}) - newly_created_move.recompute(['name']) + self._set_tax_cash_basis_entry_date(move_date, newly_created_move) # post move newly_created_move.post()