line: disable column 'quantity_balance' if cashbook-feature != asset
This commit is contained in:
parent
8acfa35289
commit
4ef14cd44b
5 changed files with 50 additions and 7 deletions
18
line.py
18
line.py
|
@ -58,9 +58,11 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
}, depends=['currency_digits', 'quantity_digits', 'feature']),
|
}, depends=['currency_digits', 'quantity_digits', 'feature']),
|
||||||
'on_change_with_asset_rate')
|
'on_change_with_asset_rate')
|
||||||
quantity_balance = fields.Function(fields.Numeric(string='Quantity',
|
quantity_balance = fields.Function(fields.Numeric(string='Quantity',
|
||||||
digits=(16, Eval('quantity_digits', 4)),
|
digits=(16, Eval('quantity_digits', 4)), readonly=True,
|
||||||
help='Number of shares in the cashbook up to the current row if the default sort applies.',
|
help='Number of shares in the cashbook up to the current row if the default sort applies.',
|
||||||
readonly=True, depends=['quantity_digits']),
|
states={
|
||||||
|
'invisible': Eval('feature', '') != 'asset',
|
||||||
|
}, depends=['quantity_digits', 'feature']),
|
||||||
'on_change_with_quantity_balance')
|
'on_change_with_quantity_balance')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -134,7 +136,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@fields.depends('id', 'date', 'cashbook', \
|
@fields.depends('id', 'date', 'cashbook', 'feature',\
|
||||||
'_parent_cashbook.id', 'reconciliation', \
|
'_parent_cashbook.id', 'reconciliation', \
|
||||||
'_parent_reconciliation.start_quantity',\
|
'_parent_reconciliation.start_quantity',\
|
||||||
'_parent_reconciliation.state')
|
'_parent_reconciliation.state')
|
||||||
|
@ -142,10 +144,12 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
""" get quantity-balance
|
""" get quantity-balance
|
||||||
"""
|
"""
|
||||||
Line2 = Pool().get('cashbook.line')
|
Line2 = Pool().get('cashbook.line')
|
||||||
return Line2.get_balance_of_line(self,
|
|
||||||
field_name='quantity',
|
if self.feature == 'asset':
|
||||||
credit_name='quantity_credit',
|
return Line2.get_balance_of_line(self,
|
||||||
debit_name='quantity_debit')
|
field_name='quantity',
|
||||||
|
credit_name='quantity_credit',
|
||||||
|
debit_name='quantity_debit')
|
||||||
|
|
||||||
@fields.depends('quantity', 'amount', 'currency_digits', 'quantity_digits')
|
@fields.depends('quantity', 'amount', 'currency_digits', 'quantity_digits')
|
||||||
def on_change_with_asset_rate(self, name=None):
|
def on_change_with_asset_rate(self, name=None):
|
||||||
|
|
11
line.xml
11
line.xml
|
@ -11,5 +11,16 @@ full copyright notices and license terms. -->
|
||||||
<field name="name">line_form</field>
|
<field name="name">line_form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="line_view_list">
|
||||||
|
<field name="model">cashbook.line</field>
|
||||||
|
<field name="inherit" ref="cashbook.line_view_list"/>
|
||||||
|
<field name="name">line_list</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="line_recon_view_list">
|
||||||
|
<field name="model">cashbook.line</field>
|
||||||
|
<field name="inherit" ref="cashbook.line_recon_view_list"/>
|
||||||
|
<field name="name">line_recon_list</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
3
mixin.py
3
mixin.py
|
@ -105,6 +105,9 @@ class SecondUomMixin(object):
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.booktransf is None:
|
if line.booktransf is None:
|
||||||
continue
|
continue
|
||||||
|
if (line.cashbook.quantity_uom is None) or \
|
||||||
|
(line.booktransf.quantity_uom is None):
|
||||||
|
continue
|
||||||
|
|
||||||
if line.cashbook.quantity_uom.id == line.booktransf.quantity_uom.id:
|
if line.cashbook.quantity_uom.id == line.booktransf.quantity_uom.id:
|
||||||
continue
|
continue
|
||||||
|
|
13
view/line_list.xml
Normal file
13
view/line_list.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<xpath expr="/tree/field[@name='balance']" position="after">
|
||||||
|
<field name="quantity_credit"/>
|
||||||
|
<field name="quantity_debit"/>
|
||||||
|
<field name="quantity_balance"/>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</data>
|
12
view/line_recon_list.xml
Normal file
12
view/line_recon_list.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<xpath expr="/tree/field[@name='debit']" position="after">
|
||||||
|
<field name="quantity_credit"/>
|
||||||
|
<field name="quantity_debit"/>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</data>
|
Loading…
Reference in a new issue