From 44b2e23eba328476034c6ac50db613be3e611208 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 9 Aug 2013 12:43:57 +0530 Subject: [PATCH] [fix] pos settings - replace customer account with customer --- accounts/doctype/pos_setting/pos_setting.txt | 8 +++---- ..._replace_customer account_with_customer.py | 21 +++++++++++++++++++ patches/patch_list.py | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 patches/august_2013/p02_pos_setting_replace_customer account_with_customer.py diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt index a8c9bd4f73..a1c74cb71b 100755 --- a/accounts/doctype/pos_setting/pos_setting.txt +++ b/accounts/doctype/pos_setting/pos_setting.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 12:15:51", "docstatus": 0, - "modified": "2013-08-08 14:21:57", + "modified": "2013-08-09 12:35:03", "modified_by": "Administrator", "owner": "Administrator" }, @@ -131,12 +131,12 @@ }, { "doctype": "DocField", - "fieldname": "customer_account", + "fieldname": "customer", "fieldtype": "Link", - "label": "Customer Account", + "label": "Customer", "oldfieldname": "customer_account", "oldfieldtype": "Link", - "options": "Account", + "options": "Customer", "read_only": 0, "reqd": 0 }, diff --git a/patches/august_2013/p02_pos_setting_replace_customer account_with_customer.py b/patches/august_2013/p02_pos_setting_replace_customer account_with_customer.py new file mode 100644 index 0000000000..4076f58621 --- /dev/null +++ b/patches/august_2013/p02_pos_setting_replace_customer account_with_customer.py @@ -0,0 +1,21 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.reload_doc("accounts", "doctype", "pos_setting") + customer_account = webnotes.conn.sql("""select customer_account, name from `tabPOS Setting` + where ifnull(customer_account, '')!=''""") + + for cust_acc, pos_name in customer_account: + customer = webnotes.conn.sql("""select master_name, account_name from `tabAccount` + where name=%s""", (cust_acc), as_dict=1) + + if not customer[0].master_name: + customer_name = webnotes.conn.get_value('Customer', customer[0].account_name, 'name') + else: + customer_name = customer[0].master_name + + webnotes.conn.set_value('POS Setting', pos_name, 'customer', customer_name) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index f2e94d0830..56bd57a41a 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -252,4 +252,5 @@ patch_list = [ "patches.july_2013.p11_update_price_list_currency", "execute:webnotes.bean('Selling Settings').save() #2013-07-29", "patches.august_2013.p01_hr_settings", + "patches.august_2013.p02_pos_setting_replace_customer account_with_customer", ] \ No newline at end of file