[IMP] account: improved the onchange of journal field.

bzr revid: vra@tinyerp.com-20100917090204-l6pq10n421zuw20b
This commit is contained in:
vra 2010-09-17 14:32:04 +05:30
parent 72f88ecf49
commit a4c243a087
2 changed files with 7 additions and 10 deletions

View File

@ -150,7 +150,7 @@
<field name="arch" type="xml">
<form string="Supplier invoice">
<group col="8" colspan="4">
<field domain="[('type', '=', 'purchase')]" name="journal_id" on_change="onchange_journal_id(journal_id, company_id)"/>
<field domain="[('type', '=', 'purchase')]" name="journal_id" on_change="onchange_journal_id(journal_id)"/>
<field name="number" readonly="1"/>
<field name="type" invisible="1"/>
<field name="currency_id" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
@ -260,7 +260,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, company_id)"/>
<field name="journal_id" groups="base.group_user" on_change="onchange_journal_id(journal_id)"/>
<field name="number"/>
<field name="type" invisible="1"/>
<field name="currency_id" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>

View File

@ -452,8 +452,7 @@ class account_invoice(osv.osv):
_('Can not select currency that is not related to current company.\nPlease select accordingly !.'))
return {}
def onchange_journal_id(self, cr, uid, ids, journal_id, company_id):
result = {}
def onchange_journal_id(self, cr, uid, ids, journal_id):
if journal_id:
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
if journal.currency:
@ -462,12 +461,11 @@ class account_invoice(osv.osv):
}
}
return result
if company_id:
company = self.pool.get('res.company').browse(cr, uid, company_id)
result = {'value': {
'currency_id': company.currency_id.id
}
user_company = self.pool.get('res.users').browse(cr, uid, [uid])[0].company_id
result = {'value': {
'currency_id': user_company.currency_id.id
}
}
return result
def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):
@ -568,7 +566,6 @@ class account_invoice(osv.osv):
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: