diff --git a/sale_commission_product_criteria_domain/models/commission.py b/sale_commission_product_criteria_domain/models/commission.py index 35cfab1ee..03598518d 100644 --- a/sale_commission_product_criteria_domain/models/commission.py +++ b/sale_commission_product_criteria_domain/models/commission.py @@ -20,7 +20,6 @@ class CommissionItem(models.Model): ) group_id = fields.Many2one( "commission.items.group", - domain="[('commission_ids', 'in', commission_id)]", ondelete="restrict", ) @@ -46,13 +45,21 @@ class CommissionItemsGroup(models.Model): name = fields.Char(required=True) commission_ids = fields.Many2many( "sale.commission", + compute="_compute_commission_ids", domain=[("commission_type", "=", "product_restricted")], required=True, + readonly=True, + store=True, ) item_ids = fields.One2many( "commission.item", "group_id", string="Items", readonly=True ) + @api.depends("item_ids") + def _compute_commission_ids(self): + for rec in self: + rec.commission_ids = [(6, 0, rec.item_ids.mapped("commission_id").ids)] + class CommissionItemAgent(models.Model): _name = "commission.item.agent" diff --git a/sale_commission_product_criteria_domain/views/views.xml b/sale_commission_product_criteria_domain/views/views.xml index 9a56341cd..4839412a2 100644 --- a/sale_commission_product_criteria_domain/views/views.xml +++ b/sale_commission_product_criteria_domain/views/views.xml @@ -1,6 +1,7 @@ + res.partner.form.agent.inherit res.partner