mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 17:04:47 +00:00
fix: Moved regional methods from controller to hooks (#16736)
This commit is contained in:
committed by
Sagar Vora
parent
ef3f864123
commit
c18e925d61
@@ -222,8 +222,12 @@ def sales_invoice_validate(doc):
|
||||
|
||||
|
||||
#Ensure payment details are valid for e-invoice.
|
||||
def sales_invoice_on_submit(doc):
|
||||
def sales_invoice_on_submit(doc, method):
|
||||
#Validate payment details
|
||||
if get_company_country(doc.company) not in ['Italy',
|
||||
'Italia', 'Italian Republic', 'Repubblica Italiana']:
|
||||
return
|
||||
|
||||
if not len(doc.payment_schedule):
|
||||
frappe.throw(_("Please set the Payment Schedule"), title=_("E-Invoicing Information Missing"))
|
||||
else:
|
||||
@@ -247,10 +251,17 @@ def prepare_and_attach_invoice(doc):
|
||||
save_file(xml_filename, invoice_xml, dt=doc.doctype, dn=doc.name, is_private=True)
|
||||
|
||||
#Delete e-invoice attachment on cancel.
|
||||
def sales_invoice_on_cancel(doc):
|
||||
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)
|
||||
|
||||
def get_company_country(company):
|
||||
return frappe.get_cached_value('Company', company, 'country')
|
||||
|
||||
def get_e_invoice_attachments(invoice):
|
||||
out = []
|
||||
attachments = get_attachments(invoice.doctype, invoice.name)
|
||||
|
||||
Reference in New Issue
Block a user