From 014896a59519672dc24ebc5f63cc997ce5758e0d Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 17 Nov 2022 22:16:43 +0100 Subject: [PATCH] feat: create incoterms and migrate shipments (cherry picked from commit d2563ee97388290ee0acad09148af6f853637886) # Conflicts: # erpnext/patches.txt --- erpnext/patches.txt | 5 +++ .../create_incoterms_and_migrate_shipment.py | 32 +++++++++++++++++++ erpnext/stock/doctype/shipment/shipment.json | 10 +++--- 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 erpnext/patches/v14_0/create_incoterms_and_migrate_shipment.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 7e7112a82cd..6bcfeae14ec 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -316,6 +316,11 @@ erpnext.patches.v14_0.create_accounting_dimensions_in_subcontracting_doctypes erpnext.patches.v14_0.fix_subcontracting_receipt_gl_entries erpnext.patches.v14_0.migrate_remarks_from_gl_to_payment_ledger erpnext.patches.v14_0.create_accounting_dimensions_for_asset_capitalization +<<<<<<< HEAD erpnext.patches.v13_0.update_schedule_type_in_loans erpnext.patches.v14_0.update_partial_tds_fields +======= +erpnext.patches.v14_0.update_tds_fields +erpnext.patches.v14_0.create_incoterms_and_migrate_shipment +>>>>>>> d2563ee973 (feat: create incoterms and migrate shipments) 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 00000000000..fd3c071edbe --- /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 a33cbc288c5..53b549deec1 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