Skip to content

Commit

Permalink
Merge PR #916 into 10.0
Browse files Browse the repository at this point in the history
Signed-off-by rafaelbn
  • Loading branch information
OCA-git-bot committed Sep 26, 2019
2 parents 18b4c5b + aeb1f32 commit 09e4494
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion sale_exception/models/sale.py
Expand Up @@ -46,7 +46,31 @@ def test_all_draft_orders(self):
order_set.detect_exceptions()
return True

@api.constrains('ignore_exception', 'order_line', 'state')
def _fields_trigger_check_exception(self):
return ['ignore_exception', 'order_line', 'state']

@api.model
def create(self, vals):
record = super(SaleOrder, self).create(vals)
check_exceptions = any(
field in vals for field
in self._fields_trigger_check_exception()
)
if check_exceptions:
record.sale_check_exception()
return record

@api.multi
def write(self, vals):
result = super(SaleOrder, self).write(vals)
check_exceptions = any(
field in vals for field
in self._fields_trigger_check_exception()
)
if check_exceptions:
self.sale_check_exception()
return result

def sale_check_exception(self):
orders = self.filtered(lambda s: s.state == 'sale')
if orders:
Expand Down

0 comments on commit 09e4494

Please sign in to comment.