From 49e71400acfadfe0b14ec0ada1e4541ffddf88b0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 Oct 2013 15:20:06 +0530 Subject: [PATCH] [patch] [minor] fix wrong customers in pos --- patches/patch_list.py | 1 + .../september_2013/p05_fix_customer_in_pos.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 patches/september_2013/p05_fix_customer_in_pos.py diff --git a/patches/patch_list.py b/patches/patch_list.py index 7041ba8858..6d1a084f68 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -218,4 +218,5 @@ patch_list = [ "execute:webnotes.bean('Style Settings').save() #2013-09-19", "execute:webnotes.conn.set_value('Accounts Settings', None, 'frozen_accounts_modifier', 'Accounts Manager') # 2013-09-24", "patches.september_2013.p04_unsubmit_serial_nos", + "patches.september_2013.p05_fix_customer_in_pos", ] \ No newline at end of file diff --git a/patches/september_2013/p05_fix_customer_in_pos.py b/patches/september_2013/p05_fix_customer_in_pos.py new file mode 100644 index 0000000000..60210dab24 --- /dev/null +++ b/patches/september_2013/p05_fix_customer_in_pos.py @@ -0,0 +1,22 @@ +# 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(): + si_list = webnotes.conn.sql("""select name, debit_to from `tabSales Invoice` + where ifnull(is_pos, 1)=1 and docstatus=1 and modified > '2013-09-03'""", as_dict=1) + + for si in si_list: + if not webnotes.conn.get_value("GL Entry", {"voucher_type": "Sales Invoice", + "voucher_no": si.name, "account": si.debit_to}): + debit_to = webnotes.conn.sql("""select account from `tabGL Entry` gle + where voucher_type='Sales Invoice' and voucher_no=%s + and (select master_type from tabAccount where name=gle.account)='Customer' + """, si.name) + if debit_to: + si_bean = webnotes.bean("Sales Invoice", si.name) + si_bean.doc.debit_to = debit_to[0][0] + si_bean.doc.customer = None + si_bean.run_method("set_customer_defaults") + si_bean.update_after_submit() \ No newline at end of file