Skip to content

Commit

Permalink
[16.0][IMP]sale_exception: set context param for unlocking an order
Browse files Browse the repository at this point in the history
  • Loading branch information
dalonsofl committed Feb 5, 2024
1 parent 32836bf commit 8921f6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sale_exception/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ def _sale_get_lines(self):
@api.model
def _get_popup_action(self):
return self.env.ref("sale_exception.action_sale_exception_confirm")

def action_unlock(self):
return super(
SaleOrder, self.with_context(check_exception=False)
).action_unlock()
18 changes: 18 additions & 0 deletions sale_exception/tests/test_sale_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,21 @@ def test_exception_no_free(self):
so_except_confirm.action_confirm()
self.assertFalse(sale_order.ignore_exception)
self.assertTrue(sale_order.state == "draft")

def test_exception_no_validation_for_unlock(self):
partner = self.env.ref("base.res_partner_1")
partner.zip = False
sale_order = self._create_sale_order(
partner=partner, product=self.env.ref("product.product_product_6")
)
sale_order.action_confirm()
self.assertEqual(sale_order.state, "sale")
exception = self.env.ref("sale_exception.excep_no_zip")
exception.active = True
sale_order.action_done()
self.assertEqual(sale_order.state, "done")
# Just reverting the state to 'sale' would trigger an error.
with self.assertRaises(ValidationError):
sale_order.write({"state": "sale"})
sale_order.action_unlock()
self.assertEqual(sale_order.state, "sale")

0 comments on commit 8921f6a

Please sign in to comment.