From b4bb7b14b2eb820719f347bd6516708724166d79 Mon Sep 17 00:00:00 2001
From: Bernat Brunet Torruella <bernat@nan-tic.com>
Date: Tue, 16 May 2017 17:28:27 +0200
Subject: [PATCH] Add more information in the sale error message

---
 locale/ca_ES.po | 9 ++-------
 locale/es_ES.po | 4 ++--
 sale.py         | 4 ++--
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/locale/ca_ES.po b/locale/ca_ES.po
index 326db46..fa02071 100644
--- a/locale/ca_ES.po
+++ b/locale/ca_ES.po
@@ -58,11 +58,6 @@ msgctxt "error:res.user:"
 msgid "You can not have two users with the same login!"
 msgstr "No podeu tenir dos usuaris amb el mateix identificador d'entrada."
 
-msgctxt "error:sale.payment:"
-msgid "A customer invoice/refund from sale device has not been created."
-msgstr ""
-"Una factura/devolució d'un terminal de venda no s'ha creat."
-
 msgctxt "error:sale.payment:"
 msgid "A draft statement for \"%s\" payments has not been created."
 msgstr "Un extracte esborrany per \"%s\" pagaments no s'ha creat."
@@ -78,9 +73,9 @@ msgid "You have not defined a sale device for your user."
 msgstr "No heu definit un terminal de venda per al vostre usuari."
 
 msgctxt "error:sale.sale:"
-msgid "A customer invoice/refund from sale device has not been created."
+msgid "A customer invoice/refund from sale device (%s) has not been created."
 msgstr ""
-"Una factura/devolució d'un terminal de venda no s'ha creat."
+"Una factura/devolució d'un terminal de venda (%s) no s'ha creat."
 
 msgctxt "error:sale.sale:"
 msgid "Go to user preferences and select a shop (\"%s\")"
diff --git a/locale/es_ES.po b/locale/es_ES.po
index dd8c6b8..ddf6eb2 100644
--- a/locale/es_ES.po
+++ b/locale/es_ES.po
@@ -53,8 +53,8 @@ msgid "You have not defined a sale device for your user."
 msgstr "No ha definido un terminal de venta para su usuario."
 
 msgctxt "error:sale.sale:"
-msgid "A customer invoice/refund from sale device has not been created."
-msgstr "Una factura/devolución del terminal de venta no se ha creado."
+msgid "A customer invoice/refund from sale device (%s) has not been created."
+msgstr "Una factura/devolución del terminal de venta (%s) no se ha creado."
 
 msgctxt "error:sale.sale:"
 msgid "Go to user preferences and select a shop (\"%s\")"
diff --git a/sale.py b/sale.py
index a0629fe..9948703 100644
--- a/sale.py
+++ b/sale.py
@@ -44,7 +44,7 @@ class Sale:
                 })
         cls._error_messages.update({
                 'not_customer_invoice': ('A customer invoice/refund '
-                    'from sale device has not been created.'),
+                    'from sale device (%s) has not been created.'),
                 })
 
     @staticmethod
@@ -67,7 +67,7 @@ class Sale:
                 cls.process([sale])
 
             if not sale.invoices and sale.invoice_method == 'order':
-                cls.raise_user_error('not_customer_invoice')
+                cls.raise_user_error('not_customer_invoice', (sale.reference,))
 
             grouping = getattr(sale.party, 'sale_invoice_grouping_method',
                 False)