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.

28 lines
1014 B

  1. # Copyright 2019 Druidoo - Iván Todorovich
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo import api, models, fields, _
  4. from odoo.exceptions import ValidationError
  5. class PosConfig(models.Model):
  6. _inherit = 'pos.config'
  7. iface_invoice_mail = fields.Boolean('Send Invoice by Mail')
  8. invoice_mail_template_id = fields.Many2one(
  9. 'mail.template',
  10. string='Invoice Email Template',
  11. domain=[('model', '=', 'account.invoice')],
  12. context=lambda self: {
  13. 'default_model_id': self.ref('account.model_account_invoice').id,
  14. },
  15. default=lambda self:
  16. self.env.ref('account.email_template_edi_invoice', False),
  17. )
  18. @api.constrains('iface_invoice_mail', 'invoice_mail_template_id')
  19. def _check_invoice_mail_templat_id(self):
  20. for rec in self.filtered('iface_invoice_mail'):
  21. if not rec.invoice_mail_template_id:
  22. raise ValidationError(_('Invoice Email Template is required'))