diff --git a/modules/edocument_unece/product.py b/modules/edocument_unece/product.py index ac6a6efc70..461b6ea86e 100644 --- a/modules/edocument_unece/product.py +++ b/modules/edocument_unece/product.py @@ -1,8 +1,12 @@ # 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 sql.functions import Trim + from trytond.model import fields from trytond.pool import PoolMeta from trytond.pyson import Eval +from trytond.transaction import Transaction UNCL5189 = [ ('1', "Handling commission"), @@ -224,12 +228,12 @@ UNCL7161 = [ ('AEH', "Location differential"), ('AEI', "Aircraft refueling"), ('AEJ', "Fuel shipped into storage"), - ('AG ', "Silver surcharge"), - ('AJ ', "Adjustments"), - ('AL ', "Aluminium surcharge"), - ('AM ', "Additional material"), - ('AU ', "Authentication charge"), - ('CA ', "Cataloguing services"), + ('AG', "Silver surcharge"), + ('AJ', "Adjustments"), + ('AL', "Aluminium surcharge"), + ('AM', "Additional material"), + ('AU', "Authentication charge"), + ('CA', "Cataloguing services"), ('CAA', "Cancellation charge"), ('CAB', "Cartage"), ('CAC', "Cash discount"), @@ -241,86 +245,86 @@ UNCL7161 = [ ('CAI', "Cutting charge"), ('CAJ', "Consular costs"), ('CAK', "Customer collection rebate"), - ('CB ', "Commission"), - ('CD ', "Car loading"), - ('CG ', "Cleaning charge"), - ('CK ', "COD charge"), - ('CL ', "Contract allowance"), - ('CO ', "Cents off"), - ('CP ', "Competitive price"), - ('CS ', "Cigarette stamping"), - ('CT ', "Count and recount"), - ('CW ', "Container allowance"), - ('DA ', "Defective allowance"), + ('CB', "Commission"), + ('CD', "Car loading"), + ('CG', "Cleaning charge"), + ('CK', "COD charge"), + ('CL', "Contract allowance"), + ('CO', "Cents off"), + ('CP', "Competitive price"), + ('CS', "Cigarette stamping"), + ('CT', "Count and recount"), + ('CW', "Container allowance"), + ('DA', "Defective allowance"), ('DAA', "Deficit freight"), ('DAB', "Layout/design"), ('DAD', "Driver assigned unloading"), ('DAE', "Distributor discount/allowance"), - ('DI ', "Discount"), - ('DL ', "Delivery"), - ('DM ', "Demurrage"), + ('DI', "Discount"), + ('DL', "Delivery"), + ('DM', "Demurrage"), ('EAA', "Early buy allowance"), ('EAB', "Early payment allowance"), - ('EG ', "Engraving"), - ('EP ', "Expediting premium"), - ('ER ', "Exchange rate guarantee charge"), - ('EX ', "Export shipping charge"), - ('FA ', "Freight allowance"), + ('EG', "Engraving"), + ('EP', "Expediting premium"), + ('ER', "Exchange rate guarantee charge"), + ('EX', "Export shipping charge"), + ('FA', "Freight allowance"), ('FAA', "Fabrication charge"), ('FAB', "Freight equalization"), ('FAC', "Freight surcharge"), - ('FC ', "Freight charge"), - ('FG ', "Free goods"), - ('FH ', "Filling/handling charge"), - ('FI ', "Finance charge"), - ('FN ', "Special finish charge"), - ('FR ', "Flat rate"), + ('FC', "Freight charge"), + ('FG', "Free goods"), + ('FH', "Filling/handling charge"), + ('FI', "Finance charge"), + ('FN', "Special finish charge"), + ('FR', "Flat rate"), ('GAA', "Grinding"), ('HAA', "Hose charge"), - ('HD ', "Handling"), - ('HH ', "Hoisting and hauling"), - ('IA ', "Invoice adjustment"), + ('HD', "Handling"), + ('HH', "Hoisting and hauling"), + ('IA', "Invoice adjustment"), ('IAA', "Installation"), ('IAB', "Installation and warranty"), - ('ID ', "Inside delivery charge"), - ('IF ', "Inspection fee"), - ('IN ', "Insurance"), - ('IR ', "Installation and training"), - ('IS ', "Invoice services"), - ('KO ', "Koshering"), - ('L1 ', "Shipper load, carrier count"), - ('LA ', "Labelling"), + ('ID', "Inside delivery charge"), + ('IF', "Inspection fee"), + ('IN', "Insurance"), + ('IR', "Installation and training"), + ('IS', "Invoice services"), + ('KO', "Koshering"), + ('L1', "Shipper load, carrier count"), + ('LA', "Labelling"), ('LAA', "Labour charge"), ('LAB', "Labour (repair and return orders)"), ('LAC', "License fee"), - ('LF ', "Legalisation fee"), - ('LS ', "Local sales tax"), - ('MA ', "Material allowance (special materials)"), + ('LF', "Legalisation fee"), + ('LS', "Local sales tax"), + ('MA', "Material allowance (special materials)"), ('MAA', "Mileage or travel"), ('MAB', "Mileage fee (for repair and return)"), ('MAC', "Minimum order/minimum billing charge"), ('MAD', "Monthly rental"), ('MAE', "Mounting"), - ('MC ', "Material surcharge (special materials)"), - ('MI ', "Mail invoice"), - ('ML ', "Mail invoice to each location"), + ('MC', "Material surcharge (special materials)"), + ('MI', "Mail invoice"), + ('ML', "Mail invoice to each location"), ('NAA', "Non-returnable containers"), - ('OA ', "Outside cable connectors"), + ('OA', "Outside cable connectors"), ('OAA', "Overtime loading"), - ('PA ', "Pack invoice with shipment"), + ('PA', "Pack invoice with shipment"), ('PAA', "Phosphatizing (steel treatment)"), ('PAB', "Postage charge"), ('PAC', "Premium charge"), ('PAD', "Promotional allowance"), ('PAE', "Promotional discount"), - ('PC ', "Packing"), - ('PD ', "Palladium surcharge"), - ('PI ', "Pick-up allowance"), - ('PL ', "Palletizing"), - ('PN ', "Pallet charge"), - ('PO ', "Per order charge"), + ('PC', "Packing"), + ('PD', "Palladium surcharge"), + ('PI', "Pick-up allowance"), + ('PL', "Palletizing"), + ('PN', "Pallet charge"), + ('PO', "Per order charge"), ('QAA', "Quantity surcharge"), - ('QD ', "Quantity discount"), + ('QD', "Quantity discount"), ('RAA', "Rebate"), ('RAB', "Repack charge"), ('RAC', "Repair"), @@ -329,13 +333,13 @@ UNCL7161 = [ ('RAF', "Restocking charge"), ('RAG', "Roll rebate"), ('RAH', "Road/rail tanker rebate"), - ('RE ', "Re-delivery charge"), - ('RF ', "Refurbishing charge"), - ('RH ', "Rail wagon hire"), - ('RO ', "Roe allowance/charge"), - ('RP ', "Repair charge"), - ('RV ', "Freight charge/costs of loading"), - ('SA ', "Salvage"), + ('RE', "Re-delivery charge"), + ('RF', "Refurbishing charge"), + ('RH', "Rail wagon hire"), + ('RO', "Roe allowance/charge"), + ('RP', "Repair charge"), + ('RV', "Freight charge/costs of loading"), + ('SA', "Salvage"), ('SAA', "Shipping and handling"), ('SAB', "Special allowance"), ('SAC', "Special credit"), @@ -346,35 +350,35 @@ UNCL7161 = [ ('SAH', "Surcharge (percentage)"), ('SAI', "Shipper load, consignee unload"), ('SAJ', "Small packages charge"), - ('SC ', "Surcharge"), - ('SD ', "Shrinkage allowance"), - ('SF ', "Special rebate"), - ('SG ', "Shrink-wrap charge"), - ('SH ', "Special handling service"), - ('SM ', "Special finish"), - ('ST ', "Stamp duties"), - ('SU ', "Set-up"), - ('SZ ', "Steel surcharge"), + ('SC', "Surcharge"), + ('SD', "Shrinkage allowance"), + ('SF', "Special rebate"), + ('SG', "Shrink-wrap charge"), + ('SH', "Special handling service"), + ('SM', "Special finish"), + ('ST', "Stamp duties"), + ('SU', "Set-up"), + ('SZ', "Steel surcharge"), ('TAA', "Telephone charge"), ('TAB', "Tank rental"), ('TAC', "Testing charge"), ('TAD', "Testing allowance"), ('TAE', "Truckload discount"), - ('TD ', "Trade discount"), - ('TS ', "State tax"), - ('TT ', "Transportation - third party billing"), - ('TV ', "Transportation - vendor provided"), - ('TX ', "Tax"), - ('TZ ', "Temporary allowance"), - ('UM ', "Unsaleable merchandise allowance"), - ('V1 ', "Drop yard"), - ('V2 ', "Drop dock"), + ('TD', "Trade discount"), + ('TS', "State tax"), + ('TT', "Transportation - third party billing"), + ('TV', "Transportation - vendor provided"), + ('TX', "Tax"), + ('TZ', "Temporary allowance"), + ('UM', "Unsaleable merchandise allowance"), + ('V1', "Drop yard"), + ('V2', "Drop dock"), ('VAA', "Vendor freight"), ('VAB', "Volume discount"), - ('VL ', "Vehicle load allowance"), - ('WH ', "Warehousing"), + ('VL', "Vehicle load allowance"), + ('WH', "Warehousing"), ('XAA', "Combine all same day shipment"), - ('YY ', "Split pickup"), + ('YY', "Split pickup"), ('ZZZ', "Mutually defined"), ] @@ -410,6 +414,20 @@ class Template(metaclass=PoolMeta): help="Standard code of " "the United Nations Economic Commission for Europe.") + @classmethod + def __register__(cls, module): + cursor = Transaction().connection.cursor() + table = cls.__table__() + + super().__register__(module) + + # Migration from 8.0: strip UNCL7161 code + cursor.execute(*table.update( + [table.unece_special_service_code], + [Trim(table.unece_special_service_code)], + where=table.unece_special_service_code + != Trim(table.unece_special_service_code))) + class Product(metaclass=PoolMeta): __name__ = 'product.product'