Friday, 11 May 2018

User Role and permission

https://erpnext.org/docs/user/manual/en/setting-up/users-and-permissions/user-permissions

How to set Role permission in ERP

https://erpnext.org/docs/user/manual/en/setting-up/users-and-permissions

Server setup

https://github.com/frappe/bench/wiki/Multitenant-Setup

Friday, 4 May 2018

how to import csv file into mysql table

LOAD DATA INFILE 'c:/tmp/discounts.csv'
INTO TABLE discounts
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;

How to convert dictionary to list in python

def demo():
     dict = {"a":1,"b":2,"c":3}
     lis = []
    temp = []
    for k,v in dict.items():
             temp = [k,v]
            lis.append(temp)
     return lis

How to generate Random question from database in mysql

select question from `tabQuestion` order by rand() limit 2;

Thursday, 3 May 2018

How to reload erp web page and settime function in JS

setTimeout(function(){
cur_frm.reload_doc();
},
  3000);

How to convert 12 Hours to 24 Hours

def convert24(str1):
    if str1[-2:] == "AM" and str1[:2] == "12":
        return "00" + str1[2:-2]
 
    elif str1[-2:] == "AM":
        return str1[:-2]
    elif str1[-2:] == "PM" and str1[:2] == "12":
        return str1[:-2] 
    else:
        return str(int(str1[:2]) + 12) + str1[2:8]     
print(convert24("08:05:45 PM"))

Tuesday, 1 May 2018

How to add only one row in child table using python

mycheck = False
for i in doc.deductions:
if i.salary_component == "Attendance Violation":
mycheck = True
i.amount = doc.deduction_amount
if mycheck:
pass
else:
row = doc.append('deductions', {})
row.salary_component = "Attendance Violation"
row.amount =doc.deduction_amount
doc.reload()

How to add row in child table using python add_child

row = doc.append('deductions', {})
row.salary_component = "Attendance Violation"
row.amount =doc.deduction_amount

Add new row in child table using Java script i. e. add_child

frappe.ui.form.on("Salary Slip", "validate", function(frm) {
deduction_amount = cur_frm.doc.deduction_amount;
frappe.msgprint(deduction_amount);
var row = frappe.model.add_child(cur_frm.doc, "Salary Slip", "deductions");
    row.salary_component = "Attendance Violation";
    row.amount = Math.round(deduction_amount);
refresh_field("deductions");
});

Django rest api - filter

views.py from django_filters.rest_framework import DjangoFilterBackend class PollList(viewsets.ModelViewSet):     queryset = X.objects...