Skip to content

Commit

Permalink
[IMP] comission: add the commission_ids field to the settlement and i…
Browse files Browse the repository at this point in the history
…nclude it in the views
  • Loading branch information
AungKoKoLin1997 committed Oct 10, 2024
1 parent 40491a3 commit 1331d57
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions commission/models/commission_settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions commission/views/commission_settlement_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<field name="arch" type="xml">
<tree decoration-danger="state == 'cancel'">
<field name="agent_id" />
<field name="commission_ids" widget="many2many_tags" />
<field name="company_id" groups="base.group_multi_company" />
<field name="date_from" />
<field name="date_to" />
Expand All @@ -27,6 +28,7 @@
<field name="arch" type="xml">
<search string="Settlement search">
<field name="agent_id" />
<field name="commission_ids" />
<field name="date_from" />
<field name="date_to" />
<field name="company_id" />
Expand All @@ -42,6 +44,11 @@
name="group_agent"
context="{'group_by': 'agent_id'}"
/>
<filter
string="Commission"
name="group_commission"
context="{'group_by': 'commission_ids'}"
/>
<filter
string="Date from month"
name="group_date"
Expand Down Expand Up @@ -70,6 +77,7 @@
<group attrs="{'readonly': [('can_edit', '=', False)]}">
<group>
<field name="agent_id" />
<field name="commission_ids" widget="many2many_tags" />
<field name="date_from" />
<field name="settlement_type" />
</group>
Expand Down

0 comments on commit 1331d57

Please sign in to comment.