[FIX] account, invoice: removed the default value of currency_id field, as it should be given by the onchange of journal_id (which has a default value)
bzr revid: qdp-launchpad@openerp.com-20120201141633-mclcw5n7v9c5789h
This commit is contained in:
parent
c40a0d9234
commit
3da9e71711
|
@ -57,12 +57,6 @@ class account_invoice(osv.osv):
|
|||
limit=1)
|
||||
return res and res[0] or False
|
||||
|
||||
def _get_currency(self, cr, uid, context=None):
|
||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid], context=context)[0]
|
||||
if user.company_id:
|
||||
return user.company_id.currency_id.id
|
||||
return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=', 1.0)])[0]
|
||||
|
||||
def _get_journal_analytic(self, cr, uid, type_inv, context=None):
|
||||
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
|
||||
tt = type2journal.get(type_inv, 'sale')
|
||||
|
@ -279,7 +273,6 @@ class account_invoice(osv.osv):
|
|||
'type': _get_type,
|
||||
'state': 'draft',
|
||||
'journal_id': _get_journal,
|
||||
'currency_id': _get_currency,
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
|
||||
'reference_type': 'none',
|
||||
'check_total': 0.0,
|
||||
|
@ -464,10 +457,10 @@ class account_invoice(osv.osv):
|
|||
result['value'].update(to_update['value'])
|
||||
return result
|
||||
|
||||
def onchange_journal_id(self, cr, uid, ids, journal_id=False):
|
||||
def onchange_journal_id(self, cr, uid, ids, journal_id=False, context=None):
|
||||
result = {}
|
||||
if journal_id:
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context)
|
||||
currency_id = journal.currency and journal.currency.id or journal.company_id.currency_id.id
|
||||
result = {'value': {
|
||||
'currency_id': currency_id,
|
||||
|
@ -572,18 +565,6 @@ class account_invoice(osv.osv):
|
|||
else:
|
||||
journal_ids = obj_journal.search(cr, uid, [])
|
||||
|
||||
if currency_id and company_id:
|
||||
currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
|
||||
if currency.company_id and currency.company_id.id != company_id:
|
||||
val['currency_id'] = False
|
||||
else:
|
||||
val['currency_id'] = currency.id
|
||||
if company_id:
|
||||
company = self.pool.get('res.company').browse(cr, uid, company_id)
|
||||
if company.currency_id.company_id and company.currency_id.company_id.id != company_id:
|
||||
val['currency_id'] = False
|
||||
else:
|
||||
val['currency_id'] = company.currency_id.id
|
||||
return {'value': val, 'domain': dom}
|
||||
|
||||
# go from canceled state to draft state
|
||||
|
|
|
@ -256,7 +256,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Invoice">
|
||||
<group colspan="4" col="8">
|
||||
<field name="journal_id" groups="base.group_user" on_change="onchange_journal_id(journal_id)" widget="selection"/>
|
||||
<field name="journal_id" groups="base.group_user" on_change="onchange_journal_id(journal_id, context)" widget="selection"/>
|
||||
<field name="number"/>
|
||||
<field name="type" invisible="1"/>
|
||||
<field name="currency_id" width="50"/>
|
||||
|
|
Loading…
Reference in New Issue