This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if frappe.db.exists('Nombre De La Tabla', {'campo_de_la_tabla': 'valor_que_desea_comprobar'}): | |
# Codigo a ejecutar en caso, si se encuentre el valor que busca | |
else: | |
# Codigo a ejecutar en caso no se encuentre, el valor que buscaba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OBTENER DATOS DE LA BASE DE DATOS | |
# 'frappe.db.get_values' se puede utilizar para obtener los datos de una tabla de la base de datos, los valores pueden ser | |
# almacenados en una variable, esta instruccion retorna una lista, donde en cada posicion se encuentra un | |
# diccionario con los datos que desea consultar. El indice puede variar segun los elementos encontrados. | |
# Ejemplo: | |
# filters: sirve para filtrar los valores que desea, dependiendo el valor que busca. | |
# recibe como parametro {'campo_de_la_tabla': 'valor_que_busca'}, tambien puede incluir mas de un campo como filtro | |
# fieldname: almacena los datos encontrados, en una lista, recibe como parametro los campos que desea consultar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// La funcion se ejecutara en Sales Invoice, cuando el documento sea recargado. | |
// frm : Hace referencia al documento con el que se esta trabajando, en este | |
// caso Sales Invoice. | |
// cdt : Nombre del Doctype con el que se esta trabajando actualmente. | |
// cdn : Nombre del docuumento con el que se esta trabajando actualmente. | |
frappe.ui.form.on("Sales Invoice", "refresh", function(frm, cdt, cdn) { | |
var d = frappe.get_doc(cdt, cdn); | |
// Para acceder a un campo en especifico, utilice la variable a la cual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Sintaxis: | |
# get_value(self, doctype, filters=None, fieldname=name, ignore=None, | |
# as_dict=False, debug=False, order_by=None, cache=False) | |
# Retorna el primer cliente que empiece con a | |
frappe.db.get_value('Customer', {'name': ('like a%')}) | |
# Retorna el ultimo acceso de **usuario** 'test@example.com' | |
frappe.db.get_value('user', 'test@example.com', 'last_login') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Retorna a los clientes con nombres empiecen con a | |
customers = frappe.db.get_values('Customer', {'name':('like a%')} | |
# Retorna todo sobre el ultimo acceso de **usuario** 'test@example.com' | |
user = frappe.db.get_values('user', 'test@example.com', '*')[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Retorna los nombres de clientes como diccionario. | |
frappe.db.sql('select name from tabCustomer', as_dict=True | |
# Retorna los nombres que empiecen con la letra "a". | |
frappe.db.sql('select name from tabCustomer where name like %s', 'a%') | |
# Valores como diccionario. | |
frappe.db.sql('select name from tabCustomer where name like %(name)s and owner=%(owner)s', | |
{'name':'a%', 'owner':'test@example.com'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frappe.ui.form.on("Sales Invoice", "refresh", function(frm, cdt, cdn) { | |
// es-GT: Obtiene el numero de Identificacion tributaria ingresado en la hoja del cliente. | |
// en-US: Fetches the Taxpayer Identification Number entered in the Customer doctype. | |
cur_frm.add_fetch("customer", "nit_face_customer", "nit_face_customer"); | |
// Funcion para la obtencion del PDF, segun el documento generado. | |
function pdf_button() { | |
frappe.call({ | |
// Este metodo verifica, el modo de generacion de PDF para la factura electronica | |
// retornara 'Manul' o 'Automatico' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frappe.ui.form.on("Sales Invoice", "refresh", function(frm, cdt, cdn) { | |
// es-GT: Obtiene el numero de Identificacion tributaria ingresado en la hoja del cliente. | |
// en-US: Fetches the Taxpayer Identification Number entered in the Customer doctype. | |
cur_frm.add_fetch("customer", "nit_face_customer", "nit_face_customer"); | |
// Funcion para la obtencion del PDF, segun el documento generado. | |
function pdf_button() { | |
frappe.call({ | |
// Este metodo verifica, el modo de generacion de PDF para la factura electronica | |
// retornara 'Manul' o 'Automatico' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calculations_tax_gt = function(frm, cdt, cdn) { | |
var this_row_qty, this_row_rate, this_row_amount, this_row_conversion_factor, this_row_stock_qty, this_row_tax_rate, this_row_tax_amount; | |
var net_fuel_tally = 0; | |
var net_goods_tally = 0; | |
var net_services_tally = 0; | |
var sales_tax_temp; | |
frm.doc.items.forEach((item_row, index) => { | |
if (item_row.name == cdn) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cuando carga, carga la pagina sales-analitycs-2 que a su vez recibe una funcion con parametro | |
// wrapper, esto quiere decri que podra hacer varias cosas al mismo tiempo | |
frappe.pages['sales-analytics-2'].on_page_load = function (wrapper) { | |
var page = frappe.ui.make_app_page({ | |
parent: wrapper, | |
title: 'Sales Analytics 2.0', | |
single_column: true | |
}); |
OlderNewer