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
#!/bin/bash | |
client=$1 | |
(echo '<ca>'; cat ca.crt; echo '</ca>';) >> $client.ovpn | |
(echo '<cert>'; cat $client.crt; echo '</cert>';) >> $client.ovpn | |
(echo '<key>'; cat $client.key; echo '</key>';) >> $client.ovpn |
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
#!/bin/bash | |
server="xxx.xxx.xxx.xxx" | |
client=$1 | |
ssh root@$server client=$client 'bash -s' <<'ENDSSH' | |
cd /etc/openvpn/easy-rsa | |
. ./vars | |
./build-key --batch $client | |
ENDSSH | |
scp root@$server:/etc/openvpn/easy-rsa/keys/$client.crt . | |
scp root@$server:/etc/openvpn/easy-rsa/keys/$client.key . |
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
get_field_precision: function(df, doc) { | |
var precision = cint(frappe.defaults.get_default("float_precision")) || 3; | |
// Here if the precision exists, it should return directly, | |
// Therefore, it always can overwrite number format -> 5,6,7,8 ... | |
if (df && cint(df.precision)) { | |
precision = cint(df.precision); | |
} else if(df && df.fieldtype === "Currency") { | |
var currency = this.get_field_currency(df, doc); | |
var number_format = get_number_format(currency); | |
var number_format_info = get_number_format_info(number_format); |
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
// Replace with new calculation of item value | |
cur_frm.cscript.calculate_item_values = function() { | |
var me = this; | |
if (!this.discount_amount_applied) { | |
$.each(this.frm.item_doclist, function(i, item) { | |
frappe.model.round_floats_in(item); | |
item.rate = flt(item.amount / item.qty, precision("rate", item)); | |
me._set_in_company_currency(item, "price_list_rate", "base_price_list_rate"); | |
me._set_in_company_currency(item, "rate", "base_rate"); |
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
// Replace with new calculation of item value | |
cur_frm.cscript.calculate_item_values = function() { | |
var me = this; | |
if (!this.discount_amount_applied) { | |
$.each(this.frm.item_doclist, function(i, item) { | |
frappe.model.round_floats_in(item); | |
if (!cur_frm.fixed_amt) { | |
item.amount = flt(item.rate * item.qty, precision("amount", item)); | |
} |
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
def update_user_permissions(self): | |
for l in self.get("employee_leave_approvers")[:]: | |
frappe.permissions.add_user_permission("User", l.leave_approver, self.user_id) | |
frappe.permissions.add_user_permission("Employee", self.name, self.user_id) | |
frappe.permissions.set_user_permission_if_allowed("Company", self.company, self.user_id) |
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
import frappe | |
import frappe.defaults | |
import unittest | |
import bioplastics_api as api | |
from frappe.auth import LoginManager, HTTPRequest, CookieManager | |
# load test records and dependencies | |
test_records = frappe.get_test_records('po') | |
class MockRequest(): | |
def __init__(self): |
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
from frappe.widgets.form.utils import get_linked_docs | |
@frappe.whitelist(allow_guest=False) | |
def received_po_item(): | |
po_name = frappe.local.form_dict.get('po_name') | |
pr_name = frappe.local.form_dict.get('pr_name') | |
item_code = frappe.local.form_dict.get('item_code') | |
qty = float(frappe.local.form_dict.get('qty', 0)) | |
if po_name: | |
try: |
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
set_notified = function(doc, dt, dn) { | |
frappe.call({ | |
method:"frappe.client.set_value", | |
args: { | |
doctype: dt, | |
name: dn, | |
fieldname: 'notified_by_email', | |
value: 1 | |
}, | |
callback: function() { |
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
cur_frm.cscript.employee = function(doc,dt,dn){ | |
return $c_obj(doc, 'get_emp_and_leave_details','',function(r, rt) { | |
console.log("default====="); | |
var doc = locals[dt][dn]; | |
cur_frm.refresh(); // Once this called, the changes made using customize script are reverted | |
calculate_all(doc, dt, dn); | |
}); | |
} |
NewerOlder