validation fixes in mantenance schedule and error fixes in setting serial no warranty expiry date

This commit is contained in:
Nabin Hait 2013-01-24 13:23:20 +05:30
parent a89e1c7040
commit 1290284c80
2 changed files with 26 additions and 28 deletions

View File

@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cstr, flt, nowdate
from webnotes.utils import add_days, cstr, flt, nowdate, cint
from webnotes.model.doc import Document
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
@ -149,17 +149,18 @@ class DocType:
s = Document('Serial No', serial_no)
s.delivery_document_type = obj.doc.doctype
s.delivery_document_no = obj.doc.name
s.delivery_date = obj.doc.posting_date
s.delivery_time = obj.doc.posting_time
s.customer = obj.doc.customer
s.customer_name = obj.doc.customer_name
s.delivery_address = obj.doc.address_display
s.territory = obj.doc.territory
s.warranty_expiry_date = s.warranty_period and add_days(cstr(obj.doc.posting_date), s.warranty_period) or ''
s.docstatus = 1
s.status = 'Delivered'
s.modified = nowdate()
s.modified_by = session['user']
s.delivery_date = obj.doc.posting_date
s.delivery_time = obj.doc.posting_time
s.customer = obj.doc.customer
s.customer_name = obj.doc.customer_name
s.delivery_address = obj.doc.address_display
s.territory = obj.doc.territory
s.warranty_expiry_date = cint(s.warranty_period) and \
add_days(cstr(obj.doc.posting_date), cint(s.warranty_period)) or s.warranty_expiry_date
s.docstatus = 1
s.status = 'Delivered'
s.modified = nowdate()
s.modified_by = session['user']
s.save()

View File

@ -277,24 +277,21 @@ class DocType(TransactionBase):
def on_update(self):
webnotes.conn.set(self.doc, 'status', 'Draft')
#validate that new maintenance start date does not clash with existing mntc end date
#-------------------------------------------------------------------------------------------------
def validate_serial_no_warranty(self):
for d in getlist(self.doclist, 'item_maintenance_detail'):
if d.serial_no:
dt = sql("select warranty_expiry_date, amc_expiry_date from `tabSerial No` where name = %s", d.serial_no, as_dict=1)
if d.serial_no.strip():
dt = sql("""select warranty_expiry_date, amc_expiry_date
from `tabSerial No` where name = %s""", d.serial_no, as_dict=1)
if dt[0]['warranty_expiry_date'] and dt[0]['warranty_expiry_date'] >= d.start_date:
webnotes.msgprint("""Serial No: %s is already under warranty upto %s.
Please check AMC Start Date.""" %
(d.serial_no, dt[0]["warranty_expiry_date"]), raise_exception=1)
if dt[0]['warranty_expiry_date']:
if dt[0]['warranty_expiry_date'] >= getdate(d.start_date):
msgprint("Serial no "+d.serial_no+" for item "+d.item_code+" is already under warranty till "+(dt[0]['warranty_expiry_date']).strftime('%Y-%m-%d')+". You can schedule AMC start date after "+(dt[0]['warranty_expiry_date']).strftime('%Y-%m-%d'))
raise Exception
if dt[0]['amc_expiry_date']:
if dt[0]['amc_expiry_date'] >= getdate(d.start_date):
msgprint("Serial no "+d.serial_no+" for item "+d.item_code+" is already under AMC till "+(dt[0]['amc_expiry_date']).strftime('%Y-%m-%d')+". You can schedule new AMC start date after "+(dt[0]['amc_expiry_date']).strftime('%Y-%m-%d'))
raise Exception
if dt[0]['amc_expiry_date'] and dt[0]['amc_expiry_date'] >= d.start_date:
webnotes.msgprint("""Serial No: %s is already under AMC upto %s.
Please check AMC Start Date.""" %
(d.serial_no, sr[0]["amc_expiry_date"]), raise_exception=1)
#validate if schedule generated for all items
#-------------------------------------------------
def validate_schedule(self):
item_lst1 =[]
item_lst2 =[]