changeset 56bf8305bcf2 in modules/commission:default
details:
https://hg.tryton.org/modules/commission?cmd=changeset&node=56bf8305bcf2
description:
Allow creating manual commission
issue11735
review411801003
diffstat:
CHANGELOG | 1 +
commission.py | 18 ++++++++++++++++--
invoice.py | 1 +
view/commission_form.xml | 7 ++++---
4 files changed, 22 insertions(+), 5 deletions(-)
diffs (76 lines):
diff -r 7c53027af609 -r 56bf8305bcf2 CHANGELOG
--- a/CHANGELOG Sun Oct 09 13:30:06 2022 +0200
+++ b/CHANGELOG Sun Oct 09 18:48:58 2022 +0200
@@ -1,3 +1,4 @@
+* Allow creating manual commission
* Include commission to stock margin report
Version 6.4.0 - 2022-05-02
diff -r 7c53027af609 -r 56bf8305bcf2 commission.py
--- a/commission.py Sun Oct 09 13:30:06 2022 +0200
+++ b/commission.py Sun Oct 09 18:48:58 2022 +0200
@@ -333,8 +333,8 @@
_readonly_states = {
'readonly': Bool(Eval('invoice_line')),
}
- origin = fields.Reference('Origin', selection='get_origin', select=True,
- readonly=True,
+ origin = fields.Reference(
+ "Origin", selection='get_origin', select=True, states=_readonly_states,
help="The source of the commission.")
date = fields.Date('Date', select=True, states=_readonly_states,
help="When the commission is due.")
@@ -392,6 +392,20 @@
models = cls._get_origin()
return [(None, '')] + [(m, get_name(m)) for m in models]
+ @fields.depends('agent', 'origin', 'base_amount')
+ def on_change_with_base_amount(self):
+ pool = Pool()
+ InvoiceLine = pool.get('account.invoice.line')
+ Currency = pool.get('currency.currency')
+ if (self.agent
+ and isinstance(self.origin, InvoiceLine)
+ and self.origin.id is not None
+ and self.origin.id >= 0
+ and self.base_amount is None):
+ return Currency.compute(
+ self.origin.invoice.currency, self.origin.amount,
+ self.agent.currency, round=False)
+
@fields.depends('agent')
def on_change_with_currency(self, name=None):
if self.agent:
diff -r 7c53027af609 -r 56bf8305bcf2 invoice.py
--- a/invoice.py Sun Oct 09 13:30:06 2022 +0200
+++ b/invoice.py Sun Oct 09 18:48:58 2022 +0200
@@ -137,6 +137,7 @@
'invisible': If(Bool(Eval('_parent_invoice')),
Eval('_parent_invoice', {}).get('type') == 'in',
Eval('invoice_type') == 'in'),
+ 'readonly': Eval('invoice_state') != 'draft',
},
help="The principal who pays a commission for the invoice line.")
commissions = fields.One2Many('commission', 'origin', 'Commissions',
diff -r 7c53027af609 -r 56bf8305bcf2 view/commission_form.xml
--- a/view/commission_form.xml Sun Oct 09 13:30:06 2022 +0200
+++ b/view/commission_form.xml Sun Oct 09 18:48:58 2022 +0200
@@ -11,14 +11,15 @@
<label name="product"/>
<field name="product"/>
+ <label name="origin"/>
+ <field name="origin"/>
+ <newline/>
+
<label name="base_amount"/>
<field name="base_amount"/>
<label name="amount"/>
<field name="amount"/>
- <label name="origin"/>
- <field name="origin"/>
- <newline/>
<label name="invoice_line"/>
<field name="invoice_line"/>
<label name="invoice_state"/>