Skip to content

Commit

Permalink
[FIX]sale_commission_product_criteria: ignore error on create
Browse files Browse the repository at this point in the history
  • Loading branch information
PicchiSeba committed Oct 16, 2024
1 parent ee3e0e9 commit 69c9058
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sale_commission_product_criteria/models/commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def check_type_change_allowed_sale(self):
)

def check_type_change_allowed_moves(self):
if not self._origin:
return
aila_ids = self.env["account.invoice.line.agent"].search(
[("commission_id", "=", self._origin.id)]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


from odoo.exceptions import ValidationError
from odoo.tests.common import SavepointCase
from odoo.tests.common import Form, SavepointCase


class TestSaleCommission(SavepointCase):
Expand Down Expand Up @@ -198,3 +198,19 @@ def _invoice_sale_order(self, sale_order, date=None):
invoice = sale_order.invoice_ids - old_invoices
invoice.flush()
return invoice

def test_on_create_check(self):
f = Form(self.commission_model)
f.name = "New commission type"
f.save()

so = self._create_sale_order(self.product_4, self.partner)
self.assertEqual(
so.order_line.agent_ids.commission_id, self.rules_commission_id
)
self.assertEqual(self.rules_commission_id.commission_type, "product")

so.action_confirm()
with self.assertRaises(ValidationError):
self.rules_commission_id.commission_type = "fixed"
self.rules_commission_id.onchange_commission_type()

0 comments on commit 69c9058

Please sign in to comment.