Scheduler

bench –site your_sitename enable-scheduler

 

 

bench doctor

https://frappeframework.com/docs/user/en/bench/guides/diagnosing-the-scheduler

bench –site gor.site.com show-pending-jobs

 

$ bench –site [site-name] trigger-scheduler-event all

 

 

Wifi Password Revealed Win10

Command prompt to show password of Wifi:

Open the command prompt and run it as administrator.

netsh wlan show profile

Type the following command to see the password of any WiFi network:
netsh wlan show profile WiFi-name key=clear
Under the security settings, in the ‘key content’, you see the WiFi password of that particular network.

Redirect Based on Country IP

$.getJSON(‘http://ip-api.com/json?callback=?’, function(data) {
console.log(JSON.stringify(data, null, 2));
if(data.country !=”Iraq”){
alert(“You are not authorised to access the system from ” + data.country + “please contact the administrator”);
//window.location.replace(“http://google.com”);
}
});

Crawling and IP permissions

It is best handled with a robots.txt file, for just bots that respect the file.

To block the whole site add this to robots.txt in the root directory of your site:

User-agent: *
Disallow: /
To limit access to your site for everyone else, .htaccess is better, but you would need to define access rules, by IP address for example.

Below are the .htaccess rules to restrict everyone except your people from your company IP:

Order allow,deny
# Enter your companies IP address here
Allow from 255.1.1.1
Deny from all

Codes


bench --site www.site.com uninstall-app meeting

BackUp
bench backup –with-files
bench –site backup –with-files

bench backup

bench backup-all-sites
bench –site [sitename] uninstall-app [app]

root@erp:/home/frappe/frappe-bench# bench –site xx.aaa.com –force restore 20171005_004314_883fdeba_database.sql
bench –site aa.site.com –force restore sites/aaaaa/private/backups/20180402_010035_29d7966e_database.sql

root@erp:/home/frappe/frappe-bench/apps# cd ..
root@erp:/home/frappe/frappe-bench# bench –help | grep uninstall
uninstall-app Remove app and linked modules from site
root@erp:/home/frappe/frappe-bench#
root@erp:/home/frappe/frappe-bench# bench –help | grep remove
remove-app completely remove app from bench
remove-from-installed-apps Remove app from site’s installed-apps list

 

 

 

Event Name Description
setup Triggered once when the form is created for the first time
before_load Triggered before the form is about to load
onload Triggered when the form is loaded and is about to render
refresh Triggered when the form is loaded and rendered.
onload_post_render Triggered after the form is loaded and rendered
validate Triggered before before_save
before_save Triggered before save is called
after_save Triggered after form is saved
before_submit Triggered before submit is called
on_submit Triggered after form is submitted
before_cancel Triggered before cancel is called
after_cancel Triggered after form is cancelled
timeline_refresh Triggered after form timeline is rendered
{fieldname}_on_form_rendered Triggered when a row is opened as a form in a Table field
{fieldname} Triggered when the value of fieldname is changed

https://frappeframework.com/docs/user/en/api/form

More on this at:

https://github.com/frappe/frappe/wiki/Developer-Cheatsheet#1-to-add-a-new-handler-on-value-change

http://pcbbc.site.mobi/templates/mobile/facade_transcoder_iframe.php?u=%2Ffrappe%2Ffrappe%2Fwiki%2FClient-Side-Scripting-Index%3Fimz_s%3Dqc84i7nnq3l78t0hqno42b7rk6&lang=en

https://wiki.erpnext.org/display/ENG/Add+a+Custom+Button

 

 

 

Call api to get values of another doc type from a given doctype

frappe.ui.form.on(“Document Record”, {
onload_post_render: function(frm) {

// This function is run right after a Sales Invoice is rendered and loaded

cur_frm.set_value(“document_by”,user);
if(user ==”Administrator”){alert(“FKNote: No details for the sender was fetched since there is no employee for Administrator, the system will now show you an error … in order for details to be fetched an account has to be created”)}

var container;
frappe.call({
‘method’: ‘frappe.client.get’,
‘args’: {
‘doctype’: ‘Purchase Order’,
‘fieldname’: ‘title’,
‘filters’: { ‘owner’: user, ‘name’:”PO-04565″}
}
,
callback: function(r){
// msgprint(r.message.salutation);
console.log(r)
container = r.message.company +”\n”+r.message.salutation +”. “+r.message.employee_name +”\n”+r.message.designation +”\n”+ r.message.company_email+”\n”+ r.message.cell_number
cur_frm.set_value(“sender_details”,container);

cur_frm.set_value(fieldname, r.message);

}

});

// https://github.com/frappe/frappe/wiki/Developer-Cheatsheet

// This listener is added to the customer field, listening for a keypress event
// cur_frm.fields_dict.customer.$input.on(“keypress”, function(evt){
// Code specified here will run when a key is pressed on the customer field.
// });

}
});

//var x = document.getElementsByClassName(“ellipsis title-text”);
//var bb = x[0].innerHTML;
//alert(bb)

//if( ! bb.indexOf(“Document”) !== -1){}else{
//cur_frm.set_value(“document_ref_test”, x[0].innerHTML );
//}

//var ss = document.getElementsByClassName(“control-input”);
//ss[0].innerHTML = bb;

//https://pcbbc.site.mobi/templates/mobile/facade_transcoder_iframe.php?u=%2Ffrappe%2Ffrappe%2Fwiki%2FClient-Side-Scripting-Index%3Fimz_s%3Dqc84i7nnq3l78t0hqno42b7rk6&lang=en

crontab

https://help.ubuntu.com/lts/serverguide/backup-shellscripts.html
https://alvinalexander.com/linux/linux-crontab-file-format-example
https://crontab.guru/every-3-minutes

To watch the contents of a directory change, you could use

watch -d ls -l
for more: http://beerpla.net/2007/08/04/watch-a-useful-linux-command-you-may-have-never-heard-of/

Select:
https://crontab-generator.org/

 

 

https://serverfault.com/questions/258489/how-to-run-cron-job-on-a-specific-hour-every-day

# +--------- Minute (0-59)                    | Output Dumper: >/dev/null 2>&1
# | +------- Hour (0-23)                      | Multiple Values Use Commas: 3,12,47
# | | +----- Day Of Month (1-31)              | Do every X intervals: */X  -> Example: */15 * * * *  Is every 15 minutes
# | | | +--- Month (1 -12)                    | Aliases: @reboot -> Run once at startup; @hourly -> 0 * * * *;
# | | | | +- Day Of Week (0-6) (Sunday = 0)   | @daily -> 0 0 * * *; @weekly -> 0 0 * * 0; @monthly ->0 0 1 * *;
# | | | | |                                   | @yearly -> 0 0 1 1 *;

Make a New App

Once the bench is installed, you will see two main folders, apps and sites. All the applications will be installed in apps.

To make a new application, go to your bench folder and run, bench new-app {app_name} and fill in details about the application. This will create a boilerplate application for you.

$ bench new-app library_management
App Title (defaut: Lib Mgt): Library Management
App Description:  App for managing Articles, Members, Memberships and Transactions for Libraries
App Publisher: Frappé
App Email: info@frappe.io
App Icon (default 'octicon octicon-file-directory'): octicon octicon-book
App Color (default 'grey'): #589494
App License (default 'MIT'): GNU General Public License

App Structure

The application will be created in a folder called library_management and will have the following structure:

.
├── MANIFEST.in
├── README.md
├── library_management
│   ├── __init__.py
│   ├── config
│   │   ├── __init__.py
│   │   └── desktop.py
│   ├── hooks.py
│   ├── library_management
│   │   └── __init__.py
│   ├── modules.txt
│   ├── patches.txt
│   └── templates
│       ├── __init__.py
│       ├── generators
│       │   └── __init__.py
│       ├── pages
│       │   └── __init__.py
│       └── statics
├── license.txt
├── requirements.txt
└── setup.py
  1. config folder contains application configuration info
  2. desktop.py is where desktop icons can be added to the Desk
  3. hooks.py is where integrations with the environment and other applications is mentioned.
  4. library_management (inner) is a module that is bootstrapped. In Frappé, a module is where model and controller files reside.
  5. modules.txt contains list of modules in the app. When you create a new module, it is required that you update it in this file.
  6. patches.txt is where migration patches are written. They are python module references using the dot notation.
  7. templates is the folder where web view templates are maintained. Templates for Login and other standard pages are bootstrapped in frappe.
  8. generators are where templates for models are maintained, where each model instance has a separte web route, for example a Blog Post where each post has its unique web url. In Frappé, the templating engine used is Jinja2
  9. pages is where single route templates are maintained. For example for a “/blog” type of page.