From 1e0b5798f316d3b98bd99c971af6d9bb4d259a72 Mon Sep 17 00:00:00 2001 From: juanjo-nan <57089222+juanjo-nan@users.noreply.github.com> Date: Wed, 26 Jan 2022 11:50:54 +0100 Subject: [PATCH] =?UTF-8?q?Now=20check=20if=20a=20purchase=20supplier=20ar?= =?UTF-8?q?e=20deactivate=20before=20quote=20the=20purc=E2=80=A6=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Now check if a purchase supplier are deactivate before quote the purchase. Task #048267 --- locale/ca.po | 11 +++++++++-- locale/es.po | 11 +++++++++-- message.xml | 3 +++ purchase.py | 9 +++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/locale/ca.po b/locale/ca.po index db029b7..c5b9468 100644 --- a/locale/ca.po +++ b/locale/ca.po @@ -2,11 +2,11 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "field:product.template,purchase_homologation_required:" +msgctxt "field:product.product,purchase_homologation_required:" msgid "Purchase Homologation Required" msgstr "Requereix homologació" -msgctxt "field:product.product,purchase_homologation_required:" +msgctxt "field:product.template,purchase_homologation_required:" msgid "Purchase Homologation Required" msgstr "Requereix homologació" @@ -17,3 +17,10 @@ msgid "" msgstr "" "No es pot finalitzar la compra \"%(purchase)s\" perquè la línia \"%(line)s\"" " necessita un proveïdor." + +msgctxt "model:ir.message,text:product_purchase_deactivate" +msgid "" +"Cannot end the purchase \"%(purchase)s\" because have a deactivate supplier." +msgstr "" +"No es pot finalitzar la compra \"%(purchase)s\" perquè un proveïdor " +"desactivat." diff --git a/locale/es.po b/locale/es.po index 3b10fd2..722e948 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2,11 +2,11 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "field:product.template,purchase_homologation_required:" +msgctxt "field:product.product,purchase_homologation_required:" msgid "Purchase Homologation Required" msgstr "Requiere homologación" -msgctxt "field:product.product,purchase_homologation_required:" +msgctxt "field:product.template,purchase_homologation_required:" msgid "Purchase Homologation Required" msgstr "Requiere homologación" @@ -17,3 +17,10 @@ msgid "" msgstr "" "No se puede finalizar la compra \"%(purchase)s\" porque la línia " "\"%(line)s\" necessita un proveedor." + +msgctxt "model:ir.message,text:product_purchase_deactivate" +msgid "" +"Cannot end the purchase \"%(purchase)s\" because have a deactivate supplier." +msgstr "" +"No se puede finalizar la compra \"%(purchase)s\" porque tiene un proveedor " +"desactivado." diff --git a/message.xml b/message.xml index 822940e..0b2f3e9 100644 --- a/message.xml +++ b/message.xml @@ -6,5 +6,8 @@ this repository contains the full copyright notices and license terms. --> Cannot end the purchase "%(purchase)s" because the line "%(line)s" needs a supplier. + + Cannot end the purchase "%(purchase)s" because have a deactivate supplier. + \ No newline at end of file diff --git a/purchase.py b/purchase.py index 98fe66c..20d691b 100644 --- a/purchase.py +++ b/purchase.py @@ -20,3 +20,12 @@ class Purchase(metaclass=PoolMeta): 'product_purchase_homologation.cannot_end_purchase', purchase=purchase.id, line=line.rec_name)) + if (line.product and + line.product.purchase_homologation_required and + line.product_supplier and + line.product_supplier.active == False and + line.type == 'line'): + raise UserError(gettext( + 'product_purchase_homologation.product_purchase_deactivate', + purchase=purchase.id, + ))