Skip to content

Instantly share code, notes, and snippets.

View rmehta's full-sized avatar

Rushabh Mehta rmehta

View GitHub Profile
cur_frm.cscript.custom_entries_add = function(doc, cdt, cdn) {
var row = frappe.model.get_doc(cdt, cdn);
row.start_date_of_accounting_period = doc.start_date_of_accounting_period;
row.end_date_of_accounting_period = doc.end_date_of_accounting_period;
row.number_of_days = new Date(row.end_date_of_accounting_period) - new Date(row.start_date_of_accounting_period); // milliseconds
row.number_of_days = Math.round(row.number_of_days / 86400000);
refresh_field("start_date_of_accounting_period");
refresh_field("end_date_of_accounting_period");
refresh_field("number_of_days");
}
// refactored by Rushabh Mehta
// original script https://gist.github.com/rmehta/5a7dbf05494990b838f8
cur_frm.add_fetch('item_code','amount_allocated_on_permit',
'amount_allocated_on_permit');
window.naivasha = {
recalculate: function(doc, child_doctype, child_name) {
if(!doc) {
doc = cur_frm.doc;
@rmehta
rmehta / erpnext_magento.php
Last active April 24, 2024 06:57
Sample ERPNext Magento Connector
<?php
// contributed by supplify.com
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '../curl/Zebra_cURL.php';
require_once '../app/Mage.php';
Mage::app();
class action extends Zebra_cURL{
@rmehta
rmehta / frappe_docs_remove_unused_images.py
Last active December 3, 2015 11:17
Purge unused image files in docs
# run this from the docs folder
from __future__ import unicode_literals
import os, re
images = []
for basepath, folders, files in os.walk("."):
for f in files:
key, extn = f.rsplit(".", 1)
class House:
name = None
ability = None
students = None
class Student:
name = None
ability = None
# houses
# you can selectively import objects from different files like this:
from houses import all_houses
from students import all_students
def sort(student):
for house in all_houses:
if house.ability == student.ability:
if house.students is None:
house.students = []
doc = frappe.get_doc(doctype, name)
if hasattr(doc, 'has_web_form_permission'):
if not doc.has_web_form_permission():
return False

Petition for mandating use of Free and Open Source in New Education Policy Draft circulated by Government of India

For the first time, the Government of India is embarking on a time-bound grassroots consultative process, which will enable the Ministry of HRD to reach out to individuals across the country through over 2.75 lakh direct consultations while also taking input from citizens online.

Here is the draft policy http://mhrd.gov.in/nep-new

In reference to this, we find it strange that the government has not included the mandate for schools to use Free and Open Source Software. Not only is Free Software cost effective, there are many other benefits.

# $ bench --site yoursitename console
for d in frappe.get_all('Your DocType', filters={'company': old_company}):
doc = frappe.get_doc('Your DocType', d.name)
doc.company = new_company
doc.save()
frappe.ui.form.on('Your DocType', 'button', function(frm) {
frm.set_value('total', frm.doc.value1 + frm.doc.value2 + frm.doc.value3);
});