[FIX] account, analytic: add analytic distribution, remove precompute
Related to https://github.com/odoo/enterprise/pull/52648 we add the analytic distributino to the move vals for the exchange diff move. We also remove the precompute on the fields, manual backport of https://github.com/odoo/odoo/commit/b9047febf3c4d67ce409f9f1dba8a9cc7c7165fe opw-3603668 closes odoo/odoo#147332 X-original-commit: 41b38f1dc7df824e6c09e66e293e82f2823915aa Related: odoo/enterprise#53322 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com> Signed-off-by: Guillaume Vanleynseele (guva) <guva@odoo.com>
This commit is contained in:
@@ -2561,7 +2561,7 @@ class AccountMoveLine(models.Model):
|
||||
|
||||
return partials
|
||||
|
||||
def _prepare_exchange_difference_move_vals(self, amounts_list, company=None, exchange_date=None):
|
||||
def _prepare_exchange_difference_move_vals(self, amounts_list, company=None, exchange_date=None, **kwargs):
|
||||
""" Prepare values to create later the exchange difference journal entry.
|
||||
The exchange difference journal entry is there to fix the debit/credit of lines when the journal items are
|
||||
fully reconciled in foreign currency.
|
||||
@@ -2625,8 +2625,8 @@ class AccountMoveLine(models.Model):
|
||||
exchange_line_account = income_exchange_account
|
||||
|
||||
sequence = len(move_vals['line_ids'])
|
||||
move_vals['line_ids'] += [
|
||||
Command.create({
|
||||
line_vals = [
|
||||
{
|
||||
'name': _('Currency exchange rate difference'),
|
||||
'debit': -amount_residual if amount_residual < 0.0 else 0.0,
|
||||
'credit': amount_residual if amount_residual > 0.0 else 0.0,
|
||||
@@ -2635,8 +2635,8 @@ class AccountMoveLine(models.Model):
|
||||
'currency_id': line.currency_id.id,
|
||||
'partner_id': line.partner_id.id,
|
||||
'sequence': sequence,
|
||||
}),
|
||||
Command.create({
|
||||
},
|
||||
{
|
||||
'name': _('Currency exchange rate difference'),
|
||||
'debit': amount_residual if amount_residual > 0.0 else 0.0,
|
||||
'credit': -amount_residual if amount_residual < 0.0 else 0.0,
|
||||
@@ -2645,8 +2645,13 @@ class AccountMoveLine(models.Model):
|
||||
'currency_id': line.currency_id.id,
|
||||
'partner_id': line.partner_id.id,
|
||||
'sequence': sequence + 1,
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
if kwargs.get('exchange_analytic_distribution'):
|
||||
line_vals[1].update({'analytic_distribution': kwargs['exchange_analytic_distribution']})
|
||||
|
||||
move_vals['line_ids'] += [Command.create(vals) for vals in line_vals]
|
||||
to_reconcile.append((line, sequence))
|
||||
|
||||
return {'move_values': move_vals, 'to_reconcile': to_reconcile}
|
||||
|
||||
Reference in New Issue
Block a user