Fix in Purchase Return - Serial No. status issue

This commit is contained in:
Anand Doshi 2012-01-31 16:20:37 +05:30
parent 6c95ccb8f5
commit 0717ca63b2
5 changed files with 33 additions and 6 deletions

View File

@ -0,0 +1,18 @@
def execute():
import webnotes
opts = webnotes.conn.sql("""\
SELECT options FROM `tabDocField`
WHERE parent='Serial No' AND fieldname='status' AND
fieldtype='Select'""")
if opts and opts[0][0]:
opt_list = opts[0][0].split("\n")
if not "Purchase Returned" in opt_list:
webnotes.conn.sql("""
UPDATE `tabDocField` SET options=%s
WHERE parent='Serial No' AND fieldname='status' AND
fieldtype='Select'""", "\n".join(opt_list + ["Purchase Returned"]))
webnotes.conn.commit()
webnotes.conn.begin()
from webnotes.modules.module_manager import reload_doc
reload_doc('stock', 'doctype', 'serial_no')

View File

@ -50,4 +50,9 @@ patch_list = [
'patch_file': 'email_settings_reload', 'patch_file': 'email_settings_reload',
'description': "Change type of mail_port field to Int and reload email_settings doctype" 'description': "Change type of mail_port field to Int and reload email_settings doctype"
}, },
{
'patch_module': 'patches.jan_mar_2012',
'patch_file': 'serial_no_add_opt',
'description': "Add option 'Purchase Returned' to Serial No status field"
},
] ]

View File

@ -5,14 +5,14 @@
{ {
'creation': '2010-08-08 17:09:23', 'creation': '2010-08-08 17:09:23',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-10-10 17:08:57', 'modified': '2012-01-31 15:53:38',
'modified_by': 'Administrator', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },
# These values are common for all DocType # These values are common for all DocType
{ {
'_last_update': '1317365120', '_last_update': '1325570647',
'allow_trash': 1, 'allow_trash': 1,
'autoname': 'field:serial_no', 'autoname': 'field:serial_no',
'colour': 'White:FFF', 'colour': 'White:FFF',
@ -25,8 +25,9 @@
'section_style': 'Tabbed', 'section_style': 'Tabbed',
'server_code_error': ' ', 'server_code_error': ' ',
'show_in_menu': 0, 'show_in_menu': 0,
'subject': 'Item Code: %(item_code)s, Warehouse: %(warehouse)s',
'tag_fields': 'status', 'tag_fields': 'status',
'version': 190 'version': 191
}, },
# These values are common for all DocField # These values are common for all DocField
@ -163,7 +164,7 @@
'no_copy': 1, 'no_copy': 1,
'oldfieldname': 'status', 'oldfieldname': 'status',
'oldfieldtype': 'Select', 'oldfieldtype': 'Select',
'options': '\nIn Store\nDelivered\nNot in Use', 'options': '\nIn Store\nDelivered\nNot in Use\nPurchase Returned',
'permlevel': 1, 'permlevel': 1,
'reqd': 1, 'reqd': 1,
'search_index': 1 'search_index': 1

View File

@ -435,7 +435,10 @@ class DocType:
sl_obj.update_serial_purchase_details(self, d, serial_no, is_submit, self.doc.purpose) sl_obj.update_serial_purchase_details(self, d, serial_no, is_submit, self.doc.purpose)
if self.doc.purpose == 'Purchase Return': if self.doc.purpose == 'Purchase Return':
delete_doc("Serial No", serial_no) #delete_doc("Serial No", serial_no)
serial_doc = Document("Serial No", serial_no)
serial_doc.status = 'Purchase Returned'
serial_doc.save()
def on_submit(self): def on_submit(self):

View File

@ -26,7 +26,7 @@ for r in res:
lft_rgt = sql("select lft, rgt from `tab%s` where name = '%s'" % (opt,r[col_idx[opt]].strip())) lft_rgt = sql("select lft, rgt from `tab%s` where name = '%s'" % (opt,r[col_idx[opt]].strip()))
det = sql("select COUNT(CASE WHEN t1.amc_expiry_date < '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.amc_expiry_date >= '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.warranty_expiry_date < '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.warranty_expiry_date >= '%s' THEN t1.name ELSE NULL END) from `tabSerial No` t1, `tab%s` t2 where t1.%s = t2.name and t2.lft>= '%s' and t2. rgt <= '%s' and t1.status not in ('In Store', 'Scrapped','Not in Use') and ifnull(item_group,'')!='' and ifnull(territory,'')!=''" %(nowdate,nowdate,nowdate,nowdate,opt, opt_dict[opt], lft_rgt[0][0], lft_rgt[0][1])) det = sql("select COUNT(CASE WHEN t1.amc_expiry_date < '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.amc_expiry_date >= '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.warranty_expiry_date < '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.warranty_expiry_date >= '%s' THEN t1.name ELSE NULL END) from `tabSerial No` t1, `tab%s` t2 where t1.%s = t2.name and t2.lft>= '%s' and t2. rgt <= '%s' and t1.status = 'Delivered' and ifnull(item_group,'')!='' and ifnull(territory,'')!=''" %(nowdate,nowdate,nowdate,nowdate,opt, opt_dict[opt], lft_rgt[0][0], lft_rgt[0][1]))
r.append(cint(det[0][0])) r.append(cint(det[0][0]))
r.append(cint(det[0][1])) r.append(cint(det[0][1]))