Ejemplo n.º 1
0
def sales_invoice_on_cancel(doc, method):
	if get_company_country(doc.company) not in ['Italy',
		'Italia', 'Italian Republic', 'Repubblica Italiana']:
		return

	for attachment in get_e_invoice_attachments(doc):
		remove_file(attachment.name, attached_to_doctype=doc.doctype, attached_to_name=doc.name)
Ejemplo n.º 2
0
def sales_invoice_on_cancel(doc, method):
	if get_company_country(doc.company) not in ['Italy',
		'Italia', 'Italian Republic', 'Repubblica Italiana']:
		return

	for attachment in get_e_invoice_attachments(doc):
		remove_file(attachment.name, attached_to_doctype=doc.doctype, attached_to_name=doc.name)
Ejemplo n.º 3
0
def remove_non_zip_docs(document):
	"""This function attaches drawings to the purchase order based on the items being ordered"""
	document = json.loads(document)
	document2 = frappe._dict(document)
	
	current_attachments = []
	
	for file_url in frappe.db.sql("""select name, file_url from `tabFile` where attached_to_doctype = %(doctype)s and attached_to_name = %(docname)s""", {'doctype': document2.doctype, 'docname': document2.name}, as_dict=True ):
		if not file_url.file_url.endswith(".zip"):
			remove_file(file_url.name, document2.doctype, document2.name)
Ejemplo n.º 4
0
def get_progressive_name_and_number(doc, replace=False):
	if replace:
		for attachment in get_e_invoice_attachments(doc):
			remove_file(attachment.name, attached_to_doctype=doc.doctype, attached_to_name=doc.name)
			filename = attachment.file_name.split(".xml")[0]
			return filename, filename.split("_")[1]

	company_tax_id = doc.company_tax_id if doc.company_tax_id.startswith("IT") else "IT" + doc.company_tax_id
	progressive_name = frappe.model.naming.make_autoname(company_tax_id + "_.#####")
	progressive_number = progressive_name.split("_")[1]

	return progressive_name, progressive_number
Ejemplo n.º 5
0
def get_progressive_name_and_number(doc, replace=False):
	if replace:
		for attachment in get_e_invoice_attachments(doc):
			remove_file(attachment.name, attached_to_doctype=doc.doctype, attached_to_name=doc.name)
			filename = attachment.file_name.split(".xml")[0]
			return filename, filename.split("_")[1]

	company_tax_id = doc.company_tax_id if doc.company_tax_id.startswith("IT") else "IT" + doc.company_tax_id
	progressive_name = frappe.model.naming.make_autoname(company_tax_id + "_.#####")
	progressive_number = progressive_name.split("_")[1]

	return progressive_name, progressive_number
Ejemplo n.º 6
0
def remove_file_by_url(file_url, doctype=None, name=None):
    if doctype and name:
        fid = frappe.db.get_value(
            "File", {
                "file_url": file_url,
                "attached_to_doctype": doctype,
                "attached_to_name": name
            })
    else:
        fid = frappe.db.get_value("File", {"file_url": file_url})

    if fid:
        from frappe.utils.file_manager import remove_file
        return remove_file(fid=fid)
Ejemplo n.º 7
0
def sales_invoice_on_cancel(doc):
	for attachment in get_e_invoice_attachments(doc):
		remove_file(attachment.name, attached_to_doctype=doc.doctype, attached_to_name=doc.name)
Ejemplo n.º 8
0
def remove_attachment(fid):
	return remove_file(fid)