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
This commit is contained in:
parent
c2de4f6b35
commit
71342320ce
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"actions": [],
|
||||||
"creation": "2019-10-15 12:33:21.845329",
|
"creation": "2019-10-15 12:33:21.845329",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
@ -86,12 +87,14 @@
|
|||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:!doc.__islocal",
|
||||||
"fieldname": "upload_xml_invoices_section",
|
"fieldname": "upload_xml_invoices_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Upload XML Invoices"
|
"label": "Upload XML Invoices"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2020-05-25 21:32:49.064579",
|
"links": [],
|
||||||
|
"modified": "2021-04-24 10:33:12.250687",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Regional",
|
"module": "Regional",
|
||||||
"name": "Import Supplier Invoice",
|
"name": "Import Supplier Invoice",
|
||||||
|
@ -28,14 +28,19 @@ class ImportSupplierInvoice(Document):
|
|||||||
self.name = "Import Invoice on " + format_datetime(self.creation)
|
self.name = "Import Invoice on " + format_datetime(self.creation)
|
||||||
|
|
||||||
def import_xml_data(self):
|
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.publish("File Import", _("Processing XML Files"), 1, 3)
|
||||||
|
|
||||||
self.file_count = 0
|
self.file_count = 0
|
||||||
self.purchase_invoices_count = 0
|
self.purchase_invoices_count = 0
|
||||||
self.default_uom = frappe.db.get_value("Stock Settings", fieldname="stock_uom")
|
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():
|
for file_name in zf.namelist():
|
||||||
content = get_file_content(file_name, zf)
|
content = get_file_content(file_name, zf)
|
||||||
file_content = bs(content, "xml")
|
file_content = bs(content, "xml")
|
||||||
@ -126,8 +131,7 @@ class ImportSupplierInvoice(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def process_file_data(self):
|
def process_file_data(self):
|
||||||
self.status = "Processing File Data"
|
self.db_set("status", "Processing File Data", notify=True, commit=True)
|
||||||
self.save()
|
|
||||||
frappe.enqueue_doc(self.doctype, self.name, "import_xml_data", queue="long", timeout=3600)
|
frappe.enqueue_doc(self.doctype, self.name, "import_xml_data", queue="long", timeout=3600)
|
||||||
|
|
||||||
def publish(self, title, message, count, total):
|
def publish(self, title, message, count, total):
|
||||||
@ -381,24 +385,3 @@ def create_uom(uom):
|
|||||||
new_uom.uom_name = uom
|
new_uom.uom_name = uom
|
||||||
new_uom.save()
|
new_uom.save()
|
||||||
return new_uom.uom_name
|
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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user