diff --git a/factura_electronica/api_erp.py b/factura_electronica/api_erp.py
index 15411ef4..021918da 100755
--- a/factura_electronica/api_erp.py
+++ b/factura_electronica/api_erp.py
@@ -145,25 +145,29 @@ def custom_customer_info(doc, method):
def add_address_info(doc):
- if doc.flags.is_new_doc and doc.get('address_line1'):
- # this name construct should work
- # because we just create this customer
- # Billing is default type
- # there shouldn't be any more address of this customer
- address_name = (
- cstr(doc.name).strip() + '-' + cstr(_('Billing')).strip()
- )
- address_doc = frappe.get_doc('Address', address_name)
-
- email_facelec = ""
- if not doc.get('email_id'):
- status_config = validate_configuration()
- if status_config[1]:
- email_facelec = frappe.db.get_value('Configuracion Factura Electronica', {'name': status_config[1]}, 'correo_copia')
-
- # adding custom data to address
- address_doc.email_id = email_facelec
- address_doc.county = doc.get('county')
- address_doc.phone = doc.get('phone')
- address_doc.is_primary_address = doc.get('is_primary_address')
- address_doc.save()
+ try:
+ if doc.flags.is_new_doc and doc.get('address_line1'):
+ # this name construct should work
+ # because we just create this customer
+ # Billing is default type
+ # there shouldn't be any more address of this customer
+ address_name = (
+ cstr(doc.name).strip() + '-' + cstr(_('Billing')).strip()
+ )
+ address_doc = frappe.get_doc('Address', address_name)
+
+ email_facelec = doc.get('email_id')
+ if not doc.get('email_id'):
+ status_config = validate_configuration()
+ if status_config[0] and status_config[1]:
+ email_facelec = frappe.db.get_value('Configuracion Factura Electronica', {'name': status_config[1]}, 'correo_copia')
+
+ # adding custom data to address
+ address_doc.email_id = email_facelec
+ address_doc.county = doc.get('county')
+ address_doc.phone = doc.get('phone')
+ # En la creacion de direccion se definira como default
+ address_doc.is_primary_address = doc.get('is_primary_address') if doc.get('is_primary_address') else 1
+ address_doc.save()
+ except:
+ pass
diff --git a/factura_electronica/public/js/facelec.js b/factura_electronica/public/js/facelec.js
index e6f1f357..c7d3b7a3 100755
--- a/factura_electronica/public/js/facelec.js
+++ b/factura_electronica/public/js/facelec.js
@@ -190,9 +190,10 @@ frappe.ui.form.on("Address", {
frm.set_df_property("city", "description", __("FEL: Ciudad p. ej.: Antigua Guatemala"));
frm.set_df_property("state", "description", __("FEL: Departamento p. ej.: Sacatepéquez"));
frm.set_df_property("county", "description", __("FEL: Municipio p. ej.: Antigua Guatemala"));
-
+ frm.set_df_property("county", "reqd", 1);
frm.set_df_property("country", "description", __("FEL: Pais p. ej: Guatemala"));
frm.set_df_property("email_id", "description", __("FEL: Correo Electronico p. ej: micorreo@hola.com"));
+ frm.set_df_property("email_id", "reqd", 1);
frm.set_df_property("phone", "description", __("Teléfono: p. ej: +502 2333-2516"));
frm.set_df_property("pincode", "description", __("FEL: Código Postal p. ej.: 03001"));
frm.set_df_property("is_primary_address", "description", __("FEL: Dirección para facturar"));