Browse Source

[IMP] Add constraint in configuration

pull/468/head
Iván Todorovich 5 years ago
parent
commit
f1a372a956
  1. 9
      pos_invoice_send_mail/models/pos_config.py
  2. 1
      pos_invoice_send_mail/models/pos_order.py

9
pos_invoice_send_mail/models/pos_config.py

@ -1,7 +1,8 @@
# Copyright 2019 Druidoo - Iván Todorovich
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models, fields
from odoo import api, models, fields, _
from odoo.exceptions import ValidationError
class PosConfig(models.Model):
@ -19,3 +20,9 @@ class PosConfig(models.Model):
default=lambda self:
self.env.ref('account.email_template_edi_invoice', False),
)
@api.constrains('iface_invoice_mail', 'invoice_mail_template_id')
def _check_invoice_mail_templat_id(self):
for rec in self.filtered('iface_invoice_mail'):
if not rec.invoice_mail_template_id:
raise ValidationError(_('Invoice Email Template is required'))

1
pos_invoice_send_mail/models/pos_order.py

@ -19,7 +19,6 @@ class PosOrder(models.Model):
for order in self.browse(order_ids):
if (
order.config_id.iface_invoice_mail
and order.config_id.invoice_mail_template_id
and order.invoice_id
and not order.invoice_id.sent
and order.pos_reference in refs_to_send_mail

Loading…
Cancel
Save