pos_table.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 OpenSynergy Indonesia
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import models, fields, api
  5. class PosTable(models.Model):
  6. _name = "pos.table"
  7. _description = "PoS Table"
  8. name = fields.Char(string="Nombre")
  9. employee_id = fields.Many2one(
  10. string="Chofer",
  11. comodel_name="hr.employee"
  12. )
  13. floor_id = fields.Many2one(
  14. string="Agrupado por",
  15. comodel_name="pos.floor",
  16. required=True,
  17. )
  18. type = fields.Selection([
  19. ('table','Mesa'),
  20. ('delivery','Delivery')],
  21. string="Tipo",
  22. required=True,
  23. related="floor_id.type"
  24. )
  25. capacity = fields.Integer(
  26. string="Capacidad",
  27. )
  28. state = fields.Selection(
  29. string="Estado",
  30. selection=[
  31. ("available", "Disponible"),
  32. ("vacant", "Vacant"),
  33. ("reserved", "Reservado"),
  34. ],
  35. required=True,
  36. default="available",
  37. )
  38. @api.one
  39. @api.onchange('employee_id')
  40. def onchange_employee_id(self):
  41. if self.employee_id:
  42. self.name = self.employee_id.name_related