models.py 776 B

12345678910111213141516171819202122
  1. from openerp import api, fields, models
  2. class res_users(models.Model):
  3. _inherit = 'res.users'
  4. is_delivery = fields.Boolean(string="Delivery ?")
  5. class pos_order(models.Model):
  6. _inherit = 'pos.order'
  7. pos_delivery = fields.Many2one(comodel_name='res.users', string="Delivery Driver",
  8. domain=[('is_delivery', '=', True)])
  9. def _order_fields(self, cr, uid, ui_order, context=None):
  10. return {
  11. 'name': ui_order['name'],
  12. 'user_id': ui_order['user_id'] or False,
  13. 'session_id': ui_order['pos_session_id'],
  14. 'lines': ui_order['lines'],
  15. 'pos_reference':ui_order['name'],
  16. 'partner_id': ui_order['partner_id'] or False,
  17. "pos_delivery": ui_order['pos_delivery'],
  18. }