[FIX] Account: account move line
bzr revid: mra@mra-laptop-20100816070633-6i2q0tbd7r6q9yk3
This commit is contained in:
parent
227503e001
commit
7b409568c1
|
@ -146,7 +146,7 @@ class account_move_line(osv.osv):
|
||||||
|
|
||||||
def convert_to_period(self, cr, uid, context={}):
|
def convert_to_period(self, cr, uid, context={}):
|
||||||
period_obj = self.pool.get('account.period')
|
period_obj = self.pool.get('account.period')
|
||||||
|
|
||||||
#check if the period_id changed in the context from client side
|
#check if the period_id changed in the context from client side
|
||||||
if context.get('period_id', False):
|
if context.get('period_id', False):
|
||||||
period_id = context.get('period_id')
|
period_id = context.get('period_id')
|
||||||
|
@ -157,13 +157,13 @@ class account_move_line(osv.osv):
|
||||||
})
|
})
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def _default_get(self, cr, uid, fields, context={}):
|
def _default_get(self, cr, uid, fields, context={}):
|
||||||
|
|
||||||
period_obj = self.pool.get('account.period')
|
period_obj = self.pool.get('account.period')
|
||||||
|
|
||||||
context = self.convert_to_period(cr, uid, context)
|
context = self.convert_to_period(cr, uid, context)
|
||||||
|
|
||||||
# Compute simple values
|
# Compute simple values
|
||||||
data = super(account_move_line, self).default_get(cr, uid, fields, context)
|
data = super(account_move_line, self).default_get(cr, uid, fields, context)
|
||||||
# Starts: Manual entry from account.move form
|
# Starts: Manual entry from account.move form
|
||||||
|
@ -337,7 +337,7 @@ class account_move_line(osv.osv):
|
||||||
invoice_id = res[line_id]
|
invoice_id = res[line_id]
|
||||||
res[line_id] = (invoice_id, invoice_names[invoice_id])
|
res[line_id] = (invoice_id, invoice_names[invoice_id])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def name_get(self, cr, uid, ids, context={}):
|
def name_get(self, cr, uid, ids, context={}):
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return []
|
return []
|
||||||
|
@ -572,18 +572,18 @@ class account_move_line(osv.osv):
|
||||||
if journal:
|
if journal:
|
||||||
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
|
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
|
||||||
#FIXME: Bank and cash journal are such a journal we can not assume a account based on this 2 journals
|
#FIXME: Bank and cash journal are such a journal we can not assume a account based on this 2 journals
|
||||||
# Bank and cash journal can have a payment or receipt transection, and in both type partner account
|
# Bank and cash journal can have a payment or receipt transection, and in both type partner account
|
||||||
# will not be same id payment then payable, and if receipt then receivable
|
# will not be same id payment then payable, and if receipt then receivable
|
||||||
#if jt in ('sale', 'purchase_refund', 'bank', 'cash'):
|
#if jt in ('sale', 'purchase_refund', 'bank', 'cash'):
|
||||||
if jt in ('sale', 'purchase_refund'):
|
if jt in ('sale', 'purchase_refund'):
|
||||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2)
|
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2)
|
||||||
elif jt in ('purchase', 'sale_refund', 'expense', 'bank', 'cash'):
|
elif jt in ('purchase', 'sale_refund', 'expense', 'bank', 'cash'):
|
||||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1)
|
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1)
|
||||||
|
|
||||||
if val.get('account_id', False):
|
if val.get('account_id', False):
|
||||||
d = self.onchange_account_id(cr, uid, ids, val['account_id'])
|
d = self.onchange_account_id(cr, uid, ids, val['account_id'])
|
||||||
val.update(d['value'])
|
val.update(d['value'])
|
||||||
|
|
||||||
return {'value':val}
|
return {'value':val}
|
||||||
|
|
||||||
def onchange_account_id(self, cr, uid, ids, account_id=False, partner_id=False):
|
def onchange_account_id(self, cr, uid, ids, account_id=False, partner_id=False):
|
||||||
|
@ -843,22 +843,23 @@ class account_move_line(osv.osv):
|
||||||
|
|
||||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
|
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
|
||||||
journal_pool = self.pool.get('account.journal')
|
journal_pool = self.pool.get('account.journal')
|
||||||
|
|
||||||
result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||||
if view_type != 'tree':
|
if view_type != 'tree':
|
||||||
#Remove the toolbar from the form view
|
#Remove the toolbar from the form view
|
||||||
if view_type == 'form':
|
if view_type == 'form':
|
||||||
result['toolbar']['action'] = []
|
if result.get('toolbar', False):
|
||||||
|
result['toolbar']['action'] = []
|
||||||
|
|
||||||
#Restrict the list of journal view in search view
|
#Restrict the list of journal view in search view
|
||||||
if view_type == 'search':
|
if view_type == 'search':
|
||||||
journal_list = journal_pool.name_search(cr, uid, '', [], context=context)
|
journal_list = journal_pool.name_search(cr, uid, '', [], context=context)
|
||||||
result['fields']['journal_id']['selection'] = journal_list
|
result['fields']['journal_id']['selection'] = journal_list
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if context.get('view_mode', False):
|
if context.get('view_mode', False):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
fld = []
|
fld = []
|
||||||
fields = {}
|
fields = {}
|
||||||
flds = []
|
flds = []
|
||||||
|
@ -912,14 +913,14 @@ class account_move_line(osv.osv):
|
||||||
attrs = []
|
attrs = []
|
||||||
if field == 'debit':
|
if field == 'debit':
|
||||||
attrs.append('sum="Total debit"')
|
attrs.append('sum="Total debit"')
|
||||||
|
|
||||||
elif field == 'credit':
|
elif field == 'credit':
|
||||||
attrs.append('sum="Total credit"')
|
attrs.append('sum="Total credit"')
|
||||||
|
|
||||||
elif field == 'account_tax_id':
|
elif field == 'account_tax_id':
|
||||||
attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
|
attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
|
||||||
attrs.append("context=\"{'journal_id':journal_id}\"")
|
attrs.append("context=\"{'journal_id':journal_id}\"")
|
||||||
|
|
||||||
elif field == 'account_id' and journal.id:
|
elif field == 'account_id' and journal.id:
|
||||||
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
|
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
|
||||||
|
|
||||||
|
@ -937,7 +938,7 @@ class account_move_line(osv.osv):
|
||||||
|
|
||||||
if field in ('amount_currency', 'currency_id'):
|
if field in ('amount_currency', 'currency_id'):
|
||||||
attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"')
|
attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"')
|
||||||
|
|
||||||
if field in widths:
|
if field in widths:
|
||||||
attrs.append('width="'+str(widths[field])+'"')
|
attrs.append('width="'+str(widths[field])+'"')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue