You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
804 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, models
  5. class IrSequenceDateRange(models.Model):
  6. _inherit = 'ir.sequence.date_range'
  7. @api.multi
  8. def _next(self):
  9. """
  10. Inherit to use the date_to (instead of date_from) as the base date
  11. :return: str
  12. """
  13. seq_date_range = self.env.context.get('ir_sequence_date_range')
  14. if seq_date_range and self.sequence_id.date_range_field:
  15. expected_value = self[self.sequence_id.date_range_field]
  16. if seq_date_range != expected_value:
  17. self = self.with_context(ir_sequence_date_range=expected_value)
  18. return super(IrSequenceDateRange, self)._next()