diff --git a/modules/sale_shipment_cost/CHANGELOG b/modules/sale_shipment_cost/CHANGELOG index d3fda4d5a5..24e9d919be 100644 --- a/modules/sale_shipment_cost/CHANGELOG +++ b/modules/sale_shipment_cost/CHANGELOG @@ -1,3 +1,5 @@ +* Require carrier to quote sale with shipment cost method + Version 6.6.0 - 2022-10-31 -------------------------- * Bug fixes (see mercurial logs for details) diff --git a/modules/sale_shipment_cost/message.xml b/modules/sale_shipment_cost/message.xml index 7b6020a990..970ce5b260 100644 --- a/modules/sale_shipment_cost/message.xml +++ b/modules/sale_shipment_cost/message.xml @@ -6,6 +6,9 @@ this repository contains the full copyright notices and license terms. --> To confirm sale "%(sale)s" you must change the carrier "%(carrier)s". + + To get a quote for sale "%(sale)s" you must enter a carrier. + To invoice shipment cost of "%(shipment)s", you must define an account revenue for product "%(product)s". diff --git a/modules/sale_shipment_cost/sale.py b/modules/sale_shipment_cost/sale.py index 2aae21a8d8..78392ca72c 100644 --- a/modules/sale_shipment_cost/sale.py +++ b/modules/sale_shipment_cost/sale.py @@ -6,7 +6,8 @@ from trytond import backend from trytond.i18n import gettext from trytond.model import ModelView, Workflow, fields from trytond.modules.product import price_digits, round_price -from trytond.modules.sale.exceptions import SaleConfirmError +from trytond.modules.sale.exceptions import ( + SaleConfirmError, SaleQuotationError) from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval, If from trytond.transaction import Transaction @@ -198,6 +199,19 @@ class Sale(metaclass=PoolMeta): elif not self.available_carriers: self.carrier = None + def check_for_quotation(self): + super().check_for_quotation() + if self.shipment_cost_method and self.available_carriers: + for line in self.lines: + if (line.product + and line.product.type != 'service' + and line.quantity >= 0 + and not self.carrier): + raise SaleQuotationError( + gettext('sale' + '.msg_sale_carrier_required_for_quotation', + sale=self.rec_name)) + @classmethod @ModelView.button @Workflow.transition('quotation')