Use 'default' for default value of shipment cost on party

issue11774
review424051003
This commit is contained in:
Cédric Krier committed 2022-10-28 00:43:56 +02:00
1 parent 42db0576f0
commit e597580a07
2 files changed
+15 -2

No files matched your search

+14 -1
View File
@@ -1,11 +1,20 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of this
# repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.modules.sale.party import get_sale_methods
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
def get_sale_methods(field_name):
@classmethod
def func(cls):
pool = Pool()
Sale = pool.get('sale.sale')
return Sale.fields_get([field_name])[field_name]['selection'] + [
('default', "")]
return func
class Party(metaclass=PoolMeta):
__name__ = 'party.party'
@@ -23,6 +32,10 @@ class Party(metaclass=PoolMeta):
get_sale_shipment_cost_method = get_sale_methods('shipment_cost_method')
@classmethod
def default_sale_shipment_cost_method(cls, **pattern):
return 'default'
@classmethod
def copy(cls, parties, default=None):
context = Transaction().context
+1 -1
View File
@@ -167,7 +167,7 @@ class Sale(metaclass=PoolMeta):
self.carrier = None
if not self.carrier:
self.shipment_cost_method = None
elif self.party and self.party.sale_shipment_cost_method:
elif self.party and self.party.sale_shipment_cost_method != 'default':
self.shipment_cost_method = self.party.sale_shipment_cost_method
else:
self.shipment_cost_method = self.default_shipment_cost_method()