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 27, 2019
2 parents f59055a + aeb1f32 commit 18a92b3
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion sale_exception/models/sale.py
Original file line number Diff line number Diff line change
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 18a92b3

Please sign in to comment.