diff --git a/CHANGELOG b/CHANGELOG index 2ac8d57c3f..cb29edde9f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow creating commission invoices for specific agents * Add reporting Version 6.0.0 - 2021-05-03 diff --git a/commission.py b/commission.py index 40b086709c..8ee1097302 100644 --- a/commission.py +++ b/commission.py @@ -560,6 +560,9 @@ class CreateInvoice(Wizard): domain.append(('agent.type_', '=', 'principal')) elif self.ask.type_ == 'out': domain.append(('agent.type_', '=', 'agent')) + if self.ask.agents: + agents = [agent.id for agent in self.ask.agents] + domain.append(('agent', 'in', agents)) return domain def do_create_(self, action): @@ -597,6 +600,17 @@ class CreateInvoiceAsk(ModelView): ('both', 'Both'), ], 'Type', help="Limit to commissions of this type.") + agents = fields.Many2Many( + 'commission.agent', None, None, "Agents", + domain=[ + If(Eval('type_') == 'in', + ('type_', '=', 'principal'), ()), + If(Eval('type_') == 'out', + ('type_', '=', 'agent'), ()), + ], + depends=['type_'], + help="Limit to commissions for these agents.\n" + "If empty all agents of the selected type are used.") @staticmethod def default_type_(): diff --git a/view/commission_create_invoice_ask_form.xml b/view/commission_create_invoice_ask_form.xml index fccb07c624..e1bf4634c5 100644 --- a/view/commission_create_invoice_ask_form.xml +++ b/view/commission_create_invoice_ask_form.xml @@ -8,4 +8,6 @@ this repository contains the full copyright notices and license terms. -->