diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py
index d133b994..595c1201 100644
--- a/account_easy_reconcile/base_reconciliation.py
+++ b/account_easy_reconcile/base_reconciliation.py
@@ -215,10 +215,32 @@ class EasyReconcileBase(orm.AbstractModel):
if set(line_ids) == partial_line_ids:
return True, False
+ # We need to give a writeoff_acc_id
+ # in case we have a multi currency lines
+ # to reconcile.
+ # If amount in currency is equal between
+ # lines to reconcile
+ # it will do a full reconcile instead of a partial reconcile
+ # and make a write-off for exchange
+ if rec.account_id.currency_id:
+ if sum_credit > sum_debit:
+ writeoff_account_id = rec.income_exchange_account_id.id
+ else:
+ writeoff_account_id = rec.expense_exchange_account_id.id
+ period_id = self.pool.get('account.period').find(
+ cr, uid, dt=date, context=context)[0]
+ if rec.analytic_account_id:
+ rec_ctx['analytic_id'] = rec.analytic_account_id.id
+ else:
+ writeoff_account_id = False
+ period_id = False
ml_obj.reconcile_partial(
cr, uid,
line_ids,
type='manual',
+ writeoff_acc_id=writeoff_account_id,
+ writeoff_period_id=period_id,
+ writeoff_journal_id=rec.journal_id.id,
context=rec_ctx)
return True, False
return False, False
diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py
index b3a14388..bb598605 100644
--- a/account_easy_reconcile/easy_reconcile.py
+++ b/account_easy_reconcile/easy_reconcile.py
@@ -47,6 +47,14 @@ class EasyReconcileOptions(orm.AbstractModel):
('newest_debit', 'Date of most recent debit')
]
+ def _get_account_currency(self, cr, uid, ids, field_name, arg,
+ context=None):
+ result = {}
+ for line in self.browse(cr, uid, ids, context=context):
+ # Always provide second currency
+ result[line.id] = bool(line.task_id.account.currency_id.id)
+ return result
+
_columns = {
'write_off': fields.float('Write off allowed'),
'account_lost_id': fields.many2one(
@@ -63,6 +71,16 @@ class EasyReconcileOptions(orm.AbstractModel):
'analytic_account_id': fields.many2one(
'account.analytic.account', 'Analytic Account',
help="Analytic account for the write-off"),
+ 'account_has_currency': fields.function(
+ _get_account_currency,
+ type='boolean',
+ string='has currency',
+ help="Check if related account has currency."),
+ 'income_exchange_account_id': fields.many2one(
+ 'account.account', 'Gain Exchange Rate Account'),
+ 'expense_exchange_account_id': fields.many2one(
+ 'account.account', 'Loss Exchange Rate Account'),
+
}
_defaults = {
@@ -210,6 +228,12 @@ class AccountEasyReconcile(orm.Model):
rec_method.account_profit_id.id),
'analytic_account_id': (rec_method.analytic_account_id and
rec_method.analytic_account_id.id),
+ 'income_exchange_account_id':
+ (rec_method.income_exchange_account_id and
+ rec_method.income_exchange_account_id.id),
+ 'expense_exchange_account_id':
+ (rec_method.income_exchange_account_id and
+ rec_method.income_exchange_account_id.id),
'journal_id': (rec_method.journal_id and
rec_method.journal_id.id),
'date_base_on': rec_method.date_base_on,
diff --git a/account_easy_reconcile/easy_reconcile.xml b/account_easy_reconcile/easy_reconcile.xml
index d191fbb8..c23c7f05 100644
--- a/account_easy_reconcile/easy_reconcile.xml
+++ b/account_easy_reconcile/easy_reconcile.xml
@@ -129,6 +129,9 @@ The lines should have the same amount (with the write-off) and the same referenc
+
+
+
@@ -147,6 +150,9 @@ The lines should have the same amount (with the write-off) and the same referenc
+
+
+