From 2571215d3d911deaed91883c4dadbc0c4d6a19cd Mon Sep 17 00:00:00 2001 From: Thomas Binsfeld Date: Mon, 25 Feb 2019 10:26:06 +0100 Subject: [PATCH] [REF] Account Invoice Constraint Chronology: better messages --- account_invoice_constraint_chronology/i18n/fr.po | 4 ++-- .../model/account_invoice.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/account_invoice_constraint_chronology/i18n/fr.po b/account_invoice_constraint_chronology/i18n/fr.po index fc43c297..78608f30 100644 --- a/account_invoice_constraint_chronology/i18n/fr.po +++ b/account_invoice_constraint_chronology/i18n/fr.po @@ -32,7 +32,7 @@ msgid "" "and try again." msgstr "" "Erreur de chronologie. Veuillez confirmer les anciennes factures brouillon " -"avant %set réessayer." +"avant le {date_invoice} et réessayer." #. module: account_invoice_constraint_chronology #: code:addons/account_invoice_constraint_chronology/model/account_invoice.py:66 @@ -42,7 +42,7 @@ msgid "" "{date_invoice}." msgstr "" "Erreur de chronologie. Il existe au moins une facture avec une date " -"ultérieure à %s." +"ultérieure au {date_invoice}." #. module: account_invoice_constraint_chronology #: model:ir.model,name:account_invoice_constraint_chronology.model_account_invoice diff --git a/account_invoice_constraint_chronology/model/account_invoice.py b/account_invoice_constraint_chronology/model/account_invoice.py index 0b167acb..1eab68a6 100644 --- a/account_invoice_constraint_chronology/model/account_invoice.py +++ b/account_invoice_constraint_chronology/model/account_invoice.py @@ -5,6 +5,7 @@ import datetime from odoo import models, api, fields, _ from odoo.exceptions import UserError +from odoo.tools.misc import format_date class AccountInvoice(models.Model): @@ -46,8 +47,9 @@ class AccountInvoice(models.Model): month=inv.date_invoice.month, day=inv.date_invoice.day, ) - date_invoice_tz = fields.Date.context_today( - self, date_invoice_format) + date_invoice_tz = format_date( + self.env, fields.Date.context_today( + self, date_invoice_format)) raise UserError(_( "Chronology Error. Please confirm older draft invoices " "before {date_invoice} and try again.").format( @@ -61,8 +63,9 @@ class AccountInvoice(models.Model): month=inv.date_invoice.month, day=inv.date_invoice.day, ) - date_invoice_tz = fields.Date.context_today( - self, date_invoice_format) + date_invoice_tz = format_date( + self.env, fields.Date.context_today( + self, date_invoice_format)) raise UserError(_( "Chronology Error. There exist at least one invoice " "with a later date to {date_invoice}.").format(