Skip to content

Instantly share code, notes, and snippets.

View vijaywm's full-sized avatar

Vijaya Raghavan vijaywm

  • Ahmedabad
View GitHub Profile
@vijaywm
vijaywm / js-hacks.md
Last active April 12, 2021 01:46
Js hacks for Frappe
async function timer (seconds) {
  return new Promise(resolve => setTimeout(resolve, seconds * 1000))
}

// Usage

...
await timer(0.5)
...
@vijaywm
vijaywm / Tabulator js in Frappe Report.md
Last active April 1, 2023 06:43
Tabulator javascript datagrid inside frappe reports

To use Tabulator javascript datagrid inside frappe reports

Hack to use Tabulator http://tabulator.info datagrid to display data inside frappe script reports. Check the several advanced features in Tabulator http://tabulator.info/docs/4.9.

How it works:

  • Hide frappe datatable by hiding the .report-wrapper div
  • Hide the message div, which displays 'No Data to Show' and other messages
  • Instantiate Tabulator in onload, monkey patch query_report's refresh method
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import getdate
import json
def execute(filters=None):
priority_map = {"High": 3, "Medium": 2, "Low": 1}
frappe.provide("frappe.views");
frappe.ui.form.on("Tab Report", {
onload: function (frm) {
if (!frm.is_new()) {
frm.tab_report = new frappe.views.TabReport({ frm: frm });
frm.tab_report.show();
}
},
prepare_report_data(data) {
this.data = data;
// prepare columns
this.data.columns.forEach((t) => {
t.title = t.label;
t.field = t.fieldname;
});
// set column cell formatter for known fieldtypes, if not provided already in report_settings
// Copyright (c) 2021, Vijay and contributors
// For license information, please see license.txt
frappe.provide("frappe.views");
frappe.ui.form.on("Tab Report", {
onload: function (frm) {
frm.tab_report = new frappe.views.TabReport({ frm: frm });
frm.tab_report.show();
},
@vijaywm
vijaywm / frappe-reference-guide.md
Last active March 25, 2024 10:24
Frappe Reference Guide
@vijaywm
vijaywm / bench.md
Created February 18, 2019 09:01
frappe bench commands

Bench Commands Cheatsheet Bench Commands Cheatsheet General Usage bench --version - Show bench version bench version - Show version of all apps bench src - Show bench repo directory bench --help - Show all commands and help bench [command] --help - Show help for command bench init [bench-name] - Create a new bench (Run from home dir) bench --site [site-name] COMMAND - Specify site for command

//Replace "DocType" with the source DocType
frappe.ui.form.on("DocType", {
//The trigger can be changed, but refresh must be used to use a button
refresh: function(frm) {
//The following line creates a button.
frm.add_custom_button(__("Update"),
//The function below is triggered when the button is pressed.
function() {
frappe.call({
"method": "frappe.client.set_value",
@vijaywm
vijaywm / 0_reuse_code.js
Created August 2, 2017 10:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console