diff --git a/commission/models/commission_settlement.py b/commission/models/commission_settlement.py index 6337bb70e..2ed4ac2da 100644 --- a/commission/models/commission_settlement.py +++ b/commission/models/commission_settlement.py @@ -60,6 +60,16 @@ class CommissionSettlement(models.Model): default=lambda self: self._default_company_id(), required=True, ) + commission_ids = fields.Many2many( + comodel_name="commission", compute="_compute_commission_ids", store=True + ) + + @api.depends("line_ids.commission_id") + def _compute_commission_ids(self): + for rec in self: + commission_ids = rec.line_ids.mapped("commission_id").ids + if commission_ids: + rec.commission_ids = [(6, 0, commission_ids)] def _default_currency_id(self): return self.env.company.currency_id.id diff --git a/commission/views/commission_settlement_views.xml b/commission/views/commission_settlement_views.xml index 8e97bfa2a..2557df287 100644 --- a/commission/views/commission_settlement_views.xml +++ b/commission/views/commission_settlement_views.xml @@ -6,6 +6,7 @@ + @@ -27,6 +28,7 @@ + @@ -42,6 +44,11 @@ name="group_agent" context="{'group_by': 'agent_id'}" /> + +