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