Skip to content

Commit

Permalink
[IMP] Add constraint in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ivantodorovich committed Mar 18, 2020
1 parent fcd2fd8 commit f1a372a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pos_invoice_send_mail/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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 change: 0 additions & 1 deletion pos_invoice_send_mail/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def create_from_ui(self, orders):
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
Expand Down

0 comments on commit f1a372a

Please sign in to comment.