This file contains hidden or 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
| # git clone <frappe_docker.git> | |
| pyenv install 3.10.2 | |
| pyenv global 3.10.2 | |
| rm -rf /frappe/.local/bin/* | |
| nvm install v16 | |
| pip install frappe-bench |
This file contains hidden or 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
| # under hooks.py | |
| # ... | |
| fixtures = [ | |
| { | |
| "doctype": "Custom Field", | |
| "filters": [ | |
| [ | |
| "name", | |
| "in", | |
| ["Sales Invoice-custom_discount_percentage"], |
This file contains hidden or 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
| frappe.ui.form.on("Sales Invoice", { | |
| custom_discount_percentage: function (frm) { | |
| frm.doc.items.forEach((item) => { | |
| frappe.model.set_value( | |
| item.doctype, | |
| item.name, | |
| 'discount_percentage', | |
| frm.doc.custom_discount_percentage, | |
| ); | |
| }); |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| from __future__ import print_function | |
| import os | |
| import sys | |
| import subprocess | |
| import getpass | |
| import json | |
| import multiprocessing |
This file contains hidden or 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
| # Commonly used in porting custom fields to another app | |
| # bench execute <path>.concat_json_files --kwargs '{"in_file": "c1.json", "in2_file": "c2.json"}' | |
| def concat_json_files(in_file, in2_file, out_file='output.json'): | |
| if not in_file: | |
| raise Exception("First file is needed!") | |
| if not in2_file: | |
| raise Exception("Second file is needed!") | |
| # Input file | |
| with open(in_file, "r") as file: |
This file contains hidden or 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 json | |
| # Commonly used in porting custom fields to another app | |
| # bench execute <path>.extract_from_json_file --kwargs '{"filters": {"dt": "Branch"}}' | |
| def extract_from_json_file(filters, in_file='input.json', out_file='output.json'): | |
| if not filters: | |
| raise Exception("Filters needed!") | |
| # Input file |
This file contains hidden or 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
| const x = 8; | |
| const y = 8; | |
| let arr = []; | |
| for (let i = 0; i < x; i++) { | |
| arr[i] = []; | |
| let even = ' '; | |
| let odd = '#'; | |
| if (i % 2 === 0) { |
This file contains hidden or 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 boto3 | |
| region = 'us-east-1' | |
| instances = ['<instance>'] | |
| def start_instances(event, context): | |
| ec2 = boto3.client('ec2', region_name=region) | |
| ec2.start_instances(InstanceIds=instances) | |
| print('Started Instances: ' + str(instances)) |
This file contains hidden or 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 json | |
| # Item | |
| item = { | |
| 'item_group': input['item_group'], | |
| 'stock_uom': input['uom'], | |
| 'item_code': input['item_code'] | |
| } | |
| # Authorization header |
This file contains hidden or 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
| Demo |
NewerOlder