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.

34 lines
1.2 KiB

9 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2016 Acsone SA/NV (http://www.acsone.eu)
  3. # © 2016 Eficent Business and IT Consulting Services S.L.
  4. # (http://www.eficent.com)
  5. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  6. from openerp import api, models
  7. class PosOrder(models.Model):
  8. _inherit = "pos.order"
  9. @api.model
  10. def sequence_number_sync(self, vals):
  11. next = vals.get('_sequence_ref_number', False)
  12. next = int(next) if next else False
  13. if vals.get('session_id') and next is not False:
  14. session = self.env['pos.session'].browse(vals['session_id'])
  15. if next != session.config_id.sequence_id.number_next_actual:
  16. session.config_id.sequence_id.number_next_actual = next
  17. if vals.get('_sequence_ref_number') is not None:
  18. del vals['_sequence_ref_number']
  19. @api.model
  20. def _order_fields(self, ui_order):
  21. vals = super(PosOrder, self)._order_fields(ui_order)
  22. vals['_sequence_ref_number'] = ui_order.get('sequence_ref_number')
  23. return vals
  24. @api.model
  25. def create(self, vals):
  26. self.sequence_number_sync(vals)
  27. order = super(PosOrder, self).create(vals)
  28. return order