feat: create incoterms and migrate shipments
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 2624181..1ca3be9 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -318,3 +318,4 @@
erpnext.patches.v13_0.update_schedule_type_in_loans
erpnext.patches.v14_0.create_accounting_dimensions_for_asset_capitalization
erpnext.patches.v14_0.update_tds_fields
+erpnext.patches.v14_0.create_incoterms_and_migrate_shipment
diff --git a/erpnext/patches/v14_0/create_incoterms_and_migrate_shipment.py b/erpnext/patches/v14_0/create_incoterms_and_migrate_shipment.py
new file mode 100644
index 0000000..fd3c071
--- /dev/null
+++ b/erpnext/patches/v14_0/create_incoterms_and_migrate_shipment.py
@@ -0,0 +1,32 @@
+import frappe
+
+from erpnext.setup.doctype.incoterm.incoterm import create_incoterms
+
+
+def execute():
+ create_incoterms()
+ migrate_shipments()
+
+
+def migrate_shipments():
+ if not frappe.db.count("Shipment"):
+ return
+
+ OLD_VALUES = [
+ # old_value: (code, title),
+ "EXW (Ex Works)",
+ "FCA (Free Carrier)",
+ "FOB (Free On Board)",
+ "FAS (Free Alongside Ship)",
+ "CPT (Carriage Paid To)",
+ "CIP (Carriage and Insurance Paid to)",
+ "CFR (Cost and Freight)",
+ "DPU (Delivered At Place Unloaded)",
+ "DAP (Delivered At Place)",
+ "DDP (Delivered Duty Paid)",
+ ]
+ shipment = frappe.qb.DocType("Shipment")
+ for old_value in OLD_VALUES:
+ frappe.qb.update(shipment).set(shipment.incoterm, old_value[:3]).where(
+ shipment.incoterm == old_value
+ ).run()
diff --git a/erpnext/stock/doctype/shipment/shipment.json b/erpnext/stock/doctype/shipment/shipment.json
index a33cbc2..53b549d 100644
--- a/erpnext/stock/doctype/shipment/shipment.json
+++ b/erpnext/stock/doctype/shipment/shipment.json
@@ -412,9 +412,9 @@
},
{
"fieldname": "incoterm",
- "fieldtype": "Select",
+ "fieldtype": "Link",
"label": "Incoterm",
- "options": "EXW (Ex Works)\nFCA (Free Carrier)\nCPT (Carriage Paid To)\nCIP (Carriage and Insurance Paid to)\nDPU (Delivered At Place Unloaded)\nDAP (Delivered At Place)\nDDP (Delivered Duty Paid)"
+ "options": "Incoterm"
},
{
"fieldname": "shipment_delivery_note",
@@ -433,10 +433,11 @@
],
"is_submittable": 1,
"links": [],
- "modified": "2021-04-13 17:14:18.181818",
+ "modified": "2022-11-17 17:23:27.025802",
"modified_by": "Administrator",
"module": "Stock",
"name": "Shipment",
+ "naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
@@ -470,5 +471,6 @@
],
"sort_field": "modified",
"sort_order": "DESC",
+ "states": [],
"track_changes": 1
-}
+}
\ No newline at end of file