diff --git a/modules/sale_shipment_cost/sale.py b/modules/sale_shipment_cost/sale.py index 2ab74f2e52..6d6226f375 100644 --- a/modules/sale_shipment_cost/sale.py +++ b/modules/sale_shipment_cost/sale.py @@ -2,6 +2,8 @@ # this repository contains the full copyright notices and license terms. from decimal import Decimal +from sql import Null + from trytond.i18n import gettext from trytond.model import ModelView, Workflow, fields from trytond.modules.product import price_digits, round_price @@ -90,11 +92,20 @@ class Sale(metaclass=PoolMeta): @classmethod def __register__(cls, module): + cursor = Transaction().connection.cursor() + table = cls.__table__() + super().__register__(module) table_h = cls.__table_handler__(module) # Migration from 5.8: remove required on shipment_cost_method table_h.not_null_action('shipment_cost_method', 'remove') + # Migration from 6.6: shipment_cost_method domain + cursor.execute(*table.update( + [table.shipment_cost_method], + [Null], + where=(table.carrier == Null) & (table.state != 'draft'))) + @classmethod def default_shipment_cost_method(cls, **pattern): Config = Pool().get('sale.configuration') diff --git a/modules/sale_shipment_cost/setup.py b/modules/sale_shipment_cost/setup.py index 76f4f16f8f..9b2aaffa42 100755 --- a/modules/sale_shipment_cost/setup.py +++ b/modules/sale_shipment_cost/setup.py @@ -41,7 +41,7 @@ else: download_url = 'http://downloads.tryton.org/%s.%s/' % ( major_version, minor_version) -requires = [] +requires = ['python-sql'] for dep in info.get('depends', []): if not re.match(r'(ir|res)(\W|$)', dep): requires.append(get_require_version('trytond_%s' % dep))