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.

97 lines
3.3 KiB

  1. from odoo import models, fields, api, _
  2. import logging
  3. _logger = logging.getLogger(__name__)
  4. class BeesPOS(models.Model):
  5. _inherit = 'pos.config'
  6. bill_value = fields.One2many('bill_value', 'pos', copy=True)
  7. class BillValue(models.Model):
  8. _name = 'bill_value'
  9. _order = 'name asc'
  10. name = fields.Float(string='Name')
  11. pos = fields.Many2one('pos.config')
  12. class BeesAccountBankStatement(models.Model):
  13. _inherit = 'account.bank.statement.cashbox'
  14. def _get_default_line(self):
  15. if not self.env.context.get('active_id'):
  16. return []
  17. pos_session_rec = self.env['pos.session'].browse(self.env.context['active_id'])
  18. return [(0, 0, {'coin_value' : bill_value_rec.name, 'subtotal':0.0}) for bill_value_rec in pos_session_rec.config_id.bill_value]
  19. cashbox_lines_ids = fields.One2many(default=_get_default_line)
  20. class BeescoopPosOrder(models.Model):
  21. _inherit = 'pos.order'
  22. print_status = fields.Selection([('no_print', 'Do not Print'),
  23. ('to_print', 'To print'),
  24. ('printed', 'Printed')],
  25. default="no_print", string="Print Status")
  26. @api.model
  27. def send_order(self, receipt_name):
  28. order = self.search([('pos_reference', '=', receipt_name)])
  29. if not order:
  30. return _('Error: no order found')
  31. if not order.partner_id.email:
  32. return _('Cannot send the ticket, no email address found on the client')
  33. order.print_status = 'to_print'
  34. return _("Ticket will be sent")
  35. @api.model
  36. def _send_order_cron(self):
  37. mail_template = self.env.ref("beesdoo_pos.email_send_ticket")
  38. _logger.info("Start to send ticket")
  39. for order in self.search([('print_status', '=', 'to_print')]):
  40. if not order.partner_id.email:
  41. continue
  42. mail_template.send_mail(order.id, force_send=True)
  43. order.print_status = 'printed'
  44. #Make sure we commit the change to not send ticket twice
  45. self.env.cr.commit()
  46. class BeescoopPosPartner(models.Model):
  47. _inherit = 'res.partner'
  48. def _get_eater(self):
  49. eaters = [False, False, False]
  50. for i, eater in enumerate(self.child_eater_ids):
  51. eaters[i] = eater.name
  52. return tuple(eaters)
  53. @api.multi
  54. def get_eater(self):
  55. eater1, eater2, eater3 = self._get_eater()
  56. return eater1, eater2, eater3
  57. # TODO: will be taken care of in separate 'pos_order_email' module
  58. # from odoo.addons.point_of_sale.report import pos_receipt
  59. #
  60. # class order_tva_included(pos_receipt.order):
  61. #
  62. # def __init__(self, cr, uid, name, context):
  63. # super(order_tva_included, self).__init__(cr, uid, name, context=context)
  64. # self.env = api.Environment(cr, uid, context)
  65. #
  66. # def netamount(self, order_line_id):
  67. # order_line = self.env['pos.order.line'].browse(order_line_id)
  68. # if order_line.order_id.config_id.iface_tax_included:
  69. # return order_line.price_subtotal_incl
  70. # else:
  71. # return order_line.price_subtotal
  72. #
  73. #
  74. # class report_order_receipt(models.AbstractModel):
  75. # _inherit = 'report.point_of_sale.report_receipt'
  76. # _template = 'point_of_sale.report_receipt'
  77. # _wrapped_report_class = order_tva_included