[FIX] account: extract code into method to allow changing the date of the tax
Before this commit, when two lines belonging to a period that is already closed a cash basis entry is created at the present date. There are localizations that could not allow creating the cash basis entry in a date other than the maximum between the Journal Items being reconciled. Now, the localizations are able to override and chose the date without having to override the whole 'create_tax_cash_basis_entry' method. opw-2195016 closes odoo/odoo#46661 X-original-commit: 2d3ab28c22c8ad5f9ed379e6b49697822e01a002 Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
committed by
Jorge Pinna Puissant
parent
0e11d7383c
commit
39c4d122a2
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user