Allow creating manual commission

issue11735
review411801003
This commit is contained in:
Cédric Krier
2022-10-09 18:48:58 +02:00
parent ebff308c9c
commit 5f3d8902a3
4 changed files with 22 additions and 5 deletions
+1
View File
@@ -1,3 +1,4 @@
* Allow creating manual commission
* Include commission to stock margin report
Version 6.4.0 - 2022-05-02
+16 -2
View File
@@ -333,8 +333,8 @@ class Commission(ModelSQL, ModelView):
_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 @@ class Commission(ModelSQL, ModelView):
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:
+1
View File
@@ -137,6 +137,7 @@ class InvoiceLine(metaclass=PoolMeta):
'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',
+4 -3
View File
@@ -11,14 +11,15 @@ this repository contains the full copyright notices and license terms. -->
<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"/>