def setup_custom_fields(): custom_fields = { "Item": [ dict(fieldname='booking_item', label='Booking Item', fieldtype='Check', insert_after='disabled', print_hide=1), dict(fieldname='service_item', label='Service Item', fieldtype='Link', insert_after='booking_item', options='Item', depends_on='eval:doc.booking_item', read_only=0, print_hide=1) ], "Sales Order": [ dict(fieldname='book_service', label='Book Service', fieldtype='Link', insert_after='customer_name', read_only=0, options='Book Service'), ] } create_custom_fields(custom_fields)
def execute(): frappe.reload_doc("accounts", "doctype", "tax_category") frappe.reload_doc("stock", "doctype", "item_manufacturer") company = frappe.get_all('Company', filters={'country': 'India'}) if not company: return bank_remittance_fields = { 'Bank Account': [{ 'fieldname': 'bank_remittance_section', 'label': 'Bank Remittance Settings', 'fieldtype': 'Section Break', 'collapsible': 1, 'insert_after': 'mask' }, { 'fieldname': 'client_code', 'label': 'Client Code', 'fieldtype': 'Data', 'insert_after': 'bank_remittance_section' }, { 'fieldname': 'remittance_column_break', 'fieldtype': 'Column Break', 'insert_after': 'client_code' }, { 'fieldname': 'product_code', 'label': 'Product Code', 'fieldtype': 'Data', 'insert_after': 'remittance_column_break' }] } create_custom_fields(bank_remittance_fields, update=True)
def execute(): custom_field = { 'Sales Invoice Item': [ dict( fieldname='hms_tz_is_lrp_item_created', label='Is LRP Item Created', fieldtype='Check', insert_after='reference_dn', depends_on= 'eval: doc.reference_dt=="Lab Prescription" || doc.reference_dt=="Radiology Procedure Prescription" || doc.reference_dt=="Procedure Prescription" ', allow_on_submit=1, read_only=1, bold=1, ) ] } create_custom_fields(custom_field, update=True) # Update/tick a check box for a new custom field 'hms_tz_is_lrpt_item_created' to all previous transactions today_date = frappe.utils.nowdate() frappe.db.sql( """ UPDATE `tabSales Invoice Item` sii INNER JOIN `tabSales Invoice` si ON sii.parent = si.name SET sii.hms_tz_is_lrp_item_created = 1 WHERE si.patient is not null AND si.docstatus = 1 AND si.posting_date <= %s AND sii.reference_dt IN ("Lab Prescription", "Radiology Procedure Prescription", "Procedure Prescription") """, today_date)
def setup_custom_fields(): custom_fields = { "Item": [ dict( fieldname="amazon_item_code", label="Amazon Item Code", fieldtype="Data", insert_after="series", read_only=1, print_hide=1, ) ], "Sales Order": [ dict( fieldname="amazon_order_id", label="Amazon Order ID", fieldtype="Data", insert_after="title", read_only=1, print_hide=1, ) ], } create_custom_fields(custom_fields)
def make_custom_fields(update=True): custom_fields = { 'Supplier': [ dict(fieldname='irs_1099', fieldtype='Check', insert_after='tax_id', label='Is IRS 1099 reporting required for supplier?') ], 'Sales Order': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_and_charges', label='Is customer exempted from sales tax?') ], 'Sales Invoice': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_section', label='Is customer exempted from sales tax?') ], 'Customer': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='represents_company', label='Is customer exempted from sales tax?') ], 'Quotation': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_and_charges', label='Is customer exempted from sales tax?') ] } create_custom_fields(custom_fields, update=update)
def setup_custom_fields(): custom_fields = { "Project": [ dict(fieldname='realestate_project_details', label='RealEstate Project Details ', fieldtype='Section Break', insert_after='sales_order'), dict( fieldname='realestate_project', label='RealEstate Project', fieldtype='Link', options='RealEstate Project', insert_after='realestate_project_details', ), ], "Purchase Invoice": [ dict(fieldname='project_reference', label='Project Reference', fieldtype='Link', options='Project', insert_after='supplier_name'), ], "Journal Entry": [ dict(fieldname='realestate_payment_entry', label='RealEstate Payment Entry', fieldtype='Link', options='RealEstate Payment Entry', insert_after='reference'), ] } create_custom_fields(custom_fields) frappe.msgprint("Custome Field update done.")
def make_custom_field(): custom_fields = { 'Sales Invoice': [ dict(fieldname='ewaybill_barcode', label='E- Way Bill', fieldtype='Code', allow_on_submit=1, read_only=1, hidden=1, no_copy=1), dict(fieldname='ewaybill_date', label='E- Way Bill Date', fieldtype='Datetime', insert_after='ewaybill', read_only=1, allow_on_submit=1, no_copy=1), dict(fieldname='ewaybill_validity', label='E- Way Bill Validity', fieldtype='Datetime', insert_after='ewaybill_date', read_only=1, allow_on_submit=1, no_copy=1) ] } create_custom_fields(custom_fields, update=True)
def execute(): company = frappe.get_all("Company", filters={"country": "Saudi Arabia"}) if not company: return if frappe.db.exists("DocType", "Sales Invoice"): frappe.reload_doc("accounts", "doctype", "sales_invoice", force=True) # rename_field method assumes that the field already exists or the doc is synced if not frappe.db.has_column("Sales Invoice", "ksa_einv_qr"): create_custom_fields({ "Sales Invoice": [ dict( fieldname="ksa_einv_qr", label="KSA E-Invoicing QR", fieldtype="Attach Image", read_only=1, no_copy=1, hidden=1, ) ] }) if frappe.db.has_column("Sales Invoice", "qr_code"): rename_field("Sales Invoice", "qr_code", "ksa_einv_qr") frappe.delete_doc_if_exists("Custom Field", "Sales Invoice-qr_code")
def execute(): # restores back the 2 custom fields that was deleted while removing e-invoicing from v14 company = frappe.get_all("Company", filters={"country": "India"}) if not company: return custom_fields = { "Sales Invoice": [ dict( fieldname="irn_cancelled", label="IRN Cancelled", fieldtype="Check", no_copy=1, print_hide=1, depends_on="eval:(doc.irn_cancelled === 1)", read_only=1, allow_on_submit=1, insert_after="customer", ), dict( fieldname="eway_bill_cancelled", label="E-Way Bill Cancelled", fieldtype="Check", no_copy=1, print_hide=1, depends_on="eval:(doc.eway_bill_cancelled === 1)", read_only=1, allow_on_submit=1, insert_after="customer", ), ] } create_custom_fields(custom_fields, update=True) add_permissions() add_print_formats()
def add_gst_hsn_code_field(): custom_fields = { "Stock Entry Detail": [ dict( fieldname="gst_hsn_code", label="HSN/SAC", fieldtype="Data", fetch_from="item_code.gst_hsn_code", insert_after="description", allow_on_submit=1, print_hide=0, ) ] } create_custom_fields(custom_fields, ignore_validate=frappe.flags.in_patch, update=True) frappe.db.sql(""" update `tabStock Entry Detail`, `tabItem` SET `tabStock Entry Detail`.gst_hsn_code = `tabItem`.gst_hsn_code Where `tabItem`.name = `tabStock Entry Detail`.item_code and `tabItem`.gst_hsn_code is not null """)
def setup_custom_fields(): custom_fields = { "Customer": [dict(fieldname='shopify_customer_id', label='Shopify Customer Id', fieldtype='Data', insert_after='series', read_only=1, print_hide=1)], "Address": [dict(fieldname='shopify_address_id', label='Shopify Address Id', fieldtype='Data', insert_after='fax', read_only=1, print_hide=1)], "Item": [ dict(fieldname='shopify_variant_id', label='Shopify Variant Id', fieldtype='Data', insert_after='item_code', read_only=1, print_hide=1), dict(fieldname='shopify_product_id', label='Shopify Product Id', fieldtype='Data', insert_after='item_code', read_only=1, print_hide=1), dict(fieldname='shopify_description', label='Shopify Description', fieldtype='Text Editor', insert_after='description', read_only=1, print_hide=1) ], "Sales Order": [dict(fieldname='shopify_order_id', label='Shopify Order Id', fieldtype='Data', insert_after='title', read_only=1, print_hide=1)], "Delivery Note":[ dict(fieldname='shopify_order_id', label='Shopify Order Id', fieldtype='Data', insert_after='title', read_only=1, print_hide=1), dict(fieldname='shopify_fulfillment_id', label='Shopify Fulfillment Id', fieldtype='Data', insert_after='title', read_only=1, print_hide=1) ], "Sales Invoice": [dict(fieldname='shopify_order_id', label='Shopify Order Id', fieldtype='Data', insert_after='title', read_only=1, print_hide=1)] } create_custom_fields(custom_fields)
def make_custom_fields(): """Create Custom fields - QR code Image file - Company Name in Arabic - Address in Arabic """ custom_fields = { 'Sales Invoice': [ dict(fieldname='qr_code', label='QR Code', fieldtype='Attach Image', read_only=1, no_copy=1, hidden=1) ], 'Address': [ dict(fieldname='address_in_arabic', label='Address in Arabic', fieldtype='Data', insert_after='address_line2') ], 'Company': [ dict(fieldname='company_name_in_arabic', label='Company Name In Arabic', fieldtype='Data', insert_after='company_name') ] } create_custom_fields(custom_fields, update=True)
def execute(): company = frappe.get_all('Company', filters={'country': 'United States'}, fields=['name']) if not company: return TAXJAR_CREATE_TRANSACTIONS = frappe.db.get_single_value( "TaxJar Settings", "taxjar_create_transactions") TAXJAR_CALCULATE_TAX = frappe.db.get_single_value("TaxJar Settings", "taxjar_calculate_tax") TAXJAR_SANDBOX_MODE = frappe.db.get_single_value("TaxJar Settings", "is_sandbox") if (not TAXJAR_CREATE_TRANSACTIONS and not TAXJAR_CALCULATE_TAX and not TAXJAR_SANDBOX_MODE): return custom_fields = { 'Sales Invoice Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', label='Product Tax Category', fetch_from='item_code.product_tax_category'), dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', label='Tax Collectable', read_only=1, options='currency'), dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', label='Taxable Amount', read_only=1, options='currency') ], 'Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category', label='Product Tax Category') ], 'TaxJar Settings': [ dict(fieldname='company', fieldtype='Link', insert_after='configuration', options='Company', label='Company') ] } create_custom_fields(custom_fields, update=True) add_permissions() frappe.enqueue( 'erpnext.erpnext_integrations.doctype.taxjar_settings.taxjar_settings.add_product_tax_categories', now=True)
def make_custom_fields(update=True): custom_fields = { 'Supplier': [ dict(fieldname='irs_1099', fieldtype='Check', insert_after='tax_id', label='Is IRS 1099 reporting required for supplier?') ] } create_custom_fields(custom_fields, update=update)
def setup_custom_fields(): custom_fields = { "Item": [dict(fieldname='amazon_item_code', label='Amazon Item Code', fieldtype='Data', insert_after='series', read_only=1, print_hide=1)], "Sales Order": [dict(fieldname='amazon_order_id', label='Amazon Order ID', fieldtype='Data', insert_after='title', read_only=1, print_hide=1)] } create_custom_fields(custom_fields)
def make_custom_fields(): custom_fields = { 'Company': [ dict(fieldname='siren_number', label='SIREN Number', fieldtype='Data', insert_after='website') ] } create_custom_fields(custom_fields)
def setup_custom_fields(): custom_fields = { "Item": [dict(fieldname='amazon_item_code', label='Amazon Item Code', fieldtype='Data', insert_after='series', read_only=1, print_hide=1)], "Sales Order": [dict(fieldname='amazon_order_id', label='Amazon Order ID', fieldtype='Data', insert_after='title', read_only=1, print_hide=1)] } create_custom_fields(custom_fields)
def healthcare_custom_field_in_sales_invoice(): frappe.reload_doc('healthcare', 'doctype', 'patient') frappe.reload_doc('healthcare', 'doctype', 'healthcare_practitioner') if data['custom_fields']: create_custom_fields(data['custom_fields']) frappe.db.sql(""" delete from `tabCustom Field` where fieldname = 'appointment' and options = 'Patient Appointment' """)
def setup_custom_field_for_domain(): field = { "Item": [ dict(fieldname='domain', label='Domain', fieldtype='Select', hidden=1, default="Manufacturing", options="Manufacturing\nService\nDistribution\nRetail" ) ] } create_custom_fields(field)
def healthcare_custom_field_in_sales_invoice(): frappe.reload_doc('healthcare', 'doctype', 'patient') frappe.reload_doc('healthcare', 'doctype', 'healthcare_practitioner') if data['custom_fields']: create_custom_fields(data['custom_fields']) frappe.db.sql(""" delete from `tabCustom Field` where fieldname = 'appointment' and options = 'Patient Appointment' """)
def healthcare_custom_field_in_sales_invoice(): frappe.reload_doc("healthcare", "doctype", "patient") frappe.reload_doc("healthcare", "doctype", "healthcare_practitioner") if data["custom_fields"]: create_custom_fields(data["custom_fields"]) frappe.db.sql(""" delete from `tabCustom Field` where fieldname = 'appointment' and options = 'Patient Appointment' """)
def setup_custom_field_for_domain(): field = { "Item": [ dict(fieldname='domain', label='Domain', fieldtype='Select', hidden=1, default="Manufacturing", options="Manufacturing\nService\nDistribution\nRetail" ) ] } create_custom_fields(field)
def make_custom_fields(): custom_fields = { "Company": [ dict(fieldname="siren_number", label="SIREN Number", fieldtype="Data", insert_after="website") ] } create_custom_fields(custom_fields)
def make_custom_fields(): custom_fields = { 'Company': [ dict(fieldname='siren_number', label='SIREN Number', fieldtype='Data', insert_after='website') ] } create_custom_fields(custom_fields)
def make_custom_fields(): custom_fields = { 'Party Account': [ dict(fieldname='debtor_creditor_number', label='Debtor/Creditor Number', fieldtype='Data', insert_after='account', translatable=0) ] } create_custom_fields(custom_fields)
def make_custom_fields(): custom_fields = { 'Sales Invoice': [ dict(fieldname='appointment', label='Patient Appointment', fieldtype='Link', options='Patient Appointment', insert_after='customer') ] } create_custom_fields(custom_fields)
def make_custom_fields(): custom_fields = { 'Supplier': [ dict(fieldname='irs_1099', fieldtype='Check', insert_after='tax_id', label='Is IRS 1099 reporting required for supplier?') ], 'Sales Order': [ dict(fieldname='affirm_id', fieldtype="Data", insert_after='po_date', label="Affirm ID", read_only=1, allow_on_submit=1), dict(fieldname='affirm_status', fieldtype="Data", insert_after='affirm_id', label="Affirm Capture Status", read_only=1, allow_on_submit=1), dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_and_charges', label='Is customer exempted from sales tax?') ], 'Sales Invoice': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_section', label='Is customer exempted from sales tax?') ], 'Customer': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='represents_company', label='Is customer exempted from sales tax?') ], 'Quotation': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_and_charges', label='Is customer exempted from sales tax?') ], 'Lead': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='email_id', label='Is Lead exempted from sales tax?') ] } create_custom_fields(custom_fields)
def execute(): company = frappe.get_all("Company", filters={"country": "India"}, fields=["name"]) if not company: return sales_invoice_gst_fields = [ dict( fieldname="billing_address_gstin", label="Billing Address GSTIN", fieldtype="Data", insert_after="customer_address", read_only=1, fetch_from="customer_address.gstin", print_hide=1, length=15, ), dict( fieldname="customer_gstin", label="Customer GSTIN", fieldtype="Data", insert_after="shipping_address_name", fetch_from="shipping_address_name.gstin", print_hide=1, length=15, ), dict( fieldname="place_of_supply", label="Place of Supply", fieldtype="Data", insert_after="customer_gstin", print_hide=1, read_only=1, length=50, ), dict( fieldname="company_gstin", label="Company GSTIN", fieldtype="Data", insert_after="company_address", fetch_from="company_address.gstin", print_hide=1, read_only=1, length=15, ), ] custom_fields = {"Quotation": sales_invoice_gst_fields} create_custom_fields(custom_fields, update=True)
def create_defaults(): #Create default roles roles = ['Bank Maker', 'Bank Checker'] for role in roles: if not frappe.db.exists('Role', role): role_doc = frappe.new_doc("Role") role_doc.role_name = role role_doc.save() #Create custom field custom_fields = { 'Bank Account': [ { "fieldname": "ifsc_code", "fieldtype": "Data", "label": "IFSC Code", "insert_after": "iban" }, ] } create_custom_fields(custom_fields, ignore_validate=frappe.flags.in_patch, update=True) #Create workflow state states_with_style = { 'Success': ['Verified', 'Initiated', 'Transaction Completed', 'Completed'], 'Danger': [ 'Verification Failed', 'Initiation Error', 'Initiation Failed', 'Transaction Failed', 'Transaction Error', 'Failed' ], 'Primary': [ 'Transaction Pending', 'Initiation Pending', 'Processing', 'Partially Completed' ] } for style in states_with_style.keys(): for state in states_with_style[style]: if not frappe.db.exists('Workflow State', state): frappe.get_doc({ "doctype": "Workflow State", "workflow_state_name": state, "style": style }).save() create_workflow('Outward Bank Payment') create_workflow('Bulk Outward Bank Payment') set_permissions_to_core_doctypes()
def make_custom_fields(): custom_fields = { "Party Account": [ dict( fieldname="debtor_creditor_number", label="Debtor/Creditor Number", fieldtype="Data", insert_after="account", translatable=0, ) ] } create_custom_fields(custom_fields)
def make_custom_field(): custom_fields = { 'Sales Invoice': [ { "fieldname": "ewaybill_barcode", "fieldtype": "Code", "label": "E- Way Bill", "allow_on_submit": 1, "read_only": 1, "hidden": 1 } ] } create_custom_fields(custom_fields, ignore_validate=frappe.flags.in_patch, update=True)
def execute(): frappe.reload_doc('accounts', 'doctype', 'advance_taxes_and_charges') frappe.reload_doc('accounts', 'doctype', 'payment_entry') custom_fields = { 'Payment Entry': [ dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', insert_after='deductions', print_hide=1, collapsible=1), dict(fieldname='company_address', label='Company Address', fieldtype='Link', insert_after='gst_section', print_hide=1, options='Address'), dict(fieldname='company_gstin', label='Company GSTIN', fieldtype='Data', insert_after='company_address', fetch_from='company_address.gstin', print_hide=1, read_only=1), dict(fieldname='place_of_supply', label='Place of Supply', fieldtype='Data', insert_after='company_gstin', print_hide=1, read_only=1), dict(fieldname='customer_address', label='Customer Address', fieldtype='Link', insert_after='place_of_supply', print_hide=1, options='Address', depends_on='eval:doc.party_type == "Customer"'), dict(fieldname='customer_gstin', label='Customer GSTIN', fieldtype='Data', insert_after='customer_address', fetch_from='customer_address.gstin', print_hide=1, read_only=1) ] } create_custom_fields(custom_fields, update=True)
def make_custom_fields(update=True): custom_fields = { 'Sales Invoice Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', label='Product Tax Category', fetch_from='item_code.product_tax_category'), dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', label='Tax Collectable', read_only=1, options='currency'), dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', label='Taxable Amount', read_only=1, options='currency') ], 'Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category', label='Product Tax Category') ] } create_custom_fields(custom_fields, update=update)
def execute(): company = frappe.get_all("Company", filters={"country": "India"}) if not company: return create_custom_fields( { "Tax Category": [ dict( fieldname="is_inter_state", label="Is Inter State", fieldtype="Check", insert_after="disabled", print_hide=1, ), dict( fieldname="is_reverse_charge", label="Is Reverse Charge", fieldtype="Check", insert_after="is_inter_state", print_hide=1, ), dict( fieldname="tax_category_column_break", fieldtype="Column Break", insert_after="is_reverse_charge", ), dict( fieldname="gst_state", label="Source State", fieldtype="Select", options="\n".join(states), insert_after="company", ), ] }, update=True, ) tax_category = frappe.qb.DocType("Tax Category") frappe.qb.update(tax_category).set(tax_category.is_reverse_charge, 1).where( tax_category.name.isin([ "Reverse Charge Out-State", "Reverse Charge In-State" ])).run()
def make_custom_fields(): """Create Custom fields - QR code Image file - Company Name in Arabic - Address in Arabic """ custom_fields = { "Sales Invoice": [ dict( fieldname="ksa_einv_qr", label="KSA E-Invoicing QR", fieldtype="Attach Image", read_only=1, no_copy=1, hidden=1, ) ], "POS Invoice": [ dict( fieldname="ksa_einv_qr", label="KSA E-Invoicing QR", fieldtype="Attach Image", read_only=1, no_copy=1, hidden=1, ) ], "Address": [ dict( fieldname="address_in_arabic", label="Address in Arabic", fieldtype="Data", insert_after="address_line2", ) ], "Company": [ dict( fieldname="company_name_in_arabic", label="Company Name In Arabic", fieldtype="Data", insert_after="company_name", ) ], } create_custom_fields(custom_fields, update=True)
def setup_domain(self): '''Setup domain icons, permissions, custom fields etc.''' self.setup_data() self.setup_roles() self.setup_properties() self.set_values() if not int(frappe.db.get_single_value('System Settings', 'setup_complete') or 0): # if setup not complete, setup desktop etc. self.setup_sidebar_items() self.setup_desktop_icons() self.set_default_portal_role() if self.data.custom_fields: create_custom_fields(self.data.custom_fields) if self.data.on_setup: # custom on_setup method frappe.get_attr(self.data.on_setup)()
def setup_domain(self): '''Setup domain icons, permissions, custom fields etc.''' self.setup_data() self.setup_roles() self.setup_properties() self.set_values() # always set the desktop icons while changing the domain settings self.setup_desktop_icons() if not int(frappe.defaults.get_defaults().setup_complete or 0): # if setup not complete, setup desktop etc. self.setup_sidebar_items() self.set_default_portal_role() if self.data.custom_fields: create_custom_fields(self.data.custom_fields) if self.data.on_setup: # custom on_setup method frappe.get_attr(self.data.on_setup)()
def make_custom_fields(update=True): hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC', fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description', allow_on_submit=1, print_hide=1, fetch_if_empty=1) invoice_gst_fields = [ dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', insert_after='language', print_hide=1, collapsible=1), dict(fieldname='invoice_copy', label='Invoice Copy', fieldtype='Select', insert_after='gst_section', print_hide=1, allow_on_submit=1, options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'), dict(fieldname='reverse_charge', label='Reverse Charge', fieldtype='Select', insert_after='invoice_copy', print_hide=1, options='Y\nN', default='N'), dict(fieldname='invoice_type', label='Invoice Type', fieldtype='Select', insert_after='invoice_copy', print_hide=1, options='Regular\nSEZ\nExport\nDeemed Export', default='Regular'), dict(fieldname='export_type', label='Export Type', fieldtype='Select', insert_after='invoice_type', print_hide=1, depends_on='eval:in_list(["SEZ", "Export", "Deemed Export"], doc.invoice_type)', options='\nWith Payment of Tax\nWithout Payment of Tax'), dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN', fieldtype='Data', insert_after='export_type', print_hide=1), dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'), dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document', fieldtype='Select', insert_after='gst_col_break', print_hide=1, depends_on='eval:doc.is_return==1', options='\n01-Sales Return\n02-Post Sale Discount\n03-Deficiency in services\n04-Correction in Invoice\n05-Change in POS\n06-Finalization of Provisional assessment\n07-Others') ] purchase_invoice_gst_fields = [ dict(fieldname='supplier_gstin', label='Supplier GSTIN', fieldtype='Data', insert_after='supplier_address', fetch_from='supplier_address.gstin', print_hide=1), dict(fieldname='company_gstin', label='Company GSTIN', fieldtype='Data', insert_after='shipping_address_display', fetch_from='shipping_address.gstin', print_hide=1), dict(fieldname='place_of_supply', label='Place of Supply', fieldtype='Data', insert_after='shipping_address', print_hide=1, read_only=0), ] purchase_invoice_itc_fields = [ dict(fieldname='eligibility_for_itc', label='Eligibility For ITC', fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1, options='input\ninput service\ncapital goods\nineligible', default="ineligible"), dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax', fieldtype='Data', insert_after='eligibility_for_itc', print_hide=1), dict(fieldname='itc_central_tax', label='Availed ITC Central Tax', fieldtype='Data', insert_after='itc_integrated_tax', print_hide=1), dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax', fieldtype='Data', insert_after='itc_central_tax', print_hide=1), dict(fieldname='itc_cess_amount', label='Availed ITC Cess', fieldtype='Data', insert_after='itc_state_tax', print_hide=1), ] sales_invoice_gst_fields = [ dict(fieldname='billing_address_gstin', label='Billing Address GSTIN', fieldtype='Data', insert_after='customer_address', fetch_from='customer_address.gstin', print_hide=1), dict(fieldname='customer_gstin', label='Customer GSTIN', fieldtype='Data', insert_after='shipping_address_name', fetch_from='shipping_address_name.gstin', print_hide=1), dict(fieldname='place_of_supply', label='Place of Supply', fieldtype='Data', insert_after='customer_gstin', print_hide=1, read_only=0), dict(fieldname='company_gstin', label='Company GSTIN', fieldtype='Data', insert_after='company_address', fetch_from='company_address.gstin', print_hide=1), ] sales_invoice_shipping_fields = [ dict(fieldname='port_code', label='Port Code', fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1, depends_on="eval:doc.invoice_type=='Export' "), dict(fieldname='shipping_bill_number', label=' Shipping Bill Number', fieldtype='Data', insert_after='port_code', print_hide=1, depends_on="eval:doc.invoice_type=='Export' "), dict(fieldname='shipping_bill_date', label='Shipping Bill Date', fieldtype='Date', insert_after='shipping_bill_number', print_hide=1, depends_on="eval:doc.invoice_type=='Export' ") ] inter_state_gst_field = [ dict(fieldname='is_inter_state', label='Is Inter State', fieldtype='Check', insert_after='disabled', print_hide=1) ] ewaybill_fields = [ { 'fieldname': 'distance', 'label': 'Distance (in km)', 'fieldtype': 'Float', 'insert_after': 'vehicle_no', 'print_hide': 1 }, { 'fieldname': 'gst_transporter_id', 'label': 'GST Transporter ID', 'fieldtype': 'Data', 'insert_after': 'transporter_name', 'fetch_from': 'transporter.gst_transporter_id', 'print_hide': 1 }, { 'fieldname': 'mode_of_transport', 'label': 'Mode of Transport', 'fieldtype': 'Select', 'options': '\nRoad\nAir\nRail\nShip', 'default': 'Road', 'insert_after': 'lr_date', 'print_hide': 1 }, { 'fieldname': 'gst_vehicle_type', 'label': 'GST Vehicle Type', 'fieldtype': 'Select', 'options': '\nRegular\nOver Dimensional Cargo (ODC)', 'default': 'Regular', 'depends_on': 'eval:(doc.mode_of_transport === "Road")', 'insert_after': 'mode_of_transport', 'print_hide': 1 } ] custom_fields = { 'Address': [ dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data', insert_after='fax'), dict(fieldname='gst_state', label='GST State', fieldtype='Select', options='\n'.join(states), insert_after='gstin'), dict(fieldname='gst_state_number', label='GST State Number', fieldtype='Data', insert_after='gst_state', read_only=1), ], 'Purchase Invoice': invoice_gst_fields + purchase_invoice_gst_fields + purchase_invoice_itc_fields, 'Purchase Order': purchase_invoice_gst_fields, 'Purchase Receipt': purchase_invoice_gst_fields, 'Sales Invoice': invoice_gst_fields + sales_invoice_gst_fields + sales_invoice_shipping_fields, 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields, 'Sales Order': sales_invoice_gst_fields, 'Sales Taxes and Charges Template': inter_state_gst_field, 'Purchase Taxes and Charges Template': inter_state_gst_field, 'Item': [ dict(fieldname='gst_hsn_code', label='HSN/SAC', fieldtype='Link', options='GST HSN Code', insert_after='item_group'), ], 'Quotation Item': [hsn_sac_field], 'Supplier Quotation Item': [hsn_sac_field], 'Sales Order Item': [hsn_sac_field], 'Delivery Note Item': [hsn_sac_field], 'Sales Invoice Item': [hsn_sac_field], 'Purchase Order Item': [hsn_sac_field], 'Purchase Receipt Item': [hsn_sac_field], 'Purchase Invoice Item': [hsn_sac_field], 'Material Request Item': [hsn_sac_field], 'Employee': [ dict(fieldname='ifsc_code', label='IFSC Code', fieldtype='Data', insert_after='bank_ac_no', print_hide=1, depends_on='eval:doc.salary_mode == "Bank"') ], 'Company': [ dict(fieldname='hra_section', label='HRA Settings', fieldtype='Section Break', insert_after='asset_received_but_not_billed'), dict(fieldname='basic_component', label='Basic Component', fieldtype='Link', options='Salary Component', insert_after='hra_section'), dict(fieldname='hra_component', label='HRA Component', fieldtype='Link', options='Salary Component', insert_after='basic_component'), dict(fieldname='arrear_component', label='Arrear Component', fieldtype='Link', options='Salary Component', insert_after='hra_component') ], 'Employee Tax Exemption Declaration':[ dict(fieldname='hra_section', label='HRA Exemption', fieldtype='Section Break', insert_after='declarations'), dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure', fieldtype='Currency', insert_after='hra_section', read_only=1), dict(fieldname='monthly_house_rent', label='Monthly House Rent', fieldtype='Currency', insert_after='salary_structure_hra'), dict(fieldname='rented_in_metro_city', label='Rented in Metro City', fieldtype='Check', insert_after='monthly_house_rent'), dict(fieldname='hra_column_break', fieldtype='Column Break', insert_after='rented_in_metro_city'), dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption', fieldtype='Currency', insert_after='hra_column_break', read_only=1), dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption', fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1) ], 'Employee Tax Exemption Proof Submission': [ dict(fieldname='hra_section', label='HRA Exemption', fieldtype='Section Break', insert_after='tax_exemption_proofs'), dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount', fieldtype='Currency', insert_after='hra_section'), dict(fieldname='rented_in_metro_city', label='Rented in Metro City', fieldtype='Check', insert_after='house_rent_payment_amount'), dict(fieldname='rented_from_date', label='Rented From Date', fieldtype='Date', insert_after='rented_in_metro_city'), dict(fieldname='rented_to_date', label='Rented To Date', fieldtype='Date', insert_after='rented_from_date'), dict(fieldname='hra_column_break', fieldtype='Column Break', insert_after='rented_to_date'), dict(fieldname='monthly_house_rent', label='Monthly House Rent', fieldtype='Currency', insert_after='hra_column_break', read_only=1), dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount', fieldtype='Currency', insert_after='monthly_house_rent', read_only=1), dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption', fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1) ], 'Supplier': [ { 'fieldname': 'gst_transporter_id', 'label': 'GST Transporter ID', 'fieldtype': 'Data', 'insert_after': 'supplier_type', 'depends_on': 'eval:doc.is_transporter' } ] } create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=update)
def make_custom_fields(): invoice_fields = [ dict(fieldname='vat_section', label='VAT Details', fieldtype='Section Break', insert_after='group_same_items', print_hide=1, collapsible=1), dict(fieldname='permit_no', label='Permit Number', fieldtype='Data', insert_after='vat_section', print_hide=1), dict(fieldname='reverse_charge_applicable', label='Reverse Charge Applicable', fieldtype='Select', insert_after='permit_no', print_hide=1, options='Y\nN', default='N') ] purchase_invoice_fields = [ dict(fieldname='company_trn', label='Company TRN', fieldtype='Read Only', insert_after='shipping_address', options='company.tax_id', print_hide=1), dict(fieldname='supplier_name_in_arabic', label='Supplier Name in Arabic', fieldtype='Read Only', insert_after='supplier_name', options='supplier.supplier_name_in_arabic', print_hide=1) ] sales_invoice_fields = [ dict(fieldname='company_trn', label='Company TRN', fieldtype='Read Only', insert_after='company_address', options='company.tax_id', print_hide=1), dict(fieldname='customer_name_in_arabic', label='Customer Name in Arabic', fieldtype='Read Only', insert_after='customer_name', options='customer.customer_name_in_arabic', print_hide=1), ] invoice_item_fields = [ dict(fieldname='tax_code', label='Tax Code', fieldtype='Read Only', options='item_code.tax_code', insert_after='description', allow_on_submit=1, print_hide=1), dict(fieldname='tax_rate', label='Tax Rate', fieldtype='Float', insert_after='tax_code', print_hide=1, hidden=1, read_only=1), dict(fieldname='tax_amount', label='Tax Amount', fieldtype='Currency', insert_after='tax_rate', print_hide=1, hidden=1, read_only=1, options="currency"), dict(fieldname='total_amount', label='Total Amount', fieldtype='Currency', insert_after='tax_amount', print_hide=1, hidden=1, read_only=1, options="currency"), ] delivery_date_field = [ dict(fieldname='delivery_date', label='Delivery Date', fieldtype='Date', insert_after='item_name', print_hide=1) ] custom_fields = { 'Item': [ dict(fieldname='tax_code', label='Tax Code', fieldtype='Data', insert_after='item_group'), ], 'Customer': [ dict(fieldname='customer_name_in_arabic', label='Customer Name in Arabic', fieldtype='Data', insert_after='customer_name'), ], 'Supplier': [ dict(fieldname='supplier_name_in_arabic', label='Supplier Name in Arabic', fieldtype='Data', insert_after='supplier_name'), ], 'Purchase Invoice': purchase_invoice_fields + invoice_fields, 'Purchase Order': purchase_invoice_fields + invoice_fields, 'Purchase Receipt': purchase_invoice_fields + invoice_fields, 'Sales Invoice': sales_invoice_fields + invoice_fields, 'Sales Order': sales_invoice_fields + invoice_fields, 'Delivery Note': sales_invoice_fields + invoice_fields, 'Sales Invoice Item': invoice_item_fields + delivery_date_field, 'Purchase Invoice Item': invoice_item_fields, 'Sales Order Item': invoice_item_fields, 'Delivery Note Item': invoice_item_fields, 'Quotation Item': invoice_item_fields, 'Purchase Order Item': invoice_item_fields, 'Purchase Receipt Item': invoice_item_fields, 'Supplier Quotation Item': invoice_item_fields, } create_custom_fields(custom_fields)
def make_custom_fields(): hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC', fieldtype='Data', options='item_code.gst_hsn_code', insert_after='description', allow_on_submit=1, print_hide=1) invoice_gst_fields = [ dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', insert_after='select_print_heading', print_hide=1, collapsible=1), dict(fieldname='invoice_copy', label='Invoice Copy', fieldtype='Select', insert_after='gst_section', print_hide=1, allow_on_submit=1, options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'), dict(fieldname='reverse_charge', label='Reverse Charge', fieldtype='Select', insert_after='invoice_copy', print_hide=1, options='Y\nN', default='N'), dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='reverse_charge'), dict(fieldname='invoice_type', label='Invoice Type', fieldtype='Select', insert_after='reverse_charge', print_hide=1, options='Regular\nSEZ\nExport\nDeemed Export', default='Regular'), dict(fieldname='export_type', label='Export Type', fieldtype='Select', insert_after='invoice_type', print_hide=1, depends_on='eval:in_list(["SEZ", "Export", "Deemed Export"], doc.invoice_type)', options='\nWith Payment of Tax\nWithout Payment of Tax'), dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN', fieldtype='Data', insert_after='export_type', print_hide=1) ] purchase_invoice_gst_fields = [ dict(fieldname='supplier_gstin', label='Supplier GSTIN', fieldtype='Data', insert_after='supplier_address', options='supplier_address.gstin', print_hide=1), dict(fieldname='company_gstin', label='Company GSTIN', fieldtype='Data', insert_after='shipping_address', options='shipping_address.gstin', print_hide=1) ] sales_invoice_gst_fields = [ dict(fieldname='billing_address_gstin', label='Billing Address GSTIN', fieldtype='Data', insert_after='customer_address', options='customer_address.gstin', print_hide=1), dict(fieldname='customer_gstin', label='Customer GSTIN', fieldtype='Data', insert_after='shipping_address', options='shipping_address_name.gstin', print_hide=1), dict(fieldname='place_of_supply', label='Place of Supply', fieldtype='Data', insert_after='customer_gstin', print_hide=1, options='shipping_address_name.gst_state_number', read_only=0), dict(fieldname='company_gstin', label='Company GSTIN', fieldtype='Data', insert_after='company_address', options='company_address.gstin', print_hide=1) ] custom_fields = { 'Address': [ dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data', insert_after='fax'), dict(fieldname='gst_state', label='GST State', fieldtype='Select', options='\n'.join(states), insert_after='gstin'), dict(fieldname='gst_state_number', label='GST State Number', fieldtype='Int', insert_after='gst_state', read_only=1), ], 'Purchase Invoice': purchase_invoice_gst_fields + invoice_gst_fields, 'Sales Invoice': sales_invoice_gst_fields + invoice_gst_fields, "Delivery Note": sales_invoice_gst_fields, 'Item': [ dict(fieldname='gst_hsn_code', label='HSN/SAC', fieldtype='Link', options='GST HSN Code', insert_after='item_group'), ], 'Quotation Item': [hsn_sac_field], 'Supplier Quotation Item': [hsn_sac_field], 'Sales Order Item': [hsn_sac_field], 'Delivery Note Item': [hsn_sac_field], 'Sales Invoice Item': [hsn_sac_field], 'Purchase Order Item': [hsn_sac_field], 'Purchase Receipt Item': [hsn_sac_field], 'Purchase Invoice Item': [hsn_sac_field] } create_custom_fields(custom_fields)
def make_custom_fields(update=True): invoice_item_fields = [ dict(fieldname='tax_rate', label='Tax Rate', fieldtype='Float', insert_after='description', print_hide=1, hidden=1, read_only=1), dict(fieldname='tax_amount', label='Tax Amount', fieldtype='Currency', insert_after='tax_rate', print_hide=1, hidden=1, read_only=1, options="currency"), dict(fieldname='total_amount', label='Total Amount', fieldtype='Currency', insert_after='tax_amount', print_hide=1, hidden=1, read_only=1, options="currency") ] custom_fields = { 'Company': [ dict(fieldname='sb_e_invoicing', label='E-Invoicing', fieldtype='Section Break', insert_after='date_of_establishment', print_hide=1), dict(fieldname='fiscal_regime', label='Fiscal Regime', fieldtype='Select', insert_after='sb_e_invoicing', print_hide=1, options="\n".join(map(lambda x: x.decode('utf-8'), fiscal_regimes))), dict(fieldname='fiscal_code', label='Fiscal Code', fieldtype='Data', insert_after='fiscal_regime', print_hide=1, description=_("Applicable if the company is an Individual or a Proprietorship")), dict(fieldname='vat_collectability', label='VAT Collectability', fieldtype='Select', insert_after='fiscal_code', print_hide=1, options="\n".join(map(lambda x: x.decode('utf-8'), vat_collectability_options))), dict(fieldname='cb_e_invoicing1', fieldtype='Column Break', insert_after='vat_collectability', print_hide=1), dict(fieldname='registrar_office_province', label='Province of the Registrar Office', fieldtype='Data', insert_after='cb_e_invoicing1', print_hide=1, length=2), dict(fieldname='registration_number', label='Registration Number', fieldtype='Data', insert_after='registrar_office_province', print_hide=1, length=20), dict(fieldname='share_capital_amount', label='Share Capital', fieldtype='Currency', insert_after='registration_number', print_hide=1, description=_('Applicable if the company is SpA, SApA or SRL')), dict(fieldname='no_of_members', label='No of Members', fieldtype='Select', insert_after='share_capital_amount', print_hide=1, options="\nSU-Socio Unico\nSM-Piu Soci", description=_("Applicable if the company is a limited liability company")), dict(fieldname='liquidation_state', label='Liquidation State', fieldtype='Select', insert_after='no_of_members', print_hide=1, options="\nLS-In Liquidazione\nLN-Non in Liquidazione") ], 'Sales Taxes and Charges': [ dict(fieldname='tax_exemption_reason', label='Tax Exemption Reason', fieldtype='Select', insert_after='included_in_print_rate', print_hide=1, depends_on='eval:doc.charge_type!="Actual" && doc.rate==0.0', options="\n" + "\n".join(map(lambda x: x.decode('utf-8'), tax_exemption_reasons))), dict(fieldname='tax_exemption_law', label='Tax Exempt Under', fieldtype='Text', insert_after='tax_exemption_reason', print_hide=1, depends_on='eval:doc.charge_type!="Actual" && doc.rate==0.0') ], 'Customer': [ dict(fieldname='fiscal_code', label='Fiscal Code', fieldtype='Data', insert_after='tax_id', print_hide=1), dict(fieldname='recipient_code', label='Recipient Code', fieldtype='Data', insert_after='fiscal_code', print_hide=1, default="0000000"), dict(fieldname='pec', label='Recipient PEC', fieldtype='Data', insert_after='fiscal_code', print_hide=1), dict(fieldname='is_public_administration', label='Is Public Administration', fieldtype='Check', insert_after='is_internal_customer', print_hide=1, description=_("Set this if the customer is a Public Administration company."), depends_on='eval:doc.customer_type=="Company"'), dict(fieldname='first_name', label='First Name', fieldtype='Data', insert_after='salutation', print_hide=1, depends_on='eval:doc.customer_type!="Company"'), dict(fieldname='last_name', label='Last Name', fieldtype='Data', insert_after='first_name', print_hide=1, depends_on='eval:doc.customer_type!="Company"') ], 'Mode of Payment': [ dict(fieldname='mode_of_payment_code', label='Code', fieldtype='Select', insert_after='included_in_print_rate', print_hide=1, options="\n".join(map(lambda x: x.decode('utf-8'), mode_of_payment_codes))) ], 'Payment Schedule': [ dict(fieldname='mode_of_payment_code', label='Code', fieldtype='Select', insert_after='mode_of_payment', print_hide=1, options="\n".join(map(lambda x: x.decode('utf-8'), mode_of_payment_codes)), fetch_from="mode_of_payment.mode_of_payment_code", read_only=1), dict(fieldname='bank_account', label='Bank Account', fieldtype='Link', insert_after='mode_of_payment_code', print_hide=1, options="Bank Account"), dict(fieldname='bank_account_name', label='Bank Account Name', fieldtype='Data', insert_after='bank_account', print_hide=1, fetch_from="bank_account.account_name", read_only=1), dict(fieldname='bank_account_no', label='Bank Account No', fieldtype='Data', insert_after='bank_account_name', print_hide=1, fetch_from="bank_account.bank_account_no", read_only=1), dict(fieldname='bank_account_iban', label='IBAN', fieldtype='Data', insert_after='bank_account_name', print_hide=1, fetch_from="bank_account.iban", read_only=1), ], "Sales Invoice": [ dict(fieldname='vat_collectability', label='VAT Collectability', fieldtype='Select', insert_after='taxes_and_charges', print_hide=1, options="\n".join(map(lambda x: x.decode('utf-8'), vat_collectability_options)), fetch_from="company.vat_collectability"), dict(fieldname='sb_e_invoicing_reference', label='E-Invoicing', fieldtype='Section Break', insert_after='pos_total_qty', print_hide=1), dict(fieldname='company_tax_id', label='Company Tax ID', fieldtype='Data', insert_after='sb_e_invoicing_reference', print_hide=1, read_only=1, fetch_from="company.tax_id"), dict(fieldname='company_fiscal_code', label='Company Fiscal Code', fieldtype='Data', insert_after='company_tax_id', print_hide=1, read_only=1, fetch_from="company.fiscal_code"), dict(fieldname='company_fiscal_regime', label='Company Fiscal Regime', fieldtype='Data', insert_after='company_fiscal_code', print_hide=1, read_only=1, fetch_from="company.fiscal_regime"), dict(fieldname='cb_e_invoicing_reference', fieldtype='Column Break', insert_after='company_fiscal_regime', print_hide=1), dict(fieldname='customer_fiscal_code', label='Customer Fiscal Code', fieldtype='Data', insert_after='cb_e_invoicing_reference', read_only=1, fetch_from="customer.fiscal_code"), ], 'Purchase Invoice Item': invoice_item_fields, 'Sales Order Item': invoice_item_fields, 'Delivery Note Item': invoice_item_fields, 'Sales Invoice Item': invoice_item_fields, 'Quotation Item': invoice_item_fields, 'Purchase Order Item': invoice_item_fields, 'Purchase Receipt Item': invoice_item_fields, 'Supplier Quotation Item': invoice_item_fields, 'Address': [ dict(fieldname='country_code', label='Country Code', fieldtype='Data', insert_after='country', print_hide=1, read_only=0, fetch_from="country.code"), dict(fieldname='state_code', label='State Code', fieldtype='Data', insert_after='state', print_hide=1) ] } create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=update)