Now check if a purchase supplier are deactivate before quote the purc… (#2)

* Now check if a purchase supplier are deactivate before quote the purchase.

Task #048267
This commit is contained in:
juanjo-nan 2022-01-26 11:50:54 +01:00 committed by Juanjo Garcia
parent cbbe536c52
commit 1e0b5798f3
4 changed files with 30 additions and 4 deletions

View File

@ -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."

View File

@ -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."

View File

@ -6,5 +6,8 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="cannot_end_purchase">
<field name="text">Cannot end the purchase "%(purchase)s" because the line "%(line)s" needs a supplier.</field>
</record>
<record model="ir.message" id="product_purchase_deactivate">
<field name="text">Cannot end the purchase "%(purchase)s" because have a deactivate supplier.</field>
</record>
</data>
</tryton>

View File

@ -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,
))