From 189d0e39e4df4092ea5b0394a1f2deecbc509414 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Thu, 10 Oct 2024 02:22:42 +0000 Subject: [PATCH] [IMP] commission: add the commission_ids field to the settlement and include it in the views --- commission/models/commission_settlement.py | 8 ++++++++ commission/views/commission_settlement_views.xml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/commission/models/commission_settlement.py b/commission/models/commission_settlement.py index 6337bb70e..bfebc53f7 100644 --- a/commission/models/commission_settlement.py +++ b/commission/models/commission_settlement.py @@ -60,6 +60,14 @@ 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: + rec.commission_ids = rec.line_ids.mapped("commission_id") 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..537dafc46 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'}" /> + +