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.

65 lines
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api, _
  3. class BeesPOS(models.Model):
  4. _inherit = 'pos.config'
  5. bill_value = fields.One2many('bill_value', 'pos', copy=True)
  6. class BillValue(models.Model):
  7. _name = 'bill_value'
  8. _order = 'name asc'
  9. name = fields.Float(string='Name')
  10. pos = fields.Many2one('pos.config')
  11. class BeesAccountBankStatement(models.Model):
  12. _inherit = 'account.bank.statement.cashbox'
  13. def _get_default_line(self):
  14. if not self.env.context.get('active_id'):
  15. return []
  16. pos_session_rec = self.env['pos.session'].browse(self.env.context['active_id'])
  17. return [(0, 0, {'coin_value' : bill_value_rec.name, 'subtotal':0.0}) for bill_value_rec in pos_session_rec.config_id.bill_value]
  18. cashbox_lines_ids = fields.One2many(default=_get_default_line)
  19. class BeescoopPosOrder(models.Model):
  20. _inherit = 'pos.order'
  21. @api.model
  22. def send_order(self, receipt_name):
  23. order = self.search([('pos_reference', '=', receipt_name)])
  24. if not order:
  25. return _('Error: no order found')
  26. if not order.partner_id.email:
  27. return _('Cannot send the ticket, no email address found on the client')
  28. mail_template = self.env.ref("beesdoo_pos.email_send_ticket")
  29. mail_template.send_mail(order.id)
  30. return _("Ticket sent")
  31. class BeescoopPosPartner(models.Model):
  32. _inherit = 'res.partner'
  33. def _get_eater(self):
  34. eater1, eater2 = False, False
  35. if self.child_eater_ids:
  36. eater1 = self.child_eater_ids[0].name
  37. if len(self.child_eater_ids) > 1:
  38. eater2 = self.child_eater_ids[1].name
  39. return eater1, eater2
  40. @api.multi
  41. def get_balance_and_eater(self):
  42. self.ensure_one()
  43. self = self.sudo()
  44. account_id = self.property_account_receivable_id.id
  45. move_lines = self.env['account.move.line'].search([('account_id', '=', account_id), ('partner_id', '=', self.id)])
  46. credit = sum([m.credit for m in move_lines])
  47. debit = sum([m.debit for m in move_lines])
  48. eater1, eater2 = self._get_eater()
  49. return str(round(credit - debit, 2)), eater1, eater2
  50. last_name = fields.Char('Last Name', required=True, default="/")