├── deltapumps ├── patches.txt ├── config │ ├── __init__.py │ ├── desktop.py │ └── docs.py ├── deltapumps │ └── __init__.py ├── modules.txt ├── templates │ ├── __init__.py │ └── pages │ │ └── __init__.py ├── __init__.py ├── custompy │ ├── history_card.py │ └── data_sheet.py └── hooks.py ├── license.txt ├── .gitignore ├── README.md ├── requirements.txt ├── setup.py └── MANIFEST.in /deltapumps/patches.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | License: MIT -------------------------------------------------------------------------------- /deltapumps/config/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deltapumps/deltapumps/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deltapumps/modules.txt: -------------------------------------------------------------------------------- 1 | Deltapumps -------------------------------------------------------------------------------- /deltapumps/templates/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deltapumps/templates/pages/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deltapumps/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | __version__ = '0.0.1' 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.egg-info 4 | *.swp 5 | tags 6 | deltapumps/docs/current -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Deltapumps 2 | 3 | Custom App for Delta Pumps 4 | 5 | #### License 6 | 7 | MIT -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # frappe -- https://github.com/frappe/frappe is installed via 'bench init' -------------------------------------------------------------------------------- /deltapumps/config/desktop.py: -------------------------------------------------------------------------------- 1 | from frappe import _ 2 | 3 | def get_data(): 4 | return [ 5 | { 6 | "module_name": "Deltapumps", 7 | "color": "grey", 8 | "icon": "octicon octicon-file-directory", 9 | "type": "module", 10 | "label": _("Deltapumps") 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /deltapumps/config/docs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Configuration for docs 3 | """ 4 | 5 | # source_link = "https://github.com/[org_name]/deltapumps" 6 | # docs_base_url = "https://[org_name].github.io/deltapumps" 7 | # headline = "App that does everything" 8 | # sub_heading = "Yes, you got that right the first time, everything" 9 | 10 | def get_context(context): 11 | context.brand_html = "Deltapumps" 12 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | with open("requirements.txt") as f: 4 | install_requires = f.read().strip().split("\n") 5 | 6 | # get version from __version__ variable in deltapumps/__init__.py 7 | from deltapumps import __version__ as version 8 | 9 | setup( 10 | name="deltapumps", 11 | version=version, 12 | description="Custom App for Delta Pumps", 13 | author="Delta Pumps", 14 | author_email="hello@aerele.in", 15 | packages=find_packages(), 16 | zip_safe=False, 17 | include_package_data=True, 18 | install_requires=install_requires 19 | ) 20 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include requirements.txt 3 | include *.json 4 | include *.md 5 | include *.py 6 | include *.txt 7 | recursive-include deltapumps *.css 8 | recursive-include deltapumps *.csv 9 | recursive-include deltapumps *.html 10 | recursive-include deltapumps *.ico 11 | recursive-include deltapumps *.js 12 | recursive-include deltapumps *.json 13 | recursive-include deltapumps *.md 14 | recursive-include deltapumps *.png 15 | recursive-include deltapumps *.py 16 | recursive-include deltapumps *.svg 17 | recursive-include deltapumps *.txt 18 | recursive-exclude deltapumps *.pyc -------------------------------------------------------------------------------- /deltapumps/custompy/history_card.py: -------------------------------------------------------------------------------- 1 | import frappe 2 | 3 | 4 | 5 | @frappe.whitelist() 6 | def make_history_card(name): 7 | salesorder=frappe.get_doc("Sales Order",name) 8 | # new_hiscard = frappe.db.get_value("History Card", {"sales_order": name}) or None 9 | # if new_hiscard: 10 | # return frappe.get_doc("History Card", new_hiscard) 11 | new_hiscard = frappe.new_doc("History Card") 12 | new_hiscard.transaction_date=salesorder.transaction_date 13 | new_hiscard.sales_order=salesorder.name 14 | new_hiscard = before_save(new_hiscard, "Creating History Card") 15 | #new_hiscard.save() 16 | return new_hiscard 17 | 18 | @frappe.whitelist() 19 | def get_atribute(name): 20 | itemcd=frappe.get_doc("Item",name) 21 | atrib=[] 22 | for i in itemcd.attributes: 23 | atrib.append(i.attribute) 24 | return atrib 25 | 26 | @frappe.whitelist() 27 | def get_parameter(parameter): 28 | if not frappe.db.get_value("Technical Parameter Entry", parameter): 29 | return [] 30 | parameter_entry = frappe.get_doc("Technical Parameter Entry", parameter) 31 | return [i.technical_parameter_name for i in parameter_entry.technical_parameter_table] 32 | 33 | def get_selected_attribs(attributes, seperator): 34 | return [i for i in attributes.split(seperator)] 35 | 36 | def before_save(self, method): 37 | try: 38 | if len(self.items) == 0: 39 | salesorder=frappe.get_doc("Sales Order",self.sales_order) 40 | for i in salesorder.items: 41 | pb = frappe.db.get_value("Product Bundle", {"new_item_code":i.item_code}) 42 | if pb: 43 | for j in salesorder.packed_items: 44 | if i.name == j.parent_detail_docname: 45 | self.append("items", 46 | { 47 | "item_code":j.item_code, 48 | "item_name":j.item_name, 49 | "description":j.description, 50 | "qty":j.qty, 51 | "rate":j.rate, 52 | "amount":j.rate * j.qty, 53 | "uom":j.uom, 54 | "technical_parameter_entry":j.technical_parameter_entry, 55 | "product_bundle":pb, 56 | "parent_item":i.item_code 57 | } 58 | ) 59 | continue 60 | self.append("items", 61 | { 62 | "item_code":i.item_code, 63 | "delivery_date":i.delivery_date, 64 | "item_name":i.item_name, 65 | "qty":i.qty, 66 | "rate":i.rate, 67 | "amount":i.amount, 68 | "uom":i.uom, 69 | "description":i.description, 70 | "technical_parameter_entry":i.technical_parameter_entry 71 | }) 72 | if len(self.exploded_items) == 0: 73 | for j in self.items: 74 | if j.item_code: 75 | bom = frappe.db.get_value("BOM",{"item":j.item_code, "docstatus":1, "is_default":1},"name") 76 | if bom: 77 | materials=frappe.get_doc("BOM",bom) 78 | add_exploded_bom_item(self, materials) 79 | if method == "Creating History Card": 80 | return self 81 | except Exception as e: 82 | frappe.log_error(e) 83 | 84 | def add_exploded_bom_item(self,materials): 85 | for i in materials.items: 86 | if i.item_code: 87 | has_bom = frappe.db.get_value("BOM",{"item":i.item_code, "docstatus":1, "is_default":1},"name") 88 | self.append("exploded_items", 89 | { 90 | "item_code":i.item_code, 91 | "item_name":i.item_name, 92 | "description":i.description, 93 | "qty":i.qty, 94 | "rate":i.rate, 95 | "amount":i.amount, 96 | "uom":i.uom, 97 | "parent_item":materials.item 98 | } 99 | ) 100 | if has_bom and has_bom != materials.name and not i.do_not_explode: 101 | bom_doc=frappe.get_doc("BOM",has_bom) 102 | add_exploded_bom_item(self, bom_doc) -------------------------------------------------------------------------------- /deltapumps/custompy/data_sheet.py: -------------------------------------------------------------------------------- 1 | import frappe 2 | 3 | 4 | @frappe.whitelist() 5 | def make_data_sheet(name): 6 | quotation = frappe.get_doc("Quotation", name) 7 | new_datasheet = frappe.db.get_value("Data Sheet", {"quotation": name}) or None 8 | if new_datasheet: 9 | return frappe.get_doc("Data Sheet", new_datasheet) 10 | new_datasheet = frappe.new_doc("Data Sheet") 11 | new_datasheet.transaction_date=quotation.transaction_date 12 | new_datasheet.quotation=quotation.name 13 | new_datasheet.save() 14 | return new_datasheet 15 | 16 | def before_save(self, method): 17 | if len(self.data_sheet_item) == 0: 18 | quotation = frappe.get_doc("Quotation", self.quotation) 19 | for i in quotation.items: 20 | pb = frappe.db.get_value("Product Bundle", {"new_item_code":i.item_code}) 21 | if pb: 22 | for j in quotation.packed_items: 23 | if i.name == j.parent_detail_docname: 24 | self.append("data_sheet_item", 25 | { 26 | "item":j.item_code, 27 | "item_name":j.item_name, 28 | "description":j.description, 29 | "qty":j.qty , 30 | "rate":j.rate, 31 | "amount":j.rate * j.qty , 32 | "uom":j.uom, 33 | "technical_parameter_entry":j.technical_parameter_entry, 34 | "product_bundle":pb, 35 | "parent_item":i.item_code 36 | } 37 | ) 38 | continue 39 | self.append("data_sheet_item", 40 | { 41 | "item":i.item_code, 42 | "item_name":i.item_name, 43 | "qty":i.qty, 44 | "rate":i.rate, 45 | "amount":i.amount, 46 | "uom":i.uom, 47 | "description":i.customer_description, 48 | "technical_parameter_entry":i.technical_parameter_entry 49 | }) 50 | self.item_details = [] 51 | for i in self.data_sheet_item: 52 | item = frappe.get_doc("Item", i.item) 53 | for j in frappe.db.get_all("Item Variant Attribute", {"parent": i.item}, "*", order_by="idx"): #item.attributes: 54 | self.append("item_details", { 55 | "item": item.name, 56 | "attribute_category": frappe.db.get_value("Item Attribute", j.attribute, 'attribute_category'), 57 | "doc_type": "Item Attribute", 58 | "parameter": j.attribute, 59 | "parameter_value": j.attribute_value, 60 | "technical_parameter_entry": i.technical_parameter_entry 61 | }) 62 | 63 | if not i.technical_parameter_entry: 64 | continue 65 | parameter_entry =frappe.get_doc("Technical Parameter Entry", i.technical_parameter_entry) 66 | template = frappe.get_doc("Technical Parameters Template", parameter_entry.technical_parameters_template) 67 | for j in frappe.db.get_all("Technical Parameters Table", {"parent":i.technical_parameter_entry}, "*", order_by="idx"): #template.technical_parameters_template: 68 | self.append("item_details", { 69 | "item": item.name, 70 | "attribute_category": frappe.db.get_value("Technical Parameters", j.technical_parameter_name, 'attribute_category'), 71 | "doc_type": "Technical Parameters", 72 | "parameter": j.technical_parameter_name, 73 | "parameter_value": frappe.db.get_value("Technical Parameters Table", {"parent":parameter_entry.name, "technical_parameter_name":j.technical_parameter_name}, "parameter_value_as_per_uom") or frappe.db.get_value("Technical Parameters Table", {"parent":parameter_entry.name, "technical_parameter_name":j.technical_parameter_name}, "parameter_value"), 74 | "parameter_uom": frappe.db.get_value("Technical Parameters Table", {"parent":parameter_entry.name, "technical_parameter_name":j.technical_parameter_name}, "uom") or frappe.db.get_value("Technical Parameters Table", {"parent":parameter_entry.name, "technical_parameter_name":j.technical_parameter_name}, "uom"), 75 | "remarks": j.remark__notes, 76 | "technical_parameter_entry": i.technical_parameter_entry 77 | }) 78 | 79 | 80 | def get_templates(doc): 81 | data = frappe._dict({}) 82 | for i in doc.data_sheet_item: 83 | data[i.item+(i.technical_parameter_entry or '')] = {} 84 | for j in doc.item_details: 85 | if i.item == j.item: 86 | if j.technical_parameter_entry: 87 | if i.technical_parameter_entry != j.technical_parameter_entry: 88 | continue 89 | if j.attribute_category == "": 90 | j.attribute_category = None 91 | 92 | value = [j.parameter, j.parameter_value, j.parameter_uom or '', j.remarks or ''] 93 | if j.attribute_category in data[i.item+(i.technical_parameter_entry or '')]: 94 | if value not in data[i.item+(i.technical_parameter_entry or '')][j.attribute_category]: 95 | data[i.item+(i.technical_parameter_entry or '')][j.attribute_category].append(value) 96 | else: 97 | data[i.item+(i.technical_parameter_entry or '')][j.attribute_category] = [value] 98 | return data 99 | -------------------------------------------------------------------------------- /deltapumps/hooks.py: -------------------------------------------------------------------------------- 1 | from . import __version__ as app_version 2 | 3 | app_name = "deltapumps" 4 | app_title = "Deltapumps" 5 | app_publisher = "Delta Pumps" 6 | app_description = "Custom App for Delta Pumps" 7 | app_icon = "octicon octicon-file-directory" 8 | app_color = "grey" 9 | app_email = "hello@aerele.in" 10 | app_license = "MIT" 11 | 12 | # Includes in 13 | # ------------------ 14 | 15 | # include js, css files in header of desk.html 16 | # app_include_css = "/assets/deltapumps/css/deltapumps.css" 17 | # app_include_js = "/assets/deltapumps/js/deltapumps.js" 18 | 19 | # include js, css files in header of web template 20 | # web_include_css = "/assets/deltapumps/css/deltapumps.css" 21 | # web_include_js = "/assets/deltapumps/js/deltapumps.js" 22 | 23 | # include custom scss in every website theme (without file extension ".scss") 24 | # website_theme_scss = "deltapumps/public/scss/website" 25 | 26 | # include js, css files in header of web form 27 | # webform_include_js = {"doctype": "public/js/doctype.js"} 28 | # webform_include_css = {"doctype": "public/css/doctype.css"} 29 | 30 | # include js in page 31 | # page_js = {"page" : "public/js/file.js"} 32 | 33 | # include js in doctype views 34 | # doctype_js = {"doctype" : "public/js/doctype.js"} 35 | # doctype_list_js = {"doctype" : "public/js/doctype_list.js"} 36 | # doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} 37 | # doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"} 38 | 39 | # Home Pages 40 | # ---------- 41 | 42 | # application home page (will override Website Settings) 43 | # home_page = "login" 44 | 45 | # website user home page (by Role) 46 | # role_home_page = { 47 | # "Role": "home_page" 48 | # } 49 | 50 | # Generators 51 | # ---------- 52 | 53 | # automatically create page for each record of this doctype 54 | # website_generators = ["Web Page"] 55 | 56 | # Installation 57 | # ------------ 58 | 59 | # before_install = "deltapumps.install.before_install" 60 | # after_install = "deltapumps.install.after_install" 61 | 62 | # Desk Notifications 63 | # ------------------ 64 | # See frappe.core.notifications.get_notification_config 65 | 66 | # notification_config = "deltapumps.notifications.get_notification_config" 67 | 68 | # Permissions 69 | # ----------- 70 | # Permissions evaluated in scripted ways 71 | 72 | # permission_query_conditions = { 73 | # "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", 74 | # } 75 | # 76 | # has_permission = { 77 | # "Event": "frappe.desk.doctype.event.event.has_permission", 78 | # } 79 | 80 | # DocType Class 81 | # --------------- 82 | # Override standard doctype classes 83 | 84 | # override_doctype_class = { 85 | # "ToDo": "custom_app.overrides.CustomToDo" 86 | # } 87 | 88 | # Document Events 89 | # --------------- 90 | # Hook on document methods and events 91 | 92 | doc_events = { 93 | "History Card":{ 94 | "before_save":[ 95 | "deltapumps.custompy.history_card.before_save" 96 | ] 97 | }, 98 | "Data Sheet":{ 99 | "before_save":[ 100 | "deltapumps.custompy.data_sheet.before_save" 101 | ] 102 | } 103 | # "*": { 104 | # "on_update": "method", 105 | # "on_cancel": "method", 106 | # "on_trash": "method" 107 | # } 108 | } 109 | 110 | # Scheduled Tasks 111 | # --------------- 112 | 113 | # scheduler_events = { 114 | # "all": [ 115 | # "deltapumps.tasks.all" 116 | # ], 117 | # "daily": [ 118 | # "deltapumps.tasks.daily" 119 | # ], 120 | # "hourly": [ 121 | # "deltapumps.tasks.hourly" 122 | # ], 123 | # "weekly": [ 124 | # "deltapumps.tasks.weekly" 125 | # ] 126 | # "monthly": [ 127 | # "deltapumps.tasks.monthly" 128 | # ] 129 | # } 130 | 131 | # Testing 132 | # ------- 133 | 134 | # before_tests = "deltapumps.install.before_tests" 135 | 136 | # Overriding Methods 137 | # ------------------------------ 138 | # 139 | # override_whitelisted_methods = { 140 | # "frappe.desk.doctype.event.event.get_events": "deltapumps.event.get_events" 141 | # } 142 | # 143 | # each overriding function accepts a `data` argument; 144 | # generated from the base implementation of the doctype dashboard, 145 | # along with any modifications made in other Frappe apps 146 | # override_doctype_dashboards = { 147 | # "Task": "deltapumps.task.get_dashboard_data" 148 | # } 149 | 150 | # exempt linked doctypes from being automatically cancelled 151 | # 152 | # auto_cancel_exempted_doctypes = ["Auto Repeat"] 153 | 154 | 155 | # User Data Protection 156 | # -------------------- 157 | 158 | user_data_fields = [ 159 | { 160 | "doctype": "{doctype_1}", 161 | "filter_by": "{filter_by}", 162 | "redact_fields": ["{field_1}", "{field_2}"], 163 | "partial": 1, 164 | }, 165 | { 166 | "doctype": "{doctype_2}", 167 | "filter_by": "{filter_by}", 168 | "partial": 1, 169 | }, 170 | { 171 | "doctype": "{doctype_3}", 172 | "strict": False, 173 | }, 174 | { 175 | "doctype": "{doctype_4}" 176 | } 177 | ] 178 | 179 | # Authentication and authorization 180 | # -------------------------------- 181 | 182 | # auth_hooks = [ 183 | # "deltapumps.auth.validate" 184 | # ] 185 | 186 | jinja = { 187 | "methods":[ 188 | "deltapumps.custompy.history_card.get_selected_attribs", 189 | "deltapumps.custompy.data_sheet.get_templates" 190 | ] 191 | } 192 | --------------------------------------------------------------------------------