[patch] [minor] fix wrong customers in pos

This commit is contained in:
Nabin Hait 2013-10-01 15:20:06 +05:30
parent cde7f829d6
commit 49e71400ac
2 changed files with 23 additions and 0 deletions

View File

@ -218,4 +218,5 @@ patch_list = [
"execute:webnotes.bean('Style Settings').save() #2013-09-19", "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", "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.p04_unsubmit_serial_nos",
"patches.september_2013.p05_fix_customer_in_pos",
] ]

View File

@ -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()