changeset c21de1d5a490 in modules/commission:default
details: 
https://hg.tryton.org/modules/commission?cmd=changeset&node=c21de1d5a490
description:
        Allow creating commission invoices for specific agents

        issue10817
        review373681002
diffstat:

 CHANGELOG                                   |   1 +
 commission.py                               |  14 ++++++++++++++
 view/commission_create_invoice_ask_form.xml |   2 ++
 3 files changed, 17 insertions(+), 0 deletions(-)

diffs (49 lines):

diff -r 841d9290df4a -r c21de1d5a490 CHANGELOG
--- a/CHANGELOG Fri Oct 08 19:23:27 2021 +0200
+++ b/CHANGELOG Sat Oct 09 00:38:28 2021 +0200
@@ -1,3 +1,4 @@
+* Allow creating commission invoices for specific agents
 * Add reporting
 
 Version 6.0.0 - 2021-05-03
diff -r 841d9290df4a -r c21de1d5a490 commission.py
--- a/commission.py     Fri Oct 08 19:23:27 2021 +0200
+++ b/commission.py     Sat Oct 09 00:38:28 2021 +0200
@@ -560,6 +560,9 @@
             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 @@
             ('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 -r 841d9290df4a -r c21de1d5a490 view/commission_create_invoice_ask_form.xml
--- a/view/commission_create_invoice_ask_form.xml       Fri Oct 08 19:23:27 
2021 +0200
+++ b/view/commission_create_invoice_ask_form.xml       Sat Oct 09 00:38:28 
2021 +0200
@@ -8,4 +8,6 @@
     <field name="to"/>
     <label name="type_"/>
     <field name="type_"/>
+
+    <field name="agents" colspan="4"/>
 </form>

Reply via email to