diff --git a/erpnext/patches/jan_mar_2012/customer_address_contact_patch.py b/erpnext/patches/jan_mar_2012/customer_address_contact_patch.py new file mode 100644 index 0000000000..6a7d40568c --- /dev/null +++ b/erpnext/patches/jan_mar_2012/customer_address_contact_patch.py @@ -0,0 +1,58 @@ +import webnotes + +def execute(): + """ + * Reload Search Criteria "Customer Address Contact" + * SET is_primary_contact=1, is_primary_address=1 WHERE not specified + """ + reload_sc() + patch_primary_contact() + patch_primary_address() + +def reload_sc(): + from webnotes.modules.module_manager import reload_doc + reload_doc('selling', 'search_criteria', 'customer_address_contact') + reload_doc('selling', 'Module Def', 'Selling') + +def patch_primary_contact(): + res = webnotes.conn.sql(""" + SELECT name FROM `tabContact` + WHERE customer IN ( + SELECT customer FROM `tabContact` + WHERE IFNULL(customer, '')!='' + GROUP BY customer HAVING SUM(IFNULL(is_primary_contact, 0))=0 + ) OR supplier IN ( + SELECT supplier FROM `tabContact` + WHERE IFNULL(supplier, '')!='' + GROUP BY supplier HAVING SUM(IFNULL(is_primary_contact, 0))=0 + ) OR sales_partner IN ( + SELECT sales_partner FROM `tabContact` + WHERE IFNULL(sales_partner, '')!='' + GROUP BY sales_partner HAVING SUM(IFNULL(is_primary_contact, 0))=0 + ) + """, as_list=1) + names = ", ".join(["'" + str(r[0]) + "'" for r in res if r]) + if names: webnotes.conn.sql("UPDATE `tabContact` SET is_primary_contact=1 WHERE name IN (%s)" % names) + +def patch_primary_address(): + res = webnotes.conn.sql(""" + SELECT name FROM `tabAddress` + WHERE customer IN ( + SELECT customer FROM `tabAddress` + WHERE IFNULL(customer, '')!='' + GROUP BY customer HAVING SUM(IFNULL(is_primary_address, 0))=0 + AND SUM(IFNULL(is_shipping_address, 0))=0 + ) OR supplier IN ( + SELECT supplier FROM `tabAddress` + WHERE IFNULL(supplier, '')!='' + GROUP BY supplier HAVING SUM(IFNULL(is_primary_address, 0))=0 + AND SUM(IFNULL(is_shipping_address, 0))=0 + ) OR sales_partner IN ( + SELECT sales_partner FROM `tabAddress` + WHERE IFNULL(sales_partner, '')!='' + GROUP BY sales_partner HAVING SUM(IFNULL(is_primary_address, 0))=0 + AND SUM(IFNULL(is_shipping_address, 0))=0 + ) + """, as_list=1) + names = ", ".join(["'" + str(r[0]) + "'" for r in res if r]) + if names: webnotes.conn.sql("UPDATE `tabAddress` SET is_primary_address=1 WHERE name IN (%s)" % names) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index fe4f09ca7e..c0c7d1ecea 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -35,4 +35,9 @@ patch_list = [ 'patch_file': 'remove_get_tds_button', 'description': "Remove One Get TDS button, which is appearing twice in JV" }, + { + 'patch_module': 'patches.jan_mar_2012', + 'patch_file': 'customer_address_contact', + 'description': "Install Customer Address Contact report and run patches regarding primary address and contact" + }, ] diff --git a/erpnext/production/doctype/bill_of_materials/bill_of_materials.py b/erpnext/production/doctype/bill_of_materials/bill_of_materials.py index 2a17817555..6e99af94d7 100644 --- a/erpnext/production/doctype/bill_of_materials/bill_of_materials.py +++ b/erpnext/production/doctype/bill_of_materials/bill_of_materials.py @@ -135,7 +135,7 @@ class DocType: """ Uncheck others if current one is selected as default, update default bom in item master""" if self.doc.is_default and self.doc.is_active == 'Yes': - sql("update `tabBill Of Materials` set is_default = 0 where name != %s", self.doc.name) + sql("update `tabBill Of Materials` set is_default = 0 where name != %s and item=%s", (self.doc.name, self.doc.item)) # update default bom in Item Master sql("update `tabItem` set default_bom = %s where name = %s", (self.doc.name, self.doc.item)) diff --git a/erpnext/selling/Module Def/Selling/Selling.txt b/erpnext/selling/Module Def/Selling/Selling.txt index 5500cb3e74..42c8449fd1 100644 --- a/erpnext/selling/Module Def/Selling/Selling.txt +++ b/erpnext/selling/Module Def/Selling/Selling.txt @@ -1,673 +1,335 @@ +# Module Def, Selling [ + + # These values are common in all dictionaries { - '_last_update': None, - 'creation': '2011-06-30 15:45:03', - 'disabled': 'No', + 'creation': '2011-07-01 17:39:08', 'docstatus': 0, + 'modified': '2012-01-23 18:25:58', + 'modified_by': 'Administrator', + 'owner': 'Administrator' + }, + + # These values are common for all Module Def Role + { + 'doctype': 'Module Def Role', + 'name': '__common__', + 'parent': 'Selling', + 'parentfield': 'roles', + 'parenttype': 'Module Def' + }, + + # These values are common for all Module Def Item + { + 'doctype': 'Module Def Item', + 'name': '__common__', + 'parent': 'Selling', + 'parentfield': 'items', + 'parenttype': 'Module Def' + }, + + # These values are common for all Module Def + { + 'disabled': 'No', 'doctype': u'Module Def', 'doctype_list': 'Print Format, Sales Order\nPrint Format, Quotation Format\nPrint Format, Delivery Note Format', 'file_list': 'crm.gif,FileData/00208', - 'idx': None, 'is_hidden': 'No', - 'last_updated_date': None, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', 'module_desc': 'Manage you sales team, with your leads, customers, quotes, orders etc.', 'module_icon': 'Selling.gif', 'module_label': 'Selling', 'module_name': 'Selling', - 'module_page': None, 'module_seq': 3, - 'name': 'Selling', - 'owner': 'Administrator', - 'parent': None, - 'parentfield': None, - 'parenttype': None, - 'trash_reason': None, - 'widget_code': None + 'name': '__common__' }, + + # Module Def, Selling + { + 'doctype': u'Module Def', + 'name': 'Selling' + }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Database of potential customers you need to keep in touch with', 'display_name': 'Lead', 'doc_name': 'Lead', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'status\nlead_owner\nlead_name\ncontact_no\ncontact_by\ncontact_date\nexpected_month', - 'hide': None, - 'icon': None, - 'idx': 1, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01284', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'status\nlead_owner\nlead_name\ncontact_no\ncontact_by\ncontact_date\nexpected_month' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Your Customer Database', 'display_name': 'Customer', 'doc_name': 'Customer', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'customer_group\ncountry', - 'hide': None, - 'icon': None, - 'idx': 2, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01285', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'customer_group\ncountry' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Specific requirements from a Lead / Customer', 'display_name': 'Enquiry', 'doc_name': 'Enquiry', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ncompany', - 'hide': None, - 'icon': None, - 'idx': 3, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01286', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ncompany' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Offers you have made to your customers', 'display_name': 'Quotation', 'doc_name': 'Quotation', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ngrand_total\ncompany', - 'hide': None, - 'icon': None, - 'idx': 4, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01287', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ngrand_total\ncompany' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Database of confirmed Sale Orders from your Customers', 'display_name': 'Sales Order', 'doc_name': 'Sales Order', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'status\ntransaction_date\ncustomer\ncost_center\ngrand_total\nper_delivered\nper_billed\ncompany', - 'hide': None, - 'icon': None, - 'idx': 5, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01288', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'status\ntransaction_date\ncustomer\ncost_center\ngrand_total\nper_delivered\nper_billed\ncompany' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Sales Dashboard', 'doc_name': 'Sales Dashboard', 'doc_type': 'Pages', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 6, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01289', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, - 'display_name': None, 'doc_name': 'Reports', 'doc_type': 'Separator', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 7, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01290', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item + { + 'doc_name': 'Reports', + 'doc_type': 'Separator', + 'doctype': 'Module Def Item' + }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Gross Profit', 'doc_name': 'Delivery Note Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 8, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01291', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Territory, Item Group wise GP', 'doc_name': 'Delivery Note', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 9, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01292', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Itemwise Sales Details', 'doc_name': 'Sales Order Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 10, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01293', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Itemwise Delivery Details', 'doc_name': 'Delivery Note Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 11, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01294', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Sales Personwise Transaction Summary', 'doc_name': 'Sales Person', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 12, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01295', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Total Target Variance Report', 'doc_name': 'Target Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 13, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01296', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Sales Persons Target Variance (Item Group wise)', 'doc_name': 'Target Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 14, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01297', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Territories Target Variance (Item Group wise)', 'doc_name': 'Target Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 15, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01298', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Sales Order Pending Items', 'doc_name': 'Sales Order Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 16, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01299', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Sales Orderwise Booking & Delivery Summary', 'doc_name': 'Sales Order Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 17, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01300', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Sales Orderwise Pending Qty To Deliver', 'doc_name': 'Sales Order Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 18, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01301', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Sales Orderwise Pending Amount To Bill', 'doc_name': 'Sales Order Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 19, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01302', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Delivered Items to be Install', 'doc_name': 'Delivery Note Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 20, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01303', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Itemwise Price List', 'doc_name': 'Ref Rate Detail', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 21, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01304', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', - 'description': None, 'display_name': 'Follow-up Report', 'doc_name': 'Follow up', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 22, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01305', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Ledger details of your debtors', 'display_name': "Debtor's Ledger", 'doc_name': 'GL Entry', 'doc_type': 'Reports', - 'docstatus': 0, - 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 23, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01306', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'doctype': 'Module Def Item' }, + + # Module Def Item + { + 'description': 'Report displaying Customer, Primary Address Details & Primary Contact Details', + 'display_name': 'Customer Address Contact', + 'doc_name': 'Customer', + 'doc_type': 'Reports', + 'doctype': 'Module Def Item' + }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Customer Category', 'display_name': 'Customer Group', 'doc_name': 'Customer Group', 'doc_type': 'Setup Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'id\ndescription', - 'hide': None, - 'icon': None, - 'idx': 24, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01307', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'id\ndescription' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Sales person details', 'display_name': 'Sales Person', 'doc_name': 'Sales Person', 'doc_type': 'Setup Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'id\nterritory\ndepartment\nmobile_no\nemail_id', - 'hide': None, - 'icon': None, - 'idx': 25, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01308', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'id\nterritory\ndepartment\nmobile_no\nemail_id' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Item master', 'display_name': 'Item', 'doc_name': 'Item', 'doc_type': 'Setup Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'name\nitem_group\ndescription', - 'hide': None, - 'icon': None, - 'idx': 26, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01309', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'name\nitem_group\ndescription' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Sales partner details', 'display_name': 'Sales Partner', 'doc_name': 'Sales Partner', 'doc_type': 'Setup Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'id\npartner_type\nmobile\nemail\nterritory', - 'hide': None, - 'icon': None, - 'idx': 27, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01310', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'id\npartner_type\nmobile\nemail\nterritory' }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:45:03', 'description': 'Business campaigns', 'display_name': 'Campaign', 'doc_name': 'Campaign', 'doc_type': 'Setup Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': 'id\ncampaign_name\ndescription', - 'hide': None, - 'icon': None, - 'idx': 28, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDI01311', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'fields': 'id\ncampaign_name\ndescription' }, + + # Module Def Role { - 'creation': '2011-06-30 15:45:03', - 'docstatus': 0, 'doctype': 'Module Def Role', - 'idx': 1, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDR00328', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'roles', - 'parenttype': 'Module Def', 'role': 'Administrator' }, + + # Module Def Role { - 'creation': '2011-06-30 15:45:03', - 'docstatus': 0, 'doctype': 'Module Def Role', - 'idx': 2, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDR00329', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'roles', - 'parenttype': 'Module Def', 'role': 'Sales Manager' }, + + # Module Def Role { - 'creation': '2011-06-30 15:45:03', - 'docstatus': 0, 'doctype': 'Module Def Role', - 'idx': 3, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDR00330', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'roles', - 'parenttype': 'Module Def', 'role': 'Sales User' }, + + # Module Def Role { - 'creation': '2011-06-30 15:45:03', - 'docstatus': 0, 'doctype': 'Module Def Role', - 'idx': 4, - 'modified': '2011-06-30 15:45:03', - 'modified_by': 'Administrator', - 'name': 'MDR00331', - 'owner': 'Administrator', - 'parent': 'Selling', - 'parentfield': 'roles', - 'parenttype': 'Module Def', 'role': 'Sales Master Manager' } ] \ No newline at end of file diff --git a/erpnext/selling/search_criteria/customer_address_contact/__init__.py b/erpnext/selling/search_criteria/customer_address_contact/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/selling/search_criteria/customer_address_contact/customer_address_contact.txt b/erpnext/selling/search_criteria/customer_address_contact/customer_address_contact.txt new file mode 100644 index 0000000000..9e0a7155bc --- /dev/null +++ b/erpnext/selling/search_criteria/customer_address_contact/customer_address_contact.txt @@ -0,0 +1,36 @@ +# Search Criteria, customer_address_contact +[ + + # These values are common in all dictionaries + { + 'creation': '2012-01-23 18:28:40', + 'docstatus': 0, + 'modified': '2012-01-23 18:28:40', + 'modified_by': 'Administrator', + 'owner': 'Administrator' + }, + + # These values are common for all Search Criteria + { + 'add_col': "`tabAddress`.address_line1 AS 'Address Line 1'\n`tabAddress`.address_line2 AS 'Address Line 2'\n`tabAddress`.city AS 'City'\n`tabAddress`.state AS 'State'\n`tabAddress`.pincode AS 'Pincode'\n`tabAddress`.country AS 'Country'\n`tabContact`.first_name AS 'Contact First Name'\n`tabContact`.last_name AS 'Contact Last Name'\n`tabContact`.phone AS 'Contact Phone'\n`tabContact`.mobile_no AS 'Contact Mobile'\n`tabContact`.email_id AS 'Contact Email'", + 'add_cond': '`tabAddress`.customer=`tabCustomer`.name\nifnull(`tabAddress`.is_primary_address, 0)=1\n`tabContact`.customer=`tabCustomer`.name\nifnull(`tabContact`.is_primary_contact, 0)=1', + 'add_tab': '`tabAddress`\n`tabContact`', + 'columns': 'Customer\x01ID,Customer\x01Customer Name', + 'criteria_name': 'Customer Address Contact', + 'doc_type': 'Customer', + 'doctype': 'Search Criteria', + 'filters': "{'Customer\x01Saved':1,'Customer\x01Submitted':1}", + 'module': 'Selling', + 'name': '__common__', + 'page_len': 50, + 'sort_by': '`tabCustomer`.`customer_name`', + 'sort_order': 'ASC', + 'standard': 'Yes' + }, + + # Search Criteria, customer_address_contact + { + 'doctype': 'Search Criteria', + 'name': 'customer_address_contact' + } +] \ No newline at end of file diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py index eabf624af2..7602d1d755 100644 --- a/erpnext/utilities/doctype/address/address.py +++ b/erpnext/utilities/doctype/address/address.py @@ -4,53 +4,64 @@ import webnotes from webnotes.model.doc import Document from webnotes import session, form, msgprint, errprint -sql = webnotes.conn.sql - # ----------------------------------------------------------------------------------------- class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist + def __init__(self, doc, doclist=[]): + self.doc = doc + self.doclist = doclist - def autoname(self): - if self.doc.customer: - self.doc.name = self.doc.customer + '-' + self.doc.address_type - elif self.doc.supplier: - self.doc.name = self.doc.supplier + '-' + self.doc.address_type - elif self.doc.sales_partner: - self.doc.name = self.doc.sales_partner + '-' + self.doc.address_type - - # filter out bad characters in name - #self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','') + def autoname(self): + if self.doc.customer: + self.doc.name = self.doc.customer + '-' + self.doc.address_type + elif self.doc.supplier: + self.doc.name = self.doc.supplier + '-' + self.doc.address_type + elif self.doc.sales_partner: + self.doc.name = self.doc.sales_partner + '-' + self.doc.address_type + + # filter out bad characters in name + #self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','') #---------------------- # Call to Validate #---------------------- - def validate(self): - self.validate_primary_address() - self.validate_shipping_address() + def validate(self): + self.validate_primary_address() + self.validate_shipping_address() #---------------------- # Validate that there can only be one primary address for particular customer, supplier #---------------------- - def validate_primary_address(self): - if self.doc.is_primary_address == 1: - if self.doc.customer: - sql("update tabAddress set is_primary_address=0 where customer = '%s'" % (self.doc.customer)) - elif self.doc.supplier: - sql("update tabAddress set is_primary_address=0 where supplier = '%s'" % (self.doc.supplier)) - elif self.doc.sales_partner: - sql("update tabAddress set is_primary_address=0 where sales_partner = '%s'" % (self.doc.sales_partner)) - + def validate_primary_address(self): + sql = webnotes.conn.sql + if self.doc.is_primary_address == 1: + if self.doc.customer: + sql("update tabAddress set is_primary_address=0 where customer = '%s'" % (self.doc.customer)) + elif self.doc.supplier: + sql("update tabAddress set is_primary_address=0 where supplier = '%s'" % (self.doc.supplier)) + elif self.doc.sales_partner: + sql("update tabAddress set is_primary_address=0 where sales_partner = '%s'" % (self.doc.sales_partner)) + elif not self.doc.is_shipping_address: + if self.doc.customer: + if not sql("select name from tabAddress where is_primary_address=1 and customer = '%s'" % (self.doc.customer)): + self.doc.is_primary_address = 1 + elif self.doc.supplier: + if not sql("select name from tabAddress where is_primary_address=1 and supplier = '%s'" % (self.doc.supplier)): + self.doc.is_primary_address = 1 + elif self.doc.sales_partner: + if not sql("select name from tabAddress where is_primary_address=1 and sales_partner = '%s'" % (self.doc.sales_partner)): + self.doc.is_primary_address = 1 + + #---------------------- # Validate that there can only be one shipping address for particular customer, supplier #---------------------- - def validate_shipping_address(self): - if self.doc.is_shipping_address == 1: - if self.doc.customer: - sql("update tabAddress set is_shipping_address=0 where customer = '%s'" % (self.doc.customer)) - elif self.doc.supplier: - sql("update tabAddress set is_shipping_address=0 where supplier = '%s'" % (self.doc.supplier)) - elif self.doc.sales_partner: - sql("update tabAddress set is_shipping_address=0 where sales_partner = '%s'" % (self.doc.sales_partner)) + def validate_shipping_address(self): + sql = webnotes.conn.sql + if self.doc.is_shipping_address == 1: + if self.doc.customer: + sql("update tabAddress set is_shipping_address=0 where customer = '%s'" % (self.doc.customer)) + elif self.doc.supplier: + sql("update tabAddress set is_shipping_address=0 where supplier = '%s'" % (self.doc.supplier)) + elif self.doc.sales_partner: + sql("update tabAddress set is_shipping_address=0 where sales_partner = '%s'" % (self.doc.sales_partner)) diff --git a/erpnext/utilities/doctype/contact/contact.js b/erpnext/utilities/doctype/contact/contact.js index bca16151a0..d33750d3ea 100644 --- a/erpnext/utilities/doctype/contact/contact.js +++ b/erpnext/utilities/doctype/contact/contact.js @@ -3,6 +3,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { if(doc.customer) cur_frm.add_fetch('customer', 'customer_name', 'customer_name'); if(doc.supplier) cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name'); } + /* //---------- on refresh ---------------------- cur_frm.cscript.refresh = function(doc,cdt,cdn){ diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py index 6d7c4c442a..8cc9ba1d7a 100644 --- a/erpnext/utilities/doctype/contact/contact.py +++ b/erpnext/utilities/doctype/contact/contact.py @@ -4,40 +4,49 @@ import webnotes from webnotes.model.doc import Document from webnotes import session, form, msgprint, errprint -sql = webnotes.conn.sql - # ----------------------------------------------------------------------------------------- class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist + def __init__(self, doc, doclist=[]): + self.doc = doc + self.doclist = doclist - def autoname(self): - if self.doc.customer: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer - elif self.doc.supplier: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier - elif self.doc.sales_partner: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner - - # filter out bad characters in name - #self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','') + def autoname(self): + if self.doc.customer: + self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer + elif self.doc.supplier: + self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier + elif self.doc.sales_partner: + self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner + + # filter out bad characters in name + #self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','') #---------------------- # Call to Validate #---------------------- - def validate(self): - self.validate_primary_contact() + def validate(self): + self.validate_primary_contact() #---------------------- # Validate that there can only be one primary contact for particular customer, supplier #---------------------- - def validate_primary_contact(self): - if self.doc.is_primary_contact == 1: - if self.doc.customer: - sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer)) - elif self.doc.supplier: - sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier)) - elif self.doc.sales_partner: - sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner)) + def validate_primary_contact(self): + sql = webnotes.conn.sql + if self.doc.is_primary_contact == 1: + if self.doc.customer: + sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer)) + elif self.doc.supplier: + sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier)) + elif self.doc.sales_partner: + sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner)) + else: + if self.doc.customer: + if not sql("select name from tabContact where is_primary_contact=1 and customer = '%s'" % (self.doc.customer)): + self.doc.is_primary_contact = 1 + elif self.doc.supplier: + if not sql("select name from tabContact where is_primary_contact=1 and supplier = '%s'" % (self.doc.supplier)): + self.doc.is_primary_contact = 1 + elif self.doc.sales_partner: + if not sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)): + self.doc.is_primary_contact = 1 diff --git a/erpnext/utilities/doctype/contact/contact.txt b/erpnext/utilities/doctype/contact/contact.txt index e5a6757ba7..9167ed48fc 100644 --- a/erpnext/utilities/doctype/contact/contact.txt +++ b/erpnext/utilities/doctype/contact/contact.txt @@ -5,14 +5,14 @@ { 'creation': '2010-08-08 17:08:55', 'docstatus': 0, - 'modified': '2011-12-19 14:11:08', + 'modified': '2012-01-23 16:07:56', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1316075905', + '_last_update': '1327314958', 'allow_trash': 1, 'colour': 'White:FFF', 'default_print_format': 'Standard', @@ -26,7 +26,7 @@ 'server_code_error': ' ', 'show_in_menu': 0, 'subject': '%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s', - 'version': 243 + 'version': 245 }, # These values are common for all DocField @@ -225,7 +225,7 @@ { 'colour': 'White:FFF', 'default': '0', - 'depends_on': 'eval:(cint(doc.is_customer) || cint(doc.is_supplier) || cint(doc.is_sales_partner))', + 'depends_on': 'eval:(doc.customer || doc.supplier || doc.sales_partner)', 'doctype': 'DocField', 'fieldname': 'is_primary_contact', 'fieldtype': 'Check', diff --git a/index.html b/index.html index bd74560508..8662485afe 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ ERPNext -