Skip to content

Commit

Permalink
[MIG] sale_exception: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasperalta1 authored and jjscarafia committed Dec 16, 2022
1 parent 1df77fa commit 4be9ab6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sale_exception/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Sale Exception",
"summary": "Custom exceptions on sale order",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Generic Modules/Sale",
"author": "Akretion, "
"Sodexis, "
Expand Down
7 changes: 4 additions & 3 deletions sale_exception/data/sale_exception_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<field name="description">Not Enough Virtual Stock</field>
<field name="sequence">50</field>
<field name="model">sale.order.line</field>
<field name="code">failed=self.product_id and self.product_id.type == 'product'
and self.virtual_available_at_date &lt; self.product_uom_qty</field>
<field
name="code"
>failed=self.product_id and self.product_id.type == 'product' and self.virtual_available_at_date &lt; self.product_uom_qty</field>
<field name="active" eval="False" />
</record>
<record id="exception_partner_sale_warning" model="exception.rule">
Expand All @@ -43,7 +44,7 @@
<field name="description">The product has a warning in his form</field>
<field name="sequence">40</field>
<field name="model">sale.order.line</field>
<field name="code">failed=self.product_id.sale_line_warn == "warning"</field>
<field name="code">failed=self.sale_line_warn == "warning"</field>
<field name="active" eval="False" />
</record>
</odoo>
11 changes: 6 additions & 5 deletions sale_exception/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ def _check_sale_check_exception(self, vals):
if check_exceptions:
self.sale_check_exception()

@api.model
def create(self, vals):
record = super().create(vals)
record._check_sale_check_exception(vals)
return record
@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
for record, vals in zip(records, vals_list):
record._check_sale_check_exception(vals)
return records

def write(self, vals):
result = super().write(vals)
Expand Down
2 changes: 1 addition & 1 deletion sale_exception/tests/test_sale_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_exception_product_sale_warning(self):
partner=self.env.ref("base.res_partner_1"), product=product
)
sale_order.action_confirm()
product.sale_line_warn = "warning"
self.sale_line_warn = "warning"
sale_order2 = sale_order.copy()
sale_order2.detect_exceptions()
self.assertTrue(sale_order2.exception_ids.filtered(lambda x: x == exception))

0 comments on commit 4be9ab6

Please sign in to comment.