diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 6ad1d83021c..979e17690a8 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -700,7 +700,7 @@ class AccountInvoice(models.Model): total_currency = 0 for line in invoice_move_lines: if self.currency_id != company_currency: - currency = self.currency_id.with_context(date=self.date or self.date_invoice or fields.Date.context_today(self)) + currency = self.currency_id.with_context(date=self._get_currency_rate_date() or fields.Date.context_today(self)) if not (line.get('currency_id') and line.get('amount_currency')): line['currency_id'] = currency.id line['amount_currency'] = currency.round(line['price']) @@ -848,7 +848,7 @@ class AccountInvoice(models.Model): if inv.payment_term_id: totlines = inv.with_context(ctx).payment_term_id.with_context(currency_id=company_currency.id).compute(total, inv.date_invoice)[0] res_amount_currency = total_currency - ctx['date'] = inv.date or inv.date_invoice + ctx['date'] = inv._get_currency_rate_date() for i, t in enumerate(totlines): if inv.currency_id != company_currency: amount_currency = company_currency.with_context(ctx).compute(t[1], inv.currency_id) @@ -1035,6 +1035,9 @@ class AccountInvoice(models.Model): copy_fields = ['company_id', 'user_id', 'fiscal_position_id'] return self._get_refund_common_fields() + self._get_refund_prepare_fields() + copy_fields + def _get_currency_rate_date(self): + return self.date or self.date_invoice + @api.model def _prepare_refund(self, invoice, date_invoice=None, date=None, description=None, journal_id=None): """ Prepare the dict of values to create the new refund from the invoice. @@ -1194,7 +1197,7 @@ class AccountInvoiceLine(models.Model): @api.one @api.depends('price_unit', 'discount', 'invoice_line_tax_ids', 'quantity', 'product_id', 'invoice_id.partner_id', 'invoice_id.currency_id', 'invoice_id.company_id', - 'invoice_id.date_invoice') + 'invoice_id.date_invoice', 'invoice_id.date') def _compute_price(self): currency = self.invoice_id and self.invoice_id.currency_id or None price = self.price_unit * (1 - (self.discount or 0.0) / 100.0) @@ -1203,7 +1206,7 @@ class AccountInvoiceLine(models.Model): taxes = self.invoice_line_tax_ids.compute_all(price, currency, self.quantity, product=self.product_id, partner=self.invoice_id.partner_id) self.price_subtotal = price_subtotal_signed = taxes['total_excluded'] if taxes else self.quantity * price if self.invoice_id.currency_id and self.invoice_id.company_id and self.invoice_id.currency_id != self.invoice_id.company_id.currency_id: - price_subtotal_signed = self.invoice_id.currency_id.with_context(date=self.invoice_id.date_invoice).compute(price_subtotal_signed, self.invoice_id.company_id.currency_id) + price_subtotal_signed = self.invoice_id.currency_id.with_context(date=self.invoice_id._get_currency_rate_date()).compute(price_subtotal_signed, self.invoice_id.company_id.currency_id) sign = self.invoice_id.type in ['in_refund', 'out_refund'] and -1 or 1 self.price_subtotal_signed = price_subtotal_signed * sign diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 79c539dcacf..f4d5b75cd86 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -165,6 +165,8 @@ class AccountMove(models.Model): if not move.journal_id.update_posted: raise UserError(_('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.')) if self.ids: + self.check_access_rights('write') + self.check_access_rule('write') self._check_lock_date() self._cr.execute('UPDATE account_move '\ 'SET state=%s '\ diff --git a/addons/account/views/report_overdue.xml b/addons/account/views/report_overdue.xml index 3b7d3808100..a413e77d0d3 100644 --- a/addons/account/views/report_overdue.xml +++ b/addons/account/views/report_overdue.xml @@ -16,7 +16,7 @@

- + diff --git a/addons/account_budget/views/account_budget_views.xml b/addons/account_budget/views/account_budget_views.xml index 21635db40a4..f94b29bfd43 100644 --- a/addons/account_budget/views/account_budget_views.xml +++ b/addons/account_budget/views/account_budget_views.xml @@ -96,7 +96,7 @@ - + @@ -110,7 +110,7 @@ - +