return False
def _get_payment_rate_currency(self, cr, uid, context=None):
+ '''
+ Return the default value for field payment_rate_currency_id: the currency of the journal
+ if there is one, otherwise the currency of the user's company
+ '''
if context is None: context = {}
journal_pool = self.pool.get('account.journal')
journal_id = context.get('journal_id', False)
('without_writeoff', 'Keep Open'),
('with_writeoff', 'Reconcile Payment Balance'),
], 'Payment Difference', required=True, readonly=True, states={'draft': [('readonly', False)]}),
- 'exchange_acc_id': fields.many2one('account.account', 'Exchange Diff. Account', readonly=True, states={'draft': [('readonly', False)]}),
'writeoff_acc_id': fields.many2one('account.account', 'Counterpart Account', readonly=True, states={'draft': [('readonly', False)]}),
'comment': fields.char('Counterpart Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}),
:return: the account move line and its counterpart to create, depicted as mapping between fieldname and value
:rtype: tuple of dict
'''
- if not line.voucher_id.exchange_acc_id.id:
- raise osv.except_osv(_('Error!'), _('You must provide an account for the exchange difference.'))
+ if amount_residual > 0:
+ account_id = line.voucher_id.company_id.expense_currency_exchange_account_id
+ if not account_id:
+ raise osv.except_osv(_('Warning'),_("Unable to create accounting entry for currency rate difference. You have to configure the field 'Income Currency Rate' on the company! "))
+ else:
+ account_id = line.voucher_id.company_id.income_currency_exchange_account_id
+ if not account_id:
+ raise osv.except_osv(_('Warning'),_("Unable to create accounting entry for currency rate difference. You have to configure the field 'Expense Currency Rate' on the company! "))
move_line = {
'journal_id': line.voucher_id.journal_id.id,
'journal_id': line.voucher_id.journal_id.id,
'period_id': line.voucher_id.period_id.id,
'name': _('change')+': '+(line.name or '/'),
- 'account_id': line.voucher_id.exchange_acc_id.id,
+ 'account_id': account_id.id,
'move_id': move_id,
'amount_currency': 0.0,
'partner_id': line.voucher_id.partner_id.id,
# We automatically reconcile the account move lines.
for rec_ids in rec_list_ids:
if len(rec_ids) >= 2:
- move_line_pool.reconcile_partial(cr, uid, rec_ids, writeoff_acc_id=voucher.exchange_acc_id.id, writeoff_period_id=voucher.period_id.id, writeoff_journal_id=voucher.journal_id.id)
+ move_line_pool.reconcile_partial(cr, uid, rec_ids, writeoff_acc_id=voucher.writeoff_acc_id.id, writeoff_period_id=voucher.period_id.id, writeoff_journal_id=voucher.journal_id.id)
return True
def copy(self, cr, uid, id, default={}, context=None):
results.append(result)
return results
+class res_company(osv.osv):
+ _inherit = "res.company"
+ _columns = {
+ 'income_currency_exchange_account_id': fields.many2one(
+ 'account.account',
+ string="Income Currency Rate",
+ domain="[('type', '=', 'other')]",),
+ 'expense_currency_exchange_account_id': fields.many2one(
+ 'account.account',
+ string="Expense Currency Rate",
+ domain="[('type', '=', 'other')]",),
+ }
+
+res_company()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
</field>
</record>
+ <!-- res.company form view -->
+ <record model="ir.ui.view" id="view_company_inherit_currency_xchange_form">
+ <field name="name">res.company.form.inherit</field>
+ <field name="inherit_id" ref="base.view_company_form"/>
+ <field name="model">res.company</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <field name="currency_id" position="after">
+ <field name="income_currency_exchange_account_id" colspan="2"/>
+ <field name="expense_currency_exchange_account_id" colspan="2"/>
+ </field>
+ </field>
+ </record>
+
</data>
</openerp>
In order to check the Account_voucher module with multi-currency in OpenERP,
I create 2 Invoices in USD and make 2 Payments in USD based on the currency rating on that particular date
-
+ I set the income and expense currency accounts on the main company
+-
+ !python {model: res.company}: |
+ from datetime import datetime
+ vals = {
+ 'income_currency_exchange_account_id': ref('account.o_expense'),
+ 'expense_currency_exchange_account_id': ref('account.o_expense')}
+ self.write(cr, uid, ref('base.main_company'), vals)
+-
I create currency USD in OpenERP for January of 1.333333 Rate
-
!python {model: res.currency.rate}: |
date: !eval time.strftime("%Y-04-01")
payment_option: 'with_writeoff'
writeoff_acc_id: account.a_expense
- exchange_acc_id: account.o_expense
comment: 'Write Off'
-
I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$
In order to check the Account_voucher module with multi-currency in OpenERP,
I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
-
+ I set the income and expense currency accounts on the main company
+-
+ !python {model: res.company}: |
+ from datetime import datetime
+ vals = {
+ 'income_currency_exchange_account_id': ref('account.o_expense'),
+ 'expense_currency_exchange_account_id': ref('account.o_expense')}
+ self.write(cr, uid, ref('base.main_company'), vals)
+-
I create a bank journal with EUR as currency
-
!record {model: account.journal, id: bank_journal_EUR}:
In order to check the Account_voucher module with multi-currency in OpenERP,
I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
-
+ I set the income and expense currency accounts on the main company
+-
+ !python {model: res.company}: |
+ from datetime import datetime
+ vals = {
+ 'income_currency_exchange_account_id': ref('account.o_expense'),
+ 'expense_currency_exchange_account_id': ref('account.o_expense')}
+ self.write(cr, uid, ref('base.main_company'), vals)
+-
I modify the debtor account in order to make sure there is no currency_id linked
-
!python {model: account.account}: |
date: !eval time.strftime("%Y-04-01")
payment_option: 'with_writeoff'
writeoff_acc_id: account.a_expense
- exchange_acc_id: account.o_expense
comment: 'Write Off'
name: 'Second payment: Case 2 SUPPL USD/EUR DR EUR'
In order to check the Account_voucher module with multi-currency in OpenERP,
I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
-
+ I set the income and expense currency accounts on the main company
+-
+ !python {model: res.company}: |
+ from datetime import datetime
+ vals = {
+ 'income_currency_exchange_account_id': ref('account.o_expense'),
+ 'expense_currency_exchange_account_id': ref('account.o_expense')}
+ self.write(cr, uid, ref('base.main_company'), vals)
+-
I modify the debtor account in order to set the currency_id = USD
-
!python {model: account.account}: |
date: !eval time.strftime("%Y-04-01")
payment_option: 'with_writeoff'
writeoff_acc_id: account.a_expense
- exchange_acc_id: account.o_expense
comment: 'Write Off'
name: 'Second payment: Case 2 SUPPL USD/EUR DR USD'
In order to check the Account_voucher module with multi-currency in OpenERP,
I create an invoice in CAD and make its Payment in CHF based on the currency rating on that particular date.
-
+ I set the income and expense currency accounts on the main company
+-
+ !python {model: res.company}: |
+ from datetime import datetime
+ vals = {
+ 'income_currency_exchange_account_id': ref('account.o_expense'),
+ 'expense_currency_exchange_account_id': ref('account.o_expense')}
+ self.write(cr, uid, ref('base.main_company'), vals)
+-
I create currency CAD in OpenERP for January of 1.338800 Rate
-
!record {model: res.currency.rate, id: jan_cad}:
date: !eval time.strftime("%Y-03-01")
payment_option: 'with_writeoff'
writeoff_acc_id: account.a_expense
- exchange_acc_id: account.o_expense
comment: 'Write Off'
name: 'First payment: Case 4'
-
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
on_change="onchange_move_line_id(move_line_id)"
domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
- required="1" readonly="1"
+ required="1"
/>
<field name="account_id" groups="base.group_no_one" domain="[('type','=','payable')]"/>
<field name="date_original" readonly="1"/>
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
on_change="onchange_move_line_id(move_line_id)"
domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
- required="1" readonly="1"
+ required="1"
/>
<field name="account_id" groups="base.group_no_one" domain="[('type','=','payable')]"/>
<field name="date_original" readonly="1"/>
<group col="2" colspan="1">
<group col="4" colspan="1" attrs="{'invisible':[('currency_id','=',False)]}">
<separator string="Currency Options" colspan="4"/>
- <field name="exchange_acc_id"
- domain="[('type','=','other')]" colspan="4"/>
<field name="payment_rate" required="1" on_change="onchange_rate(payment_rate, amount, currency_id, payment_rate_currency_id, company_id, context)" groups='base.group_extended' colspan="3"/>
<field name="payment_rate_currency_id" groups='base.group_extended' colspan="1" nolabel="1" on_change="onchange_payment_rate_currency(currency_id, payment_rate, payment_rate_currency_id, date, amount, company_id, context)"/>
<field name="paid_amount_in_company_currency" groups='base.group_extended' colspan="4"/>
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
on_change="onchange_move_line_id(move_line_id)"
domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
- required="1" readonly="1"
+ required="1"
/>
<field name="account_id" groups="base.group_no_one" domain="[('type','=','receivable')]"/>
<field name="date_original" readonly="1"/>
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
on_change="onchange_move_line_id(move_line_id)"
domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
- required="1" readonly="1"
+ required="1"
/>
<field name="account_id" groups="base.group_no_one" domain="[('type','=','receivable')]"/>
<field name="date_original" readonly="1"/>
<group col="2" colspan="1">
<group col="4" colspan="1" attrs="{'invisible':[('currency_id','=',False)]}">
<separator string="Currency Options" colspan="4"/>
- <field name="exchange_acc_id"
- domain="[('type','=','other')]" colspan="4"/>
<field name="payment_rate" required="1" on_change="onchange_rate(payment_rate, amount, currency_id, payment_rate_currency_id, company_id, context)" groups='base.group_extended' colspan="3"/>
<field name="payment_rate_currency_id" groups='base.group_extended' colspan="1" nolabel="1" on_change="onchange_payment_rate_currency(currency_id, payment_rate, payment_rate_currency_id, date, amount, company_id, context)"/>
<field name="paid_amount_in_company_currency" groups='base.group_extended' colspan="4"/>