summaryrefslogtreecommitdiff
path: root/odoo/addons/base/models/ir_sequence.py
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-01-02 09:23:08 +0000
committerNicolas Martinelli <nim@odoo.com>2020-01-02 12:49:13 +0000
commitdc55cc6468bf9d2fddc47cb5f135af7016ed2a50 (patch)
tree3d1c7cb17b26617378c382dbb0bc57d4ef20e6a9 /odoo/addons/base/models/ir_sequence.py
parent3a541a8ae1aa272847f71829dc5e8af512472d20 (diff)
[FIX] base, account: fix test for 2020
When `invoice_sequence_number_next` is set in [1], the move date is not taken into account to find a corresponding `ir.sequence.date_range` in [2]. We use the current date instead. However, when the move is posted we use its date to find the `ir.sequence.date_range` [3]. This leads to an inconsistency: we set `invoice_sequence_number_next` on the `ir.sequence.date_range` of the current date, but at posting we use the `ir.sequence.date_range` of the move date. The fix is to take into account the move date when we set `invoice_sequence_number_next`. [1] https://github.com/odoo/odoo/blob/40c8da4bd47d99a97b7231f2749c8e981f35a1a0/addons/account/tests/test_account_move_in_invoice.py#L829 [2] https://github.com/odoo/odoo/blob/40c8da4bd47d99a97b7231f2749c8e981f35a1a0/addons/account/models/account_move.py#L1153 [3] https://github.com/odoo/odoo/blob/40c8da4bd47d99a97b7231f2749c8e981f35a1a0/addons/account/models/account_move.py#L2096 closes odoo/odoo#42580 X-original-commit: 45d126405b030610fc66b8557a668f0d61e129dc Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'odoo/addons/base/models/ir_sequence.py')
-rw-r--r--odoo/addons/base/models/ir_sequence.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/odoo/addons/base/models/ir_sequence.py b/odoo/addons/base/models/ir_sequence.py
index df68bee0454..67a9329c1ec 100644
--- a/odoo/addons/base/models/ir_sequence.py
+++ b/odoo/addons/base/models/ir_sequence.py
@@ -100,20 +100,20 @@ class IrSequence(models.Model):
seq.write({'number_next': seq.number_next_actual or 1})
@api.model
- def _get_current_sequence(self):
+ def _get_current_sequence(self, sequence_date=None):
'''Returns the object on which we can find the number_next to consider for the sequence.
It could be an ir.sequence or an ir.sequence.date_range depending if use_date_range is checked
or not. This function will also create the ir.sequence.date_range if none exists yet for today
'''
if not self.use_date_range:
return self
- now = fields.Date.today()
+ sequence_date = sequence_date or fields.Date.today()
seq_date = self.env['ir.sequence.date_range'].search(
- [('sequence_id', '=', self.id), ('date_from', '<=', now), ('date_to', '>=', now)], limit=1)
+ [('sequence_id', '=', self.id), ('date_from', '<=', sequence_date), ('date_to', '>=', sequence_date)], limit=1)
if seq_date:
return seq_date[0]
#no date_range sequence was found, we create a new one
- return self._create_date_range_seq(now)
+ return self._create_date_range_seq(sequence_date)
name = fields.Char(required=True)
code = fields.Char(string='Sequence Code')