I’ve been thinking on how to properly define the limits. As Tryton is modular we should be able to define for each incoterm a list of exclusion clause. The exclusion clause should be only created by modules and we will use a Many2Many to refer them.
A similar field should be added at document level (sale/purchaes) but in this case it will be a functional field. This wil allow the developer to compute for each document it’s exclusion clauses.
With this information we can add a domain that test that both clauses matches. This will prevent the user to select wrong incoterms.
With this desing the incoterm module should loads by default all the know codes (Here is a list) so other modules will be able to include the exlusion clauses of each one.
On the other hand, we should be able to name the place where the goods should made available (i.e: Seller Warehouse, Buyer Warehouse, A named Port). I think that for each party we should add a list of Named Places.
With this setup, it should be possible to exclude some clauses depending on the ownership (if it’s from seller or buyer) of the delivery place.
The sale_shipment_cost module should also include a condition to restrict the Incoterms that do not include transportation costs (CPT, CIP, etc). So this incoterms should not be selected if a carrier is selected.
To resume, the incoterm module should define the folliwing models:
- Code: The 3 digits code used to represent it
- Name: The translatable name of the incoterm
- Clauses: A Many2Many to the exclusion clauses of this incoterm
- Name: A translatable name to represent the clause
- Name: A Char field to the name
- Company: The company to which the place is associated
- Party: An optional party from which party the place is associated
- Address: An address to represent the place.
The Party model should be extended with the follwoing fields:
- Accepted incoterms: A sequence ordered list of the incoterms accepted by the party.
- Places: A list of incoterms places that related are to the party
And for each document (purchase/sale) we will add the following fields:
- Incoterm: A Many2One to the incoterm. If only one is applicable it will be automatically set via on_change
- Place: The place where to deliver the goods. It will also be automatically set if only one is applicable.