[IMP/FIX] account: improvements related to multi company

*removed domain on currency_id field in invoice form view
*fixed conditions on currency_id.company_id (not mandatory)

bzr revid: qdp-launchpad@tinyerp.com-20100818151903-9147syg4kxjrp08z
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-08-18 17:19:03 +02:00
parent 7ddaee4694
commit 195ac98256
2 changed files with 5 additions and 10 deletions

View File

@ -153,7 +153,7 @@
<field domain="[('type', '=', 'purchase')]" name="journal_id"/>
<field name="number" readonly="1"/>
<field name="type" invisible="1"/>
<field name="currency_id" domain="[('company_id','=', company_id)]" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
<field name="currency_id" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
<button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
<newline/>
<field name="partner_id" domain="[('supplier','=', 1)]" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" context="{'default_customer': 0}"/>
@ -262,7 +262,7 @@
<field name="journal_id" groups="base.group_user"/>
<field name="number"/>
<field name="type" invisible="1"/>
<field name="currency_id" domain="[('company_id','=', company_id)]" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
<field name="currency_id" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
<button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
<newline/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" groups="base.group_user"/>

View File

@ -539,22 +539,21 @@ class account_invoice(osv.osv):
if journal_ids:
val['journal_id'] = journal_ids[0]
else:
raise osv.except_osv(_('Configuration Error !'),
_('Can not find account journal for this company in invoice, Please Create journal.'))
raise osv.except_osv(_('Configuration Error !'), _('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.' % (journal_type)))
dom = {'journal_id': [('id', 'in', journal_ids)]}
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.id != company_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.id != 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
@ -1386,10 +1385,6 @@ class account_invoice_line(osv.osv):
company = self.pool.get('res.company').browse(cr, uid, company_id)
currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
if not currency.company_id.id == company.id:
raise osv.except_osv(_('Configuration Error !'),
_('Can not select currency that is not related to any company.\nPlease select accordingly !.'))
if company.currency_id.id != currency.id:
new_price = res_final['value']['price_unit'] * currency.rate
res_final['value']['price_unit'] = new_price