summaryrefslogtreecommitdiff
path: root/addons/account/models/account_bank_statement.py
diff options
context:
space:
mode:
authorwan <wan@odoo.com>2020-11-06 14:49:32 +0000
committerwan <wan@odoo.com>2020-11-06 15:03:16 +0000
commitb863b9cfedb3e7b4d1e3d409c829ffa0bfa1d9bb (patch)
tree2b6a93af124595b85cfbbbd3dc250e7ddade559c /addons/account/models/account_bank_statement.py
parentb2a07e4d08beff360ac1e6c95d240a15b1081855 (diff)
[FIX] account: deduce sequence reset
The order to find when to reset the sequence needs to be the following: * find a sequence used before the date of this move * if there isn't any, find the sequence of any move Because we were not looking at the second step for bank statements, we could have an issue since we were not checking the sequence relative to the correct date. closes odoo/odoo#61486 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Diffstat (limited to 'addons/account/models/account_bank_statement.py')
-rw-r--r--addons/account/models/account_bank_statement.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 3f620eed143..e3726860b71 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -460,8 +460,12 @@ class AccountBankStatement(models.Model):
where_string = "WHERE journal_id = %(journal_id)s AND name != '/'"
param = {'journal_id': self.journal_id.id}
- sequence_number_reset = self._deduce_sequence_number_reset(self.search([('date', '<', self.date)], order='date desc', limit=1).name)
if not relaxed:
+ domain = [('journal_id', '=', self.journal_id.id), ('id', '!=', self.id or self._origin.id), ('name', '!=', False)]
+ previous_name = self.search(domain + [('date', '<', self.date)], order='date desc', limit=1).name
+ if not previous_name:
+ previous_name = self.search(domain, order='date desc', limit=1).name
+ sequence_number_reset = self._deduce_sequence_number_reset(previous_name)
if sequence_number_reset == 'year':
where_string += " AND date_trunc('year', date) = date_trunc('year', %(date)s) "
param['date'] = self.date