[IMP] Improved code for
In cash registers, it does not work at all >>real closing balance is not updated >>opening balance is not updated >>and so amount is never good bzr revid: psa@tinyerp.com-20130917130901-hem0iwy608vkwe02
This commit is contained in:
parent
2c2fdc09f1
commit
5f06129179
|
@ -171,7 +171,35 @@ class account_cash_statement(osv.osv):
|
|||
|
||||
return result
|
||||
|
||||
def _compute_cash_all(self, cr, uid, ids, fieldnames, args, context=None):
|
||||
result = dict()
|
||||
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
result[record.id] = {
|
||||
'cash_journal_id' : False,
|
||||
'cash_register_id' : False,
|
||||
'cash_control' : False,
|
||||
}
|
||||
for st in self.browse(cr, uid, ids, context=context):
|
||||
if st.journal_id.cash_control == True:
|
||||
result[record.id]['cash_control'] = True
|
||||
result[record.id]['cash_journal_id'] = st.journal_id.id
|
||||
result[record.id]['cash_register_id'] = st.id
|
||||
return result
|
||||
|
||||
|
||||
_columns = {
|
||||
'cash_control' : fields.function(_compute_cash_all,
|
||||
multi='cash',
|
||||
type='boolean', string='Has Cash Control'),
|
||||
'cash_journal_id' : fields.function(_compute_cash_all,
|
||||
multi='cash',
|
||||
type='many2one', relation='account.journal',
|
||||
string='Cash Journal', store=True),
|
||||
'cash_register_id' : fields.function(_compute_cash_all,
|
||||
multi='cash',
|
||||
type='many2one', relation='account.bank.statement',
|
||||
string='Cash Register', store=True),
|
||||
'total_entry_encoding': fields.function(_get_sum_entry_encoding, string="Total Transactions",
|
||||
store = {
|
||||
'account.bank.statement': (lambda self, cr, uid, ids, context=None: ids, ['line_ids','move_line_ids'], 10),
|
||||
|
@ -185,6 +213,28 @@ class account_cash_statement(osv.osv):
|
|||
'user_id': fields.many2one('res.users', 'Responsible', required=False),
|
||||
'difference' : fields.function(_compute_difference, method=True, string="Difference", type="float", help="Difference between the theoretical closing balance and the real closing balance."),
|
||||
'last_closing_balance' : fields.function(_compute_last_closing_balance, method=True, string='Last Closing Balance', type='float'),
|
||||
'cash_register_balance_end_real' : fields.related('cash_register_id', 'balance_end_real',
|
||||
type='float',
|
||||
digits_compute=dp.get_precision('Account'),
|
||||
string="Ending Balance",
|
||||
help="Total of closing cash control lines.",
|
||||
readonly=True),
|
||||
'cash_register_balance_start' : fields.related('cash_register_id', 'balance_start',
|
||||
type='float',
|
||||
digits_compute=dp.get_precision('Account'),
|
||||
string="Starting Balance",
|
||||
help="Total of opening cash control lines.",
|
||||
readonly=True),
|
||||
'cash_register_total_entry_encoding' : fields.related('cash_register_id', 'total_entry_encoding',
|
||||
string='Total Cash Transaction',
|
||||
readonly=True,
|
||||
help="Total of all paid sale orders"),
|
||||
'cash_register_balance_end' : fields.related('cash_register_id', 'balance_end',
|
||||
type='float',
|
||||
digits_compute=dp.get_precision('Account'),
|
||||
string="Theoretical Closing Balance",
|
||||
help="Sum of opening balance and transactions.",
|
||||
readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'state': 'draft',
|
||||
|
|
|
@ -2264,7 +2264,6 @@
|
|||
<group>
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" widget="selection" domain="[('type', '=', 'cash')]" />
|
||||
<field name="user_id" readonly="1" string="Responsible"/>
|
||||
<field name="total_entry_encoding"/>
|
||||
<field name='company_id' widget="selection" groups="base.group_multi_company" />
|
||||
</group>
|
||||
<group>
|
||||
|
@ -2281,7 +2280,7 @@
|
|||
<field name="opening_details_ids" colspan="2" nolabel="1">
|
||||
<tree string="Opening Cashbox Lines" editable="bottom">
|
||||
<field name="pieces"/>
|
||||
<field name="number_opening" on_change="on_change_sub_opening(pieces, number_opening, parent.balance_end)"/>
|
||||
<field name="number_opening" on_change="on_change_sub_opening(pieces, number_opening)" />
|
||||
<field name="subtotal_opening" string="Opening Subtotal" sum="Total"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
@ -2291,7 +2290,7 @@
|
|||
<field name="details_ids" colspan="2" nolabel="1" attrs="{'readonly' : [('state', '!=', 'draft')]}">
|
||||
<tree string="Opening Cashbox Lines" editable="bottom">
|
||||
<field name="pieces"/>
|
||||
<field name="number_opening" on_change="on_change_sub_opening(pieces, number_opening, parent.balance_end)"/>
|
||||
<field name="number_opening" on_change="on_change_sub_opening(pieces, number_opening)"/>
|
||||
<field name="subtotal_opening" string="Opening Subtotal" sum="Total"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
@ -2300,7 +2299,7 @@
|
|||
<field name="closing_details_ids" colspan="2" nolabel="1">
|
||||
<tree string="Closing Cashbox Lines" editable="bottom">
|
||||
<field name="pieces" readonly="1" />
|
||||
<field name="number_closing" on_change="on_change_sub_closing(pieces, number_closing, parent.balance_end)"/>
|
||||
<field name="number_closing" on_change="on_change_sub_closing(pieces, number_closing)"/>
|
||||
<field name="subtotal_closing" string="Closing Subtotal" sum="Total"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue