From 9b769f27e692963b303b2426ca8f773d9f183ec8 Mon Sep 17 00:00:00 2001 From: monroy95 Date: Thu, 13 May 2021 19:28:14 +0000 Subject: [PATCH 1/5] Custom quick entry creado --- factura_electronica/__init__.py | 2 +- factura_electronica/patches.txt | 1 + .../v7_0_9/update_properties_fields.py | 77 ++++++++ factura_electronica/public/js/facelec.js | 175 +++++++++++++++++- 4 files changed, 253 insertions(+), 2 deletions(-) mode change 100644 => 100755 factura_electronica/patches.txt create mode 100755 factura_electronica/patches/v7_0_9/update_properties_fields.py diff --git a/factura_electronica/__init__.py b/factura_electronica/__init__.py index 5e188c83..21c3ef3b 100755 --- a/factura_electronica/__init__.py +++ b/factura_electronica/__init__.py @@ -11,7 +11,7 @@ # locale.setlocale(locale.LC_ALL, str('en_US.UTF-8')) -__version__ = '7.0.8' +__version__ = '7.0.9' @frappe.whitelist() def currency_in_words(amount, currency, cent_in_numb=0): diff --git a/factura_electronica/patches.txt b/factura_electronica/patches.txt old mode 100644 new mode 100755 index e69de29b..6b68409f --- a/factura_electronica/patches.txt +++ b/factura_electronica/patches.txt @@ -0,0 +1 @@ +factura_electronica.patches.v7_0_9.update_properties_fields \ No newline at end of file diff --git a/factura_electronica/patches/v7_0_9/update_properties_fields.py b/factura_electronica/patches/v7_0_9/update_properties_fields.py new file mode 100755 index 00000000..af68824f --- /dev/null +++ b/factura_electronica/patches/v7_0_9/update_properties_fields.py @@ -0,0 +1,77 @@ +import frappe + +# This patch deletes all the duplicate indexes created for same column +# The patch only checks for indexes with UNIQUE constraints + +def execute(): + try: + for ffield in ["city", "county", "state", "country"]: + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": ffield, + "default": "Guatemala", + "property": "reqd", + "value": 1, + "property_type": "Int" + }, + { + "doctype": 'Address', + "fieldname": ffield, + "property": "allow_in_quick_entry", + "value": 1, + "property_type": "Int" + }) + + frappe.make_property_setter({ + "doctype": 'Address', + "fieldname": 'is_primary_address', + "property": "allow_in_quick_entry", + "value": 1, + "property_type": "Int" + }, + { + "doctype": 'Address', + "fieldname": 'pincode', + "default": "0", + "property": "reqd", + "value": 1, + "property_type": "Int" + }, + { + "doctype": 'Address', + "fieldname": 'pincode', + "property": "allow_in_quick_entry", + "value": 0, + "property_type": "Int" + }, + { + "doctype": 'Address', + "fieldname": 'email_id', + "property": "reqd", + "value": 1, + "property_type": "Int" + }, + { + "doctype": 'Address', + "fieldname": 'email_id', + "property": "allow_in_quick_entry", + "value": 1, + "property_type": "Int" + }, + { + "doctype": 'Address', + "fieldname": 'phone', + "property": "reqd", + "value": 0, + "property_type": "Int" + }, + { + "doctype": 'Address', + "fieldname": 'phone', + "property": "allow_in_quick_entry", + "value": 1, + "property_type": "Int" + }) + + except: + pass diff --git a/factura_electronica/public/js/facelec.js b/factura_electronica/public/js/facelec.js index 24297eb5..c0f148bf 100755 --- a/factura_electronica/public/js/facelec.js +++ b/factura_electronica/public/js/facelec.js @@ -76,6 +76,10 @@ frappe.ui.form.on("Customer", { var cust_name_desc = __("Legal Name, for tax, government or contract use. For Example: Apple, Inc. Amazon.com, Inc., The Home Depot, Inc."); cur_frm.set_df_property("customer_name", "description", cust_name_desc); frm.refresh_field('customer_name'); + }, + onload: function (frm) { + frm.set_value('tax_id', frm.doc.nit_face_customer); + frm.set_value('nit_face_customer', frm.doc.tax_id); } }); @@ -208,4 +212,173 @@ frappe.ui.form.on("Expense Claim Detail", { frm.refresh(); } }, -}); \ No newline at end of file +}); + +// Personalizador de quick entry en customer +frappe.provide('frappe.ui.form'); + +frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ + init: function (doctype, after_insert) { + this.skip_redirect_on_error = true; + this._super(doctype, after_insert); + }, + + render_dialog: function () { + console.log('Ejecutando prueba') + this.mandatory = this.get_field(); + this._super(); + }, + + get_field: function () { + var variant_fields = [ + { + label: __('Full Name'), + fieldname: 'customer_name', + fieldtype: 'Data', + }, + { + label: __('Type'), + fieldname: 'customer_type', + fieldtype: 'Select', + options: ['', 'Company', 'Individual'] + }, + { + fieldtype: "Section Break", + label: __(""), + collapsible: 0 + }, + { + label: __('NIT FEL'), + fieldname: 'nit_face_customer', + fieldtype: 'Data', + }, + { + fieldtype: "Column Break" + }, + { + label: __('NIT'), + fieldname: 'tax_id', + fieldtype: 'Data', + reqd: true, + description: 'FEL' + }, + { + fieldtype: "Section Break", + label: __(""), + collapsible: 0 + }, + { + label: __('Customer Group'), + fieldname: 'customer_group', + fieldtype: 'Link', + }, + { + label: __('Territory'), + fieldname: 'territory', + fieldtype: 'Link', + }, + + { + fieldtype: "Section Break", + label: __("Primary Contact Details"), + collapsible: 1 + }, + { + label: __("Email ID"), + fieldname: "email_id", + fieldtype: "Data", + options: 'Email', + reqd: 0 + }, + { + fieldtype: "Column Break" + }, + { + label: __("Mobile Number"), + fieldname: "mobile_no", + fieldtype: "Data" + }, + { + fieldtype: "Section Break", + label: __("Primary Address Details"), + collapsible: 1 + }, + { + label: __("Address Line 1"), + fieldname: "address_line1", + fieldtype: "Data", + default: 'Guatemala', + reqd: 1, + options: 'FEL' + }, + { + label: __("Address Line 2"), + fieldname: "address_line2", + fieldtype: "Data" + }, + { + label: __("City/Town"), + fieldname: "city", + fieldtype: "Data", + reqd: 1, + description: 'FEL Ciudad ej.: Antigua Guatemala' + }, + { + label: __("County"), + fieldname: "county", + fieldtype: "Data", + reqd: 1, + description: 'FEL Municipio ej.: Antigua Guatemala', + allow_in_quick_entry: 1 + }, + { + label: __("State"), + fieldname: "state", + fieldtype: "Data", + reqd: 1, + description: 'FEL Departamento ej.: Sacatepéquez' + }, + { + label: __("Country"), + fieldname: "country", + fieldtype: "Link", + reqd: 1, + options: 'Country', + description: 'FEL Pais ej: Guatemala' + }, + { + label: __("ZIP Code"), + fieldname: "pincode", + default: '0', + fieldtype: "Data", + description: 'FEL Código Postal ej.: 03001' + }, + { + fieldtype: "Column Break" + }, + { + label: __("Phone"), + fieldname: "phone", + fieldtype: "Data", + allow_in_quick_entry: 1 + }, + { + label: __("Email Address"), + fieldname: "email_id", + fieldtype: "Data", + reqd: 1, + allow_in_quick_entry: 1, + options: 'Email', + description: 'FEL Correo Electronico ej: micorreo@hola.com', + }, + { + label: __("Preferred Billing Address"), + fieldname: "is_primary_address", + fieldtype: "Check", + description: 'FEL Dirección para facturar', + allow_in_quick_entry: 1 + },]; + + return variant_fields; + }, +}) \ No newline at end of file From 1e5b36a5e1a4efe3b92a551632299da97d7cf13c Mon Sep 17 00:00:00 2001 From: monroy95 Date: Thu, 13 May 2021 22:52:11 +0000 Subject: [PATCH 2/5] Customizacion Quick Entry pra creacion de clientes --- factura_electronica/api_erp.py | 28 ++++- factura_electronica/hooks.py | 5 +- factura_electronica/patches.txt | 2 +- .../v7_0_9/update_properties_fields.py | 114 ++++++++++-------- factura_electronica/public/js/facelec.js | 20 +-- 5 files changed, 110 insertions(+), 59 deletions(-) diff --git a/factura_electronica/api_erp.py b/factura_electronica/api_erp.py index eef6faca..f355ad2e 100755 --- a/factura_electronica/api_erp.py +++ b/factura_electronica/api_erp.py @@ -6,10 +6,12 @@ import json import frappe +from frappe import _ +from frappe.utils import cstr + from factura_electronica.controllers.journal_entry import JournalEntrySaleInvoice from factura_electronica.controllers.journal_entry_special import JournalEntrySpecialISR from factura_electronica.factura_electronica.doctype.batch_electronic_invoice.batch_electronic_invoice import batch_generator -from frappe import _ # USAR ESTE SCRIPT COMO API PARA COMUNICAR APPS DEL ECOSISTEMA FRAPPE/ERPNEXT :) @@ -133,3 +135,27 @@ def download_asl_files(): filedata = fileobj.read() frappe.local.response.filecontent = filedata frappe.local.response.type = "download" + + +def custom_customer_info(doc, method): + # Runs on event update - Customer + # this function will get call `on_update` as we define in hook.py + add_address_info(doc) + + +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) + # adding custom data to address + address_doc.email_id = doc.get('email_id') + 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() diff --git a/factura_electronica/hooks.py b/factura_electronica/hooks.py index 51ccea96..c5c9e7fb 100755 --- a/factura_electronica/hooks.py +++ b/factura_electronica/hooks.py @@ -108,7 +108,10 @@ # # "on_save": "factura_electronica.api.get_tax_html", # "on_cancel": "method", # "on_trash": "method" - # } + # }, + 'Customer': { + 'on_update': 'factura_electronica.api_erp.custom_customer_info' + } } # Scheduled Tasks diff --git a/factura_electronica/patches.txt b/factura_electronica/patches.txt index 6b68409f..f59ab626 100755 --- a/factura_electronica/patches.txt +++ b/factura_electronica/patches.txt @@ -1 +1 @@ -factura_electronica.patches.v7_0_9.update_properties_fields \ No newline at end of file +factura_electronica.patches.v7_0_9.update_props_address \ No newline at end of file diff --git a/factura_electronica/patches/v7_0_9/update_properties_fields.py b/factura_electronica/patches/v7_0_9/update_properties_fields.py index af68824f..05d9af57 100755 --- a/factura_electronica/patches/v7_0_9/update_properties_fields.py +++ b/factura_electronica/patches/v7_0_9/update_properties_fields.py @@ -5,73 +5,93 @@ def execute(): try: - for ffield in ["city", "county", "state", "country"]: - frappe.make_property_setter({ - "doctype": "Address", - "fieldname": ffield, - "default": "Guatemala", - "property": "reqd", - "value": 1, - "property_type": "Int" - }, - { - "doctype": 'Address', - "fieldname": ffield, - "property": "allow_in_quick_entry", - "value": 1, - "property_type": "Int" - }) - + # Cambios propiedades campo pincode frappe.make_property_setter({ - "doctype": 'Address', - "fieldname": 'is_primary_address', + "doctype": "Address", + "fieldname": "pincode", "property": "allow_in_quick_entry", "value": 1, "property_type": "Int" - }, - { - "doctype": 'Address', - "fieldname": 'pincode', - "default": "0", + }) + + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": "pincode", + # "default": "0", "property": "reqd", "value": 1, "property_type": "Int" - }, - { - "doctype": 'Address', - "fieldname": 'pincode', + }) + + # Cambios propiedades campo email_id + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": "email_id", "property": "allow_in_quick_entry", - "value": 0, + "value": 1, "property_type": "Int" - }, - { - "doctype": 'Address', - "fieldname": 'email_id', + }) + + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": "email_id", "property": "reqd", "value": 1, "property_type": "Int" - }, - { - "doctype": 'Address', - "fieldname": 'email_id', + }) + + # Cambios propiedades campo phone + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": "phone", + "property": "reqd", + "value": 0, + "property_type": "Int" + }) + + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": "phone", "property": "allow_in_quick_entry", "value": 1, "property_type": "Int" - }, - { - "doctype": 'Address', - "fieldname": 'phone', + }) + + # Campo tax id en Customer Dt + frappe.make_property_setter({ + "doctype": "Customer", + "fieldname": "tax_id", "property": "reqd", - "value": 0, + "value": 1, "property_type": "Int" - }, - { - "doctype": 'Address', - "fieldname": 'phone', + }) + + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": "tax_id", "property": "allow_in_quick_entry", "value": 1, "property_type": "Int" }) + for ffield in ["city", "county", "state", "country"]: + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": ffield, + "default": "Guatemala", + "property": "reqd", + "value": 1, + "property_type": "Int" + }) + + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": ffield, + "property": "allow_in_quick_entry", + "value": 1, + "property_type": "Int" + }) + except: - pass + with open("debug.txt", "w") as f: + f.write(str(frappe.get_traceback())) diff --git a/factura_electronica/public/js/facelec.js b/factura_electronica/public/js/facelec.js index c0f148bf..cf45aa35 100755 --- a/factura_electronica/public/js/facelec.js +++ b/factura_electronica/public/js/facelec.js @@ -189,7 +189,7 @@ frappe.ui.form.on("Address", { frm.set_df_property("address_line1", "description", __("* FEL: Direccion Comercial 1")); 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", __("Municipio p. ej.: Antigua Guatemala")); + frm.set_df_property("county", "description", __("FEL: Municipio p. ej.: Antigua Guatemala")); 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")); @@ -224,13 +224,13 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ }, render_dialog: function () { - console.log('Ejecutando prueba') + // console.log('Ejecutando prueba') this.mandatory = this.get_field(); this._super(); }, get_field: function () { - var variant_fields = [ + const variant_fields = [ { label: __('Full Name'), fieldname: 'customer_name', @@ -251,6 +251,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __('NIT FEL'), fieldname: 'nit_face_customer', fieldtype: 'Data', + description: 'FEL: Si no tiene disponible el NIT escriba C/F' }, { fieldtype: "Column Break" @@ -260,7 +261,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ fieldname: 'tax_id', fieldtype: 'Data', reqd: true, - description: 'FEL' + description: 'FEL: Si no tiene disponible el NIT escriba C/F' }, { fieldtype: "Section Break", @@ -288,7 +289,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ fieldname: "email_id", fieldtype: "Data", options: 'Email', - reqd: 0 + reqd: 1 }, { fieldtype: "Column Break" @@ -298,6 +299,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ fieldname: "mobile_no", fieldtype: "Data" }, + { fieldtype: "Section Break", label: __("Primary Address Details"), @@ -328,8 +330,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ fieldname: "county", fieldtype: "Data", reqd: 1, - description: 'FEL Municipio ej.: Antigua Guatemala', - allow_in_quick_entry: 1 + description: 'FEL: Municipio p. ej.: Antigua Guatemala' }, { label: __("State"), @@ -350,6 +351,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __("ZIP Code"), fieldname: "pincode", default: '0', + reqd: 1, fieldtype: "Data", description: 'FEL Código Postal ej.: 03001' }, @@ -368,7 +370,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ fieldtype: "Data", reqd: 1, allow_in_quick_entry: 1, - options: 'Email', + // options: 'Email', description: 'FEL Correo Electronico ej: micorreo@hola.com', }, { @@ -377,7 +379,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ fieldtype: "Check", description: 'FEL Dirección para facturar', allow_in_quick_entry: 1 - },]; + }]; return variant_fields; }, From 8b596766f364b98806afa3049965cc3d7ad35730 Mon Sep 17 00:00:00 2001 From: monroy95 Date: Thu, 13 May 2021 22:52:56 +0000 Subject: [PATCH 3/5] Cambio nombre parche --- .../{update_properties_fields.py => update_props_address.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename factura_electronica/patches/v7_0_9/{update_properties_fields.py => update_props_address.py} (100%) diff --git a/factura_electronica/patches/v7_0_9/update_properties_fields.py b/factura_electronica/patches/v7_0_9/update_props_address.py similarity index 100% rename from factura_electronica/patches/v7_0_9/update_properties_fields.py rename to factura_electronica/patches/v7_0_9/update_props_address.py From 96ab0f1f8257d8cbd790cbbece6a50a01b113a9f Mon Sep 17 00:00:00 2001 From: monroy95 Date: Fri, 14 May 2021 16:29:03 +0000 Subject: [PATCH 4/5] Adding default vals quick entry --- factura_electronica/api_erp.py | 10 +++++++- .../patches/v7_0_9/update_props_address.py | 24 ++++++++++++++++--- factura_electronica/public/js/facelec.js | 6 +++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/factura_electronica/api_erp.py b/factura_electronica/api_erp.py index f355ad2e..15411ef4 100755 --- a/factura_electronica/api_erp.py +++ b/factura_electronica/api_erp.py @@ -12,6 +12,7 @@ from factura_electronica.controllers.journal_entry import JournalEntrySaleInvoice from factura_electronica.controllers.journal_entry_special import JournalEntrySpecialISR from factura_electronica.factura_electronica.doctype.batch_electronic_invoice.batch_electronic_invoice import batch_generator +from factura_electronica.fel_api import validate_configuration # USAR ESTE SCRIPT COMO API PARA COMUNICAR APPS DEL ECOSISTEMA FRAPPE/ERPNEXT :) @@ -153,8 +154,15 @@ def add_address_info(doc): 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 = doc.get('email_id') + 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') diff --git a/factura_electronica/patches/v7_0_9/update_props_address.py b/factura_electronica/patches/v7_0_9/update_props_address.py index 05d9af57..14ec0ad8 100755 --- a/factura_electronica/patches/v7_0_9/update_props_address.py +++ b/factura_electronica/patches/v7_0_9/update_props_address.py @@ -17,7 +17,7 @@ def execute(): frappe.make_property_setter({ "doctype": "Address", "fieldname": "pincode", - # "default": "0", + "default": "0", "property": "reqd", "value": 1, "property_type": "Int" @@ -36,7 +36,7 @@ def execute(): "doctype": "Address", "fieldname": "email_id", "property": "reqd", - "value": 1, + "value": 0, "property_type": "Int" }) @@ -69,12 +69,30 @@ def execute(): frappe.make_property_setter({ "doctype": "Address", "fieldname": "tax_id", + "default": "C/F", + "property": "allow_in_quick_entry", + "value": 1, + "property_type": "Int" + }) + + frappe.make_property_setter({ + "doctype": "Customer", + "fieldname": "county", + "property": "reqd", + "value": 0, + "property_type": "Int" + }) + + frappe.make_property_setter({ + "doctype": "Address", + "fieldname": "county", + "default": "Guatemala", "property": "allow_in_quick_entry", "value": 1, "property_type": "Int" }) - for ffield in ["city", "county", "state", "country"]: + for ffield in ["city", "state", "country"]: frappe.make_property_setter({ "doctype": "Address", "fieldname": ffield, diff --git a/factura_electronica/public/js/facelec.js b/factura_electronica/public/js/facelec.js index cf45aa35..e6f1f357 100755 --- a/factura_electronica/public/js/facelec.js +++ b/factura_electronica/public/js/facelec.js @@ -251,6 +251,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __('NIT FEL'), fieldname: 'nit_face_customer', fieldtype: 'Data', + default: 'C/F', description: 'FEL: Si no tiene disponible el NIT escriba C/F' }, { @@ -260,6 +261,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __('NIT'), fieldname: 'tax_id', fieldtype: 'Data', + default: 'C/F', reqd: true, description: 'FEL: Si no tiene disponible el NIT escriba C/F' }, @@ -322,6 +324,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __("City/Town"), fieldname: "city", fieldtype: "Data", + default: 'Guatemala', reqd: 1, description: 'FEL Ciudad ej.: Antigua Guatemala' }, @@ -329,6 +332,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __("County"), fieldname: "county", fieldtype: "Data", + default: 'Guatemala', reqd: 1, description: 'FEL: Municipio p. ej.: Antigua Guatemala' }, @@ -336,6 +340,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __("State"), fieldname: "state", fieldtype: "Data", + default: 'Guatemala', reqd: 1, description: 'FEL Departamento ej.: Sacatepéquez' }, @@ -343,6 +348,7 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __("Country"), fieldname: "country", fieldtype: "Link", + default: 'Guatemala', reqd: 1, options: 'Country', description: 'FEL Pais ej: Guatemala' From f48c99e2be8a46476d3cf2141cff9cc57a084984 Mon Sep 17 00:00:00 2001 From: monroy95 Date: Fri, 14 May 2021 16:47:54 +0000 Subject: [PATCH 5/5] OK customizacion quick entry new customer --- factura_electronica/api_erp.py | 48 +++++++++++++----------- factura_electronica/public/js/facelec.js | 3 +- 2 files changed, 28 insertions(+), 23 deletions(-) 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"));