[MERGE] account: merged the dev branch with workaround of context['line_id'] in line_id field (operation not supported in web client)
bzr revid: qdp-launchpad@openerp.com-20120213131702-f20fl7ydpxvt9o7g
This commit is contained in:
commit
614893d620
|
@ -1273,7 +1273,9 @@ class account_move(osv.osv):
|
|||
'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}, select=True),
|
||||
'narration':fields.text('Internal Note'),
|
||||
'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
|
||||
'balance': fields.float('balance', digits_compute=dp.get_precision('Account'), help="This is a field only used for internal purpose and shouldn't be displayed"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'name': '/',
|
||||
'state': 'draft',
|
||||
|
@ -1357,6 +1359,13 @@ class account_move(osv.osv):
|
|||
'WHERE id IN %s', ('draft', tuple(ids),))
|
||||
return True
|
||||
|
||||
def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
|
||||
balance = 0.0
|
||||
for line in line_ids:
|
||||
if line[2]:
|
||||
balance += (line[2]['debit'] or 0.00)- (line[2]['credit'] or 0.00)
|
||||
return {'value': {'balance': balance}}
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
|
|
@ -228,13 +228,8 @@ class account_move_line(osv.osv):
|
|||
# Compute simple values
|
||||
data = super(account_move_line, self).default_get(cr, uid, fields, context=context)
|
||||
# Starts: Manual entry from account.move form
|
||||
if context.get('lines',[]):
|
||||
total_new = 0.00
|
||||
for i in context['lines']:
|
||||
if i[2]:
|
||||
total_new += (i[2]['debit'] or 0.00)- (i[2]['credit'] or 0.00)
|
||||
for item in i[2]:
|
||||
data[item] = i[2][item]
|
||||
if context.get('lines'):
|
||||
total_new = context.get('balance', 0.00)
|
||||
if context['journal']:
|
||||
journal_data = journal_obj.browse(cr, uid, context['journal'], context=context)
|
||||
if journal_data.type == 'purchase':
|
||||
|
|
|
@ -1365,7 +1365,10 @@
|
|||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Journal Items">
|
||||
<field colspan="4" name="line_id" nolabel="1" height="250" widget="one2many_list" context="{'lines':line_id ,'journal':journal_id }">
|
||||
<field name="balance" invisible="1"/>
|
||||
<field colspan="4" name="line_id" nolabel="1" height="250" widget="one2many_list"
|
||||
on_change="onchange_line_id(line_id)"
|
||||
context="{'balance': balance , 'journal': journal_id }">
|
||||
<form string="Journal Item">
|
||||
<group col="6" colspan="4">
|
||||
<field name="name"/>
|
||||
|
|
Loading…
Reference in New Issue