fix: Moved regional methods from controller to hooks (#16736)
This commit is contained in:
parent
ef3f864123
commit
c18e925d61
@ -24,7 +24,6 @@ from erpnext.accounts.general_ledger import get_round_off_account_and_cost_cente
|
|||||||
from erpnext.accounts.doctype.loyalty_program.loyalty_program import \
|
from erpnext.accounts.doctype.loyalty_program.loyalty_program import \
|
||||||
get_loyalty_program_details_with_points, get_loyalty_details, validate_loyalty_points
|
get_loyalty_program_details_with_points, get_loyalty_details, validate_loyalty_points
|
||||||
from erpnext.accounts.deferred_revenue import validate_service_stop_date
|
from erpnext.accounts.deferred_revenue import validate_service_stop_date
|
||||||
from erpnext.controllers.accounts_controller import on_submit_regional, on_cancel_regional
|
|
||||||
|
|
||||||
from erpnext.healthcare.utils import manage_invoice_submit_cancel
|
from erpnext.healthcare.utils import manage_invoice_submit_cancel
|
||||||
|
|
||||||
@ -199,8 +198,6 @@ class SalesInvoice(SellingController):
|
|||||||
if "Healthcare" in active_domains:
|
if "Healthcare" in active_domains:
|
||||||
manage_invoice_submit_cancel(self, "on_submit")
|
manage_invoice_submit_cancel(self, "on_submit")
|
||||||
|
|
||||||
on_submit_regional(self)
|
|
||||||
|
|
||||||
def validate_pos_paid_amount(self):
|
def validate_pos_paid_amount(self):
|
||||||
if len(self.payments) == 0 and self.is_pos:
|
if len(self.payments) == 0 and self.is_pos:
|
||||||
frappe.throw(_("At least one mode of payment is required for POS invoice."))
|
frappe.throw(_("At least one mode of payment is required for POS invoice."))
|
||||||
@ -256,8 +253,6 @@ class SalesInvoice(SellingController):
|
|||||||
if "Healthcare" in active_domains:
|
if "Healthcare" in active_domains:
|
||||||
manage_invoice_submit_cancel(self, "on_cancel")
|
manage_invoice_submit_cancel(self, "on_cancel")
|
||||||
|
|
||||||
on_cancel_regional(self)
|
|
||||||
|
|
||||||
def update_status_updater_args(self):
|
def update_status_updater_args(self):
|
||||||
if cint(self.update_stock):
|
if cint(self.update_stock):
|
||||||
self.status_updater.extend([{
|
self.status_updater.extend([{
|
||||||
|
@ -1138,11 +1138,3 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name):
|
|||||||
@erpnext.allow_regional
|
@erpnext.allow_regional
|
||||||
def validate_regional(doc):
|
def validate_regional(doc):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@erpnext.allow_regional
|
|
||||||
def on_submit_regional(doc):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@erpnext.allow_regional
|
|
||||||
def on_cancel_regional(doc):
|
|
||||||
pass
|
|
||||||
|
@ -202,7 +202,8 @@ doc_events = {
|
|||||||
"validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products"
|
"validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products"
|
||||||
},
|
},
|
||||||
"Sales Invoice": {
|
"Sales Invoice": {
|
||||||
"on_submit": "erpnext.regional.france.utils.create_transaction_log",
|
"on_submit": ["erpnext.regional.france.utils.create_transaction_log", "erpnext.regional.italy.utils.sales_invoice_on_submit"],
|
||||||
|
"on_cancel": "erpnext.regional.italy.utils.sales_invoice_on_cancel",
|
||||||
"on_trash": "erpnext.regional.check_deletion_permission"
|
"on_trash": "erpnext.regional.check_deletion_permission"
|
||||||
},
|
},
|
||||||
"Payment Entry": {
|
"Payment Entry": {
|
||||||
@ -305,7 +306,5 @@ regional_overrides = {
|
|||||||
'Italy': {
|
'Italy': {
|
||||||
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.italy.utils.update_itemised_tax_data',
|
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.italy.utils.update_itemised_tax_data',
|
||||||
'erpnext.controllers.accounts_controller.validate_regional': 'erpnext.regional.italy.utils.sales_invoice_validate',
|
'erpnext.controllers.accounts_controller.validate_regional': 'erpnext.regional.italy.utils.sales_invoice_validate',
|
||||||
'erpnext.controllers.accounts_controller.on_submit_regional': 'erpnext.regional.italy.utils.sales_invoice_on_submit',
|
|
||||||
'erpnext.controllers.accounts_controller.on_cancel_regional': 'erpnext.regional.italy.utils.sales_invoice_on_cancel'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,8 +222,12 @@ def sales_invoice_validate(doc):
|
|||||||
|
|
||||||
|
|
||||||
#Ensure payment details are valid for e-invoice.
|
#Ensure payment details are valid for e-invoice.
|
||||||
def sales_invoice_on_submit(doc):
|
def sales_invoice_on_submit(doc, method):
|
||||||
#Validate payment details
|
#Validate payment details
|
||||||
|
if get_company_country(doc.company) not in ['Italy',
|
||||||
|
'Italia', 'Italian Republic', 'Repubblica Italiana']:
|
||||||
|
return
|
||||||
|
|
||||||
if not len(doc.payment_schedule):
|
if not len(doc.payment_schedule):
|
||||||
frappe.throw(_("Please set the Payment Schedule"), title=_("E-Invoicing Information Missing"))
|
frappe.throw(_("Please set the Payment Schedule"), title=_("E-Invoicing Information Missing"))
|
||||||
else:
|
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)
|
save_file(xml_filename, invoice_xml, dt=doc.doctype, dn=doc.name, is_private=True)
|
||||||
|
|
||||||
#Delete e-invoice attachment on cancel.
|
#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):
|
for attachment in get_e_invoice_attachments(doc):
|
||||||
remove_file(attachment.name, attached_to_doctype=doc.doctype, attached_to_name=doc.name)
|
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):
|
def get_e_invoice_attachments(invoice):
|
||||||
out = []
|
out = []
|
||||||
attachments = get_attachments(invoice.doctype, invoice.name)
|
attachments = get_attachments(invoice.doctype, invoice.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user