Beispiel #1
0
def execute():
    company = frappe.get_all('Company', filters={'country': 'Italy'})
    if not company:
        return

    frappe.reload_doc('regional', 'report', 'electronic_invoice_register')
    make_custom_fields()
    setup_report()

    # Set state codes
    condition = ""
    for state, code in state_codes.items():
        condition += " when {0} then {1}".format(frappe.db.escape(state),
                                                 frappe.db.escape(code))

    if condition:
        condition = "state_code = (case state {0} end),".format(condition)

    frappe.db.sql("""
		UPDATE tabAddress set {condition} country_code = UPPER(ifnull((select code
			from `tabCountry` where name = `tabAddress`.country), ''))
			where country_code is null and state_code is null
	""".format(condition=condition))

    frappe.db.sql("""
		UPDATE `tabSales Invoice Item` si, `tabSales Order` so
			set si.customer_po_no = so.po_no, si.customer_po_date = so.po_date
		WHERE
			si.sales_order = so.name and so.po_no is not null
	""")
def execute():
	company = frappe.get_all('Company', filters = {'country': 'Italy'})
	if not company:
		return

	frappe.reload_doc('regional', 'report', 'electronic_invoice_register')
	make_custom_fields()
	setup_report()

	# Set state codes
	condition = ""
	for state, code in state_codes.items():
		condition += " when '{0}' then '{1}'".format(frappe.db.escape(state), frappe.db.escape(code))

	if condition:
		condition = "state_code = (case state {0} end),".format(condition)

	frappe.db.sql("""
		UPDATE tabAddress set {condition} country_code = UPPER(ifnull((select code
			from `tabCountry` where name = `tabAddress`.country), ''))
			where country_code is null and state_code is null
	""".format(condition=condition))

	frappe.db.sql("""
		UPDATE `tabSales Invoice Item` si, `tabSales Order` so
			set si.customer_po_no = so.po_no, si.customer_po_date = so.po_date
		WHERE
			si.sales_order = so.name and so.po_no is not null
	""")
Beispiel #3
0
def set_state_code(doc, method):
	if doc.get('country_code'):
		doc.country_code = doc.country_code.upper()

	if not doc.get('state'):
		return

	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())
Beispiel #4
0
def set_state_code(doc, method):
    if not doc.get('state'):
        return

    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())
Beispiel #5
0
def set_state_code(doc, method):
    if doc.get("country_code"):
        doc.country_code = doc.country_code.upper()

    if not doc.get("state"):
        return

    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()
    }

    state = doc.get("state", "").lower()
    if state_codes_lower.get(state):
        doc.state_code = state_codes_lower.get(state)
def execute():

    company = frappe.get_all('Company', filters={'country': 'Italy'})
    if not company:
        return

    make_custom_fields()
    setup_report()

    # Set state codes
    condition = ""
    for state, code in state_codes.items():
        condition += " when '{0}' then '{1}'".format(frappe.db.escape(state),
                                                     frappe.db.escape(code))

    if condition:
        frappe.db.sql("""
        UPDATE tabAddress set state_code = (case state {condition} end)
        WHERE country in ('Italy', 'Italia', 'Italian Republic', 'Repubblica Italiana')
      """.format(condition=condition))
def execute():
	company = frappe.get_all('Company', filters = {'country': 'Italy'})
	if not company:
		return

	frappe.reload_doc('regional', 'report', 'electronic_invoice_register')
	make_custom_fields()
	setup_report()

	# Set state codes
	condition = ""
	for state, code in state_codes.items():
		condition += " when '{0}' then '{1}'".format(frappe.db.escape(state), frappe.db.escape(code))

	if condition:
		condition = "state_code = (case state {0} end),".format(condition)

	frappe.db.sql("""
		UPDATE tabAddress set {condition} country_code = UPPER(ifnull((select code
			from `tabCountry` where name = `tabAddress`.country), ''))
	""".format(condition=condition))
def execute():
    company = frappe.get_all('Company', filters={'country': 'Italy'})
    if not company:
        return

    frappe.reload_doc('regional', 'report', 'electronic_invoice_register')
    make_custom_fields()
    setup_report()

    # Set state codes
    condition = ""
    for state, code in state_codes.items():
        condition += " when '{0}' then '{1}'".format(frappe.db.escape(state),
                                                     frappe.db.escape(code))

    if condition:
        condition = "state_code = (case state {0} end),".format(condition)

    frappe.db.sql("""
		UPDATE tabAddress set {condition} country_code = UPPER(ifnull((select code
			from `tabCountry` where name = `tabAddress`.country), ''))
	""".format(condition=condition))