fix(Italy): multiple fixes in import supplier invoice (#25466)
* fix(Italy): remove incorrect method, use defined variable
* fix: show attach section after save; use db_set
diff --git a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
index c1680c4..afdd54b 100644
--- a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
+++ b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"creation": "2019-10-15 12:33:21.845329",
"doctype": "DocType",
"editable_grid": 1,
@@ -86,12 +87,14 @@
"reqd": 1
},
{
+ "depends_on": "eval:!doc.__islocal",
"fieldname": "upload_xml_invoices_section",
"fieldtype": "Section Break",
"label": "Upload XML Invoices"
}
],
- "modified": "2020-05-25 21:32:49.064579",
+ "links": [],
+ "modified": "2021-04-24 10:33:12.250687",
"modified_by": "Administrator",
"module": "Regional",
"name": "Import Supplier Invoice",
diff --git a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py
index cc6b907..0030053 100644
--- a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py
+++ b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py
@@ -28,14 +28,19 @@
self.name = "Import Invoice on " + format_datetime(self.creation)
def import_xml_data(self):
- import_file = frappe.get_doc("File", {"file_url": self.zip_file})
+ zip_file = frappe.get_doc("File", {
+ "file_url": self.zip_file,
+ "attached_to_doctype": self.doctype,
+ "attached_to_name": self.name
+ })
+
self.publish("File Import", _("Processing XML Files"), 1, 3)
self.file_count = 0
self.purchase_invoices_count = 0
self.default_uom = frappe.db.get_value("Stock Settings", fieldname="stock_uom")
- with zipfile.ZipFile(get_full_path(self.zip_file)) as zf:
+ with zipfile.ZipFile(zip_file.get_full_path()) as zf:
for file_name in zf.namelist():
content = get_file_content(file_name, zf)
file_content = bs(content, "xml")
@@ -126,8 +131,7 @@
@frappe.whitelist()
def process_file_data(self):
- self.status = "Processing File Data"
- self.save()
+ self.db_set("status", "Processing File Data", notify=True, commit=True)
frappe.enqueue_doc(self.doctype, self.name, "import_xml_data", queue="long", timeout=3600)
def publish(self, title, message, count, total):
@@ -381,24 +385,3 @@
new_uom.uom_name = uom
new_uom.save()
return new_uom.uom_name
-
-def get_full_path(file_name):
- """Returns file path from given file name"""
- file_path = file_name
-
- if "/" not in file_path:
- file_path = "/files/" + file_path
-
- if file_path.startswith("/private/files/"):
- file_path = get_files_path(*file_path.split("/private/files/", 1)[1].split("/"), is_private=1)
-
- elif file_path.startswith("/files/"):
- file_path = get_files_path(*file_path.split("/files/", 1)[1].split("/"))
-
- elif file_path.startswith("http"):
- pass
-
- elif not self.file_url:
- frappe.throw(_("There is some problem with the file url: {0}").format(file_path))
-
- return file_path