fix(regional,italy): added state code on address, updated patch

moved state codes to init, rewired patch
added logic to autoset state code on address validate
handled multiple names for Italy
refactored validate_address_italy to validate_address
This commit is contained in:
Gaurav
2019-02-19 16:28:22 +05:30
parent ff6d2692d3
commit 3f046136d4
6 changed files with 45 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ from erpnext.controllers.taxes_and_totals import get_itemised_tax
from frappe import _
from frappe.utils.file_manager import save_file, remove_file
from frappe.desk.form.load import get_attachments
from erpnext.regional.italy import state_codes
def update_itemised_tax_data(doc):
@@ -282,4 +283,11 @@ def get_progressive_name_and_number(doc):
progressive_name = frappe.model.naming.make_autoname(company_tax_id + "_.#####")
progressive_number = progressive_name.split("_")[1]
return progressive_name, progressive_number
return progressive_name, progressive_number
def validate_address(doc, method):
if not (hasattr(doc, "state_code") and doc.country in ["Italy", "Italia", "Italian Republic", "Repubblica Italiana"]):
return
state_codes_lower = {key.lower():value for key,value in state_codes.items()}
doc.state_code = state_codes_lower.get(doc.get('state','').lower())