2021-03-11 11:18:22 +01:00
|
|
|
# The COPYRIGHT file at the top level of this repository contains
|
|
|
|
# the full copyright notices and license terms.
|
2021-03-28 00:23:19 +01:00
|
|
|
from trytond.pool import PoolMeta
|
2021-03-11 11:18:22 +01:00
|
|
|
from trytond.exceptions import UserError
|
|
|
|
from trytond.i18n import gettext
|
|
|
|
|
|
|
|
|
|
|
|
class Purchase(metaclass=PoolMeta):
|
|
|
|
__name__ = 'purchase.purchase'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def quote(cls, purchases):
|
|
|
|
super(Purchase, cls).quote(purchases)
|
|
|
|
for purchase in purchases:
|
|
|
|
for line in purchase.lines:
|
2021-03-19 23:08:51 +01:00
|
|
|
if (line.product and
|
2021-03-22 14:26:35 +01:00
|
|
|
not line.product_supplier and
|
2021-03-11 11:18:22 +01:00
|
|
|
line.product.purchase_homologation_required):
|
2021-03-22 14:26:35 +01:00
|
|
|
raise UserError(gettext(
|
|
|
|
'product_purchase_homologation.cannot_end_purchase',
|
|
|
|
purchase=purchase.id,
|
|
|
|
line=line.rec_name))
|
2022-01-26 11:50:54 +01:00
|
|
|
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,
|
|
|
|
))
|