diff options
| author | Laurent Smet <las@odoo.com> | 2020-04-29 08:26:56 +0000 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2020-08-13 11:48:06 +0000 |
| commit | 419d4bbee04763367fef675a01dc73afa9758b2f (patch) | |
| tree | d87f483241c422112535a9a7e951ceba58c06b6a /addons/account/wizard | |
| parent | a37a746b4e0060c834dd700a511ff61350831d1d (diff) | |
[IMP] account, *: Required currency on journal items
closes odoo/odoo#50711
Task: 1930680
Related: odoo/enterprise#10394
Related: odoo/upgrade#1147
Signed-off-by: Cedric Snauwaert (csn) <csn@openerp.com>
Diffstat (limited to 'addons/account/wizard')
| -rw-r--r-- | addons/account/wizard/account_automatic_entry_wizard.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/addons/account/wizard/account_automatic_entry_wizard.py b/addons/account/wizard/account_automatic_entry_wizard.py index 2259dacb922..c3f5cb49b47 100644 --- a/addons/account/wizard/account_automatic_entry_wizard.py +++ b/addons/account/wizard/account_automatic_entry_wizard.py @@ -112,9 +112,7 @@ class AutomaticEntryWizard(models.TransientModel): counterpart_currency = self.destination_account_id.currency_id counterpart_amount_currency = self.company_id.currency_id._convert(line.balance, self.destination_account_id.currency_id, self.company_id, line.date) - if counterpart_currency: - counterpart_balances[(line.partner_id, counterpart_currency)]['amount_currency'] += counterpart_amount_currency - + counterpart_balances[(line.partner_id, counterpart_currency)]['amount_currency'] += counterpart_amount_currency counterpart_balances[(line.partner_id, counterpart_currency)]['balance'] += line.balance grouped_source_lines[(line.partner_id, line.currency_id, line.account_id)] += line @@ -123,29 +121,29 @@ class AutomaticEntryWizard(models.TransientModel): source_accounts = self.move_line_ids.mapped('account_id') counterpart_label = len(source_accounts) == 1 and _("Transfer from %s", source_accounts.display_name) or _("Transfer counterpart") - if not self.company_id.currency_id.is_zero(counterpart_vals['balance']) or (counterpart_currency and not counterpart_currency.is_zero(counterpart_vals['amount_currency'])): + if not counterpart_currency.is_zero(counterpart_vals['amount_currency']): line_vals.append({ 'name': counterpart_label, 'debit': counterpart_vals['balance'] > 0 and self.company_id.currency_id.round(counterpart_vals['balance']) or 0, 'credit': counterpart_vals['balance'] < 0 and self.company_id.currency_id.round(-counterpart_vals['balance']) or 0, 'account_id': self.destination_account_id.id, 'partner_id': counterpart_partner.id or None, - 'amount_currency': counterpart_currency and counterpart_currency.round((counterpart_vals['balance'] < 0 and -1 or 1) * abs(counterpart_vals['amount_currency'])) or 0, - 'currency_id': counterpart_currency.id or None, + 'amount_currency': counterpart_currency.round((counterpart_vals['balance'] < 0 and -1 or 1) * abs(counterpart_vals['amount_currency'])) or 0, + 'currency_id': counterpart_currency.id, }) # Generate change_account lines' vals for (partner, currency, account), lines in grouped_source_lines.items(): account_balance = sum(line.balance for line in lines) - if not (currency or self.company_id.currency_id).is_zero(account_balance): - account_amount_currency = currency and currency.round(sum(line.amount_currency for line in lines)) or 0 + if not self.company_id.currency_id.is_zero(account_balance): + account_amount_currency = currency.round(sum(line.amount_currency for line in lines)) line_vals.append({ 'name': _('Transfer to %s', self.destination_account_id.display_name or _('[Not set]')), 'debit': account_balance < 0 and self.company_id.currency_id.round(-account_balance) or 0, 'credit': account_balance > 0 and self.company_id.currency_id.round(account_balance) or 0, 'account_id': account.id, 'partner_id': partner.id or None, - 'currency_id': currency.id or None, + 'currency_id': currency.id, 'amount_currency': (account_balance > 0 and -1 or 1) * abs(account_amount_currency), }) @@ -188,10 +186,7 @@ class AutomaticEntryWizard(models.TransientModel): # account.move.line data reported_debit = aml.company_id.currency_id.round((self.percentage / 100) * aml.debit) reported_credit = aml.company_id.currency_id.round((self.percentage / 100) * aml.credit) - if aml.currency_id: - reported_amount_currency = aml.currency_id.round((self.percentage / 100) * aml.amount_currency) - else: - reported_amount_currency = 0.0 + reported_amount_currency = aml.currency_id.round((self.percentage / 100) * aml.amount_currency) move_data['new_date']['line_ids'] += [ (0, 0, { |
