Corrected manual entry behaviour on account.move form for unsaved move.line
bzr revid: jvo@tinyerp.com-20080910113229-0gqd0uff2vbed2kv
This commit is contained in:
parent
c7fe56aacf
commit
294e474bc0
|
@ -70,6 +70,33 @@ class account_move_line(osv.osv):
|
|||
# Compute simple values
|
||||
data = super(account_move_line, self).default_get(cr, uid, fields, context)
|
||||
|
||||
# Starts: Manual entry from account.move form
|
||||
if context.get('lines',[]):
|
||||
|
||||
total_new=0.00
|
||||
for i in context['lines']:
|
||||
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['journal']:
|
||||
journal_obj=self.pool.get('account.journal').browse(cr,uid,context['journal'])
|
||||
if journal_obj.type == 'purchase':
|
||||
if total_new>0:
|
||||
account = journal_obj.default_credit_account_id
|
||||
else:
|
||||
account = journal_obj.default_debit_account_id
|
||||
else:
|
||||
if total_new>0:
|
||||
account = journal_obj.default_credit_account_id
|
||||
else:
|
||||
account = journal_obj.default_debit_account_id
|
||||
data['account_id'] = account.id
|
||||
s = -total_new
|
||||
data['debit'] = s>0 and s or 0.0
|
||||
data['credit'] = s<0 and -s or 0.0
|
||||
return data
|
||||
# Ends: Manual entry from account.move form
|
||||
|
||||
if not 'move_id' in fields: #we are not in manual entry
|
||||
return data
|
||||
|
||||
|
@ -649,7 +676,6 @@ class account_move_line(osv.osv):
|
|||
def create(self, cr, uid, vals, context=None, check=True):
|
||||
if not context:
|
||||
context={}
|
||||
|
||||
account_obj = self.pool.get('account.account')
|
||||
tax_obj=self.pool.get('account.tax')
|
||||
|
||||
|
|
|
@ -801,7 +801,7 @@
|
|||
<field name="to_check" select="2"/>
|
||||
|
||||
<separator colspan="4" string="Entry Lines"/>
|
||||
<field colspan="4" name="line_id" nolabel="1" widget="one2many_list">
|
||||
<field colspan="4" name="line_id" nolabel="1" widget="one2many_list" default_get="{'lines':line_id ,'journal':journal_id }">
|
||||
<form string="Account Entry Line">
|
||||
<separator colspan="4" string="General Information"/>
|
||||
<field name="name" select="1"/>
|
||||
|
@ -828,7 +828,6 @@
|
|||
</form>
|
||||
<tree editable="top" string="Account Entry Line">
|
||||
<field name="date"/>
|
||||
<field name="move_id" readonly="1" />
|
||||
<field name="name"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,date,parent.journal_id)"/>
|
||||
<field name="account_id"/>
|
||||
|
|
Loading…
Reference in New Issue