Files
tryton/modules/incoterm/web.py
T
Cédric Krier 381703a194 Clear any default incoterm for sale created for web shop
The default incoterm may prevent to save the sale.
So we let the quotation transition set the incoterm values.

Closes #14521
2026-01-19 19:05:51 +01:00

38 lines
1.3 KiB
Python

# 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.pool import Pool, PoolMeta
from trytond.pyson import Eval
class Shop(metaclass=PoolMeta):
__name__ = 'web.shop'
default_incoterm = fields.Many2One(
'incoterm.incoterm', "Default Incoterm",
domain=[
('carrier', '=', 'seller'),
('id', 'in', Eval('available_incoterms', [])),
],
help="Used to fill incoterm on sales that require it.")
available_incoterms = fields.Function(fields.Many2Many(
'incoterm.incoterm', None, None, "Available Incoterms"),
'on_change_with_available_incoterms')
@fields.depends('company', methods=['_get_incoterm_pattern'])
def on_change_with_available_incoterms(self, name=None):
pool = Pool()
Incoterm = pool.get('incoterm.incoterm')
pattern = self._get_incoterm_pattern()
return Incoterm.get_incoterms(self.company, pattern)
@fields.depends()
def _get_incoterm_pattern(self):
return {}
def get_sale(self, party=None):
sale = super().get_sale(party=party)
sale.incoterm = sale.incoterm_location = None
return sale