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.

79 lines
2.5 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api, _
  3. import logging
  4. _logger = logging.getLogger(__name__)
  5. class BeesPOS(models.Model):
  6. _inherit = 'pos.config'
  7. bill_value = fields.One2many('bill_value', 'pos', copy=True)
  8. class BillValue(models.Model):
  9. _name = 'bill_value'
  10. _order = 'name asc'
  11. name = fields.Float(string='Name')
  12. pos = fields.Many2one('pos.config')
  13. class BeesAccountBankStatement(models.Model):
  14. _inherit = 'account.bank.statement.cashbox'
  15. def _get_default_line(self):
  16. if not self.env.context.get('active_id'):
  17. return []
  18. pos_session_rec = self.env['pos.session'].browse(self.env.context['active_id'])
  19. return [(0, 0, {'coin_value' : bill_value_rec.name, 'subtotal':0.0}) for bill_value_rec in pos_session_rec.config_id.bill_value]
  20. cashbox_lines_ids = fields.One2many(default=_get_default_line)
  21. class BeescoopPosOrder(models.Model):
  22. _inherit = 'pos.order'
  23. print_status = fields.Selection([('no_print', 'Do not Print'),
  24. ('to_print', 'To print'),
  25. ('printed', 'Printed')],
  26. default="no_print", string="Print Status")
  27. @api.model
  28. def send_order(self, receipt_name):
  29. order = self.search([('pos_reference', '=', receipt_name)])
  30. if not order:
  31. return _('Error: no order found')
  32. if not order.partner_id.email:
  33. return _('Cannot send the ticket, no email address found on the client')
  34. order.print_status = 'to_print'
  35. return _("Ticket will be sent")
  36. @api.model
  37. def _send_order_cron(self):
  38. mail_template = self.env.ref("beesdoo_pos.email_send_ticket")
  39. _logger.info("Start to send ticket")
  40. for order in self.search([('print_status', '=', 'to_print')]):
  41. if not order.partner_id.email:
  42. continue
  43. mail_template.send_mail(order.id, force_send=True)
  44. order.print_status = 'printed'
  45. #Make sure we commit the change to not send ticket twice
  46. self.env.cr.commit()
  47. class BeescoopPosPartner(models.Model):
  48. _inherit = 'res.partner'
  49. def _get_eater(self):
  50. eaters = [False, False, False]
  51. for i, eater in enumerate(self.child_eater_ids):
  52. eaters[i] = eater.name
  53. return tuple(eaters)
  54. @api.multi
  55. def get_eater(self):
  56. eater1, eater2, eater3 = self._get_eater()
  57. return eater1, eater2, eater3
  58. last_name = fields.Char('Last Name', required=True, default="/")