Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
a0aa3d5605
@ -18,8 +18,8 @@ cur_frm.cscript.onload = function(doc,dt,dn) {
|
||||
if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
|
||||
if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()});
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
if(!doc.currency && sys_defaults.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
|
||||
if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
|
||||
if(!doc.currency && sys_defaults.currency) set_multiple(dt,dn,{currency:sys_defaults.currency});
|
||||
if(!doc.price_list_currency) set_multiple(dt, dn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
|
||||
|
||||
//for previously created sales invoice, set required field related to pos
|
||||
if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn);
|
||||
|
@ -53,7 +53,7 @@ cur_frm.cscript.uom = function(doc, cdt, cdn) {
|
||||
call_back = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.calc_amount(doc, 2);
|
||||
}
|
||||
str_arg = {'item_code':d.item_code, 'uom':d.uom, 'stock_qty':flt(d.stock_qty), 'qty': flt(d.qty)}
|
||||
str_arg = {'item_code':d.item_code, 'uom':d.uom, 'stock_qty':flt(d.stock_qty), 'qty': flt(d.qty), 'conversion_rate':doc.conversion_rate}
|
||||
// Updates Conversion Factor, Qty and Purchase Rate
|
||||
get_server_fields('get_uom_details',JSON.stringify(str_arg), fname, doc,cdt,cdn,1, call_back);
|
||||
// don't make mistake of calling update_stock_qty() the get_uom_details returns stock_qty as per conversion factor properly
|
||||
|
@ -165,8 +165,8 @@ class DocType(TransactionBase):
|
||||
'qty' : flt(arg['stock_qty']) / flt(uom[0]['conversion_factor']),
|
||||
'purchase_ref_rate' : (lpr and flt(lpr[0]['last_purchase_rate']) * flt(uom[0]['conversion_factor'])) or 0,
|
||||
'purchase_rate' : (lpr and flt(lpr[0]['last_purchase_rate']) * flt(uom[0]['conversion_factor'])) or 0,
|
||||
'import_ref_rate' : (lpr and flt(lpr[0]['last_purchase_rate']) * flt(uom[0]['conversion_factor'])/flt(self.doc.conversion_rate)) or 0,
|
||||
'import_rate' : (lpr and flt(lpr[0]['last_purchase_rate']) * flt(uom[0]['conversion_factor'])/flt(self.doc.conversion_rate)) or 0
|
||||
'import_ref_rate' : (lpr and flt(lpr[0]['last_purchase_rate']) * flt(uom[0]['conversion_factor'])/flt(arg['conversion_rate'])) or 0,
|
||||
'import_rate' : (lpr and flt(lpr[0]['last_purchase_rate']) * flt(uom[0]['conversion_factor'])/flt(arg['conversion_rate'])) or 0
|
||||
}
|
||||
|
||||
return ret
|
||||
|
4
erpnext/patches/delete_pur_of_service.py
Normal file
4
erpnext/patches/delete_pur_of_service.py
Normal file
@ -0,0 +1,4 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.model import delete_doc
|
||||
delete_doc('DocType', 'Purpose of Service')
|
58
erpnext/patches/pending_patches.py
Normal file
58
erpnext/patches/pending_patches.py
Normal file
@ -0,0 +1,58 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.modules.module_manager import reload_doc
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
reload_doc('hr', 'doctype', 'appraisal')
|
||||
reload_doc('hr', 'doctype', 'appraisal_detail')
|
||||
|
||||
sql("update `tabDocField` set `hidden` = 0 where fieldname = 'group_or_ledger' and parent = 'Cost Center'")
|
||||
sql("update tabDocPerm set amend = 0 where parent = 'Salary Structure'")
|
||||
sql("update tabDocPerm set cancel = 1 where parent = 'Company' and role = 'System Manager'")
|
||||
|
||||
if sql("select count(name) from `tabDocField` where label = 'View Ledger Entry' and parent = 'Journal Voucher' and fieldtype = 'Button'")[0][0] > 1:
|
||||
sql("delete from `tabDocField` where label = 'View Ledger Entry' and parent = 'Journal Voucher' and fieldtype = 'Button' limit 1")
|
||||
if sql("select count(name) from `tabDocField` where label = 'Get Balance' and parent = 'Journal Voucher' and fieldtype = 'Button'")[0][0] > 1:
|
||||
sql("delete from `tabDocField` where label = 'Get Balance' and parent = 'Journal Voucher' and fieldtype = 'Button' limit 1")
|
||||
|
||||
reload_doc('accounts', 'doctype', 'internal_reconciliation')
|
||||
reload_doc('accounts', 'doctype', 'ir_payment_detail')
|
||||
reload_doc('accounts', 'Module Def', 'Accounts')
|
||||
|
||||
|
||||
|
||||
if sql("select count(name) from `tabDocField` where label = 'Get Specification Details' and parent = 'QA Inspection Report' and fieldtype = 'Button'")[0][0] > 1:
|
||||
sql("delete from `tabDocField` where label = 'Get Specification Details' and parent = 'QA Inspection Report' and fieldtype = 'Button' limit 1")
|
||||
|
||||
reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')
|
||||
|
||||
reload_doc('accounts', 'doctype', 'cost_center')
|
||||
reload_doc('stock', 'Module Def', 'Stock')
|
||||
sql("delete from `tabModule Def Item` where display_name = 'Serial No' and parent = 'Support'")
|
||||
sql("update `tabDocType` set subject = 'Item Code: %(item_code)s, Warehouse: %(warehouse)s' where name = 'Serial No'")
|
||||
|
||||
# Patch for adding packing related columns (packed by, checked by, shipping mark etc)
|
||||
reload_doc('stock','doctype','delivery_note')
|
||||
sql("update `tabDocField` set allow_on_submit = 1 where fieldname = 'page_break'")
|
||||
sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('indent_details', 'po_details', 'purchase_receipt_details', 'entries', 'sales_order_details', 'delivery_note_details', 'quotation_details') and fieldtype = 'Table'")
|
||||
|
||||
from webnotes.session_cache import clear_cache
|
||||
clear_cache(webnotes.session['user'])
|
||||
|
||||
# FEATURES SETUP
|
||||
#----------------
|
||||
reload_doc('setup', 'doctype','features_setup')
|
||||
flds = ['page_break', 'projects', 'packing_details', 'discounts', 'brands', 'item_batch_nos', 'after_sales_installations', 'item_searial_nos', 'item_group_in_details', 'exports', 'imports', 'item_advanced', 'sales_extras', 'more_info', 'quality', 'manufacturing', 'pos', 'item_serial_nos']
|
||||
st = "'"+"', '".join(flds)+"'"
|
||||
sql("delete from `tabSingles` where field in (%s) and doctype = 'Features Setup'" % st)
|
||||
sql("delete from `tabDocField` where fieldname in (%s) and parent = 'Features Setup'" % st)
|
||||
sql("delete from `tabDefaultValue` where defkey in (%s) and parent = 'Control Panel'" % st)
|
||||
|
||||
if not sql("select * from `tabDefaultValue` where defkey like 'fs_%' and parent = 'Control Panel'"):
|
||||
rs = sql("select fieldname from tabDocField where parent='Features Setup' and fieldname is not null")
|
||||
fs = get_obj('Features Setup', 'Features Setup')
|
||||
for d in rs:
|
||||
fs.doc.fields[d[0]] = 1
|
||||
fs.doc.save()
|
||||
fs.validate()
|
6
erpnext/patches/pos_setting_patch.py
Normal file
6
erpnext/patches/pos_setting_patch.py
Normal file
@ -0,0 +1,6 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
webnotes.conn.sql("update `tabDocField` set `default` = 1 where fieldname = 'conversion_rate' and parent = 'POS Setting'")
|
||||
|
||||
from webnotes.model import delete_doc
|
||||
delete_doc('DocType', 'POS Settings')
|
4
erpnext/patches/reload_doctype.py
Normal file
4
erpnext/patches/reload_doctype.py
Normal file
@ -0,0 +1,4 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.modules.module_manager import reload_doc
|
||||
reload_doc('core', 'doctype', 'doctype')
|
4
erpnext/patches/reload_po_pr_mapper.py
Normal file
4
erpnext/patches/reload_po_pr_mapper.py
Normal file
@ -0,0 +1,4 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.modules.module_manager import reload_doc
|
||||
reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')
|
@ -130,6 +130,7 @@ def sent_reminder_task():
|
||||
msg2="""<h2>Two days to complete: %(name)s</h2>
|
||||
<p>This is a reminder for the task %(name)s has been assigned to you
|
||||
by %(senders_name)s on %(opening_date)s</p>
|
||||
<p><b>Subject:</b> %(subject)s </p>
|
||||
<p><b>Project:</b> %(project)s</p>
|
||||
<p><b>Expected Start Date:</b> %(exp_start_date)s</p>
|
||||
<p><b>Expected End Date:</b> %(exp_end_date)s</p>
|
||||
|
@ -97,6 +97,7 @@ class DocType:
|
||||
'opening_date': self.doc.opening_date,
|
||||
'exp_start_date': self.doc.exp_start_date,
|
||||
'exp_end_date' : self.doc.exp_end_date,
|
||||
'subject' : self.doc.subject,
|
||||
'project': self.doc.project,
|
||||
'review_date': self.doc.review_date,
|
||||
'description': self.doc.description
|
||||
@ -105,6 +106,7 @@ class DocType:
|
||||
msg2="""<h2>%(name)s</h2>
|
||||
<p>This is a Notification for the task %(name)s that has been assigned to you
|
||||
by %(senders_name)s on %(opening_date)s</p>
|
||||
<p><b>Subject:</b> %(subject)s </p>
|
||||
<p><b>Project:</b> %(project)s</p>
|
||||
<p><b>Review Date:</b> %(review_date)s</p>
|
||||
<p><b>Expected Start Date:</b> %(exp_start_date)s</p>
|
||||
|
@ -42,16 +42,16 @@ class DocType:
|
||||
def_list = [['fiscal_year',self.doc.current_fiscal_year],
|
||||
['company',self.doc.default_company],
|
||||
['currency',self.doc.default_currency],
|
||||
['price_list_name',self.doc.default_price_list],
|
||||
['price_list_currency', self.doc.default_price_list_currency],
|
||||
['item_group',self.doc.default_item_group],
|
||||
['customer_group',self.doc.default_customer_group],
|
||||
['cust_master_name',self.doc.cust_master_name],
|
||||
['supplier_type',self.doc.default_supplier_type],
|
||||
['price_list_name',self.doc.default_price_list or ''],
|
||||
['price_list_currency', self.doc.default_price_list_currency or ''],
|
||||
['item_group',self.doc.default_item_group or ''],
|
||||
['customer_group',self.doc.default_customer_group or ''],
|
||||
['cust_master_name',self.doc.cust_master_name or ''],
|
||||
['supplier_type',self.doc.default_supplier_type or ''],
|
||||
['supp_master_name',self.doc.supp_master_name],
|
||||
['territory',self.doc.default_territory],
|
||||
['stock_uom',self.doc.default_stock_uom],
|
||||
['fraction_currency',self.doc.default_currency_fraction],
|
||||
['territory',self.doc.default_territory or ''],
|
||||
['stock_uom',self.doc.default_stock_uom or ''],
|
||||
['fraction_currency',self.doc.default_currency_fraction or ''],
|
||||
['valuation_method',self.doc.default_valuation_method]]
|
||||
|
||||
for d in def_list:
|
||||
|
@ -82,9 +82,12 @@ class DocType:
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
def update_series_start(self):
|
||||
if self.doc.prefix:
|
||||
ser_det = sql("select name from `tabSeries` where name = %s", self.doc.prefix)
|
||||
if ser_det:
|
||||
sql("update `tabSeries` set current = '%s' where name = '%s'" % (self.doc.starts_from-1,self.doc.prefix))
|
||||
else:
|
||||
sql("insert into tabSeries (name, current) values (%s,%s)",(cstr(self.doc.prefix),cint(self.doc.starts_from)-1))
|
||||
msgprint("Series Updated Successfully")
|
||||
else:
|
||||
msgprint("Please select prefix first")
|
||||
|
@ -168,7 +168,7 @@ SetupData = function(cnty){
|
||||
['Manage Trash',2,'Trash','','Restore trashed items'],
|
||||
['Import Data',2,'Import Data','','Import data from CSV files'],
|
||||
['Manage Users',2,'My Company','','Add / remove users and manage their roles'],
|
||||
['Web Forms',2,'Webforms','', 'Code to embed forms in yor website'],
|
||||
//['Web Forms',2,'Webforms','', 'Code to embed forms in yor website'],
|
||||
['Permissions Manager',2,'Permission Engine','', 'Manage all permissions from one tool'],
|
||||
//['Property Setter',1,'Property Setter','', 'Customize properties of a Form (DocType) or Field'],
|
||||
['Customize Form View',3,'DocLayer','', 'Customize properties of a Form (DocType) or Field'],
|
||||
@ -235,8 +235,7 @@ SetupData = function(cnty){
|
||||
this.buying = {'Buying':[['Supplier Type',1,'Supplier Type','','Manage supplier classifications'],
|
||||
['Supplier',1,'Supplier','id'+NEWLINE+'supplier_type'+NEWLINE+'supplier_status'+NEWLINE+'company','Supplier master']]};
|
||||
|
||||
this.maintenance = {'Maintenance':[['Serial No',1,'Serial No','item_code'+NEWLINE+'status'+NEWLINE+'pr_no'+NEWLINE+'delivery_note_no'+NEWLINE+'customer_name','Manage unique serial numbers for items'],
|
||||
['Purpose of Service',1,'Purpose of Service','','Purpose of service master']]};
|
||||
this.maintenance = {'Maintenance':[['Serial No',1,'Serial No','item_code'+NEWLINE+'status'+NEWLINE+'pr_no'+NEWLINE+'delivery_note_no'+NEWLINE+'customer_name','Manage unique serial numbers for items']]};
|
||||
|
||||
this.production = {'Production':[['Bill of Materials',1,'Bill Of Materials','id'+NEWLINE+'item'+NEWLINE+'description'+NEWLINE+'operating_cost'+NEWLINE+'maintained_by','Muti-level bill of materials and operations'],
|
||||
['Workstation',1,'Workstation','id'+NEWLINE+'workstation_name'+NEWLINE+'warehouse'+NEWLINE+'description','Workstation master']]};
|
||||
|
@ -5,7 +5,7 @@
|
||||
{
|
||||
'creation': '2010-08-08 17:09:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-10-12 10:49:40',
|
||||
'modified': '2012-01-05 11:21:23',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
@ -22,7 +22,6 @@
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'name': '__common__',
|
||||
'parent': 'Purchase Order-Purchase Receipt',
|
||||
'parentfield': 'field_mapper_details',
|
||||
@ -50,6 +49,7 @@
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'supplier',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'supplier'
|
||||
},
|
||||
@ -59,6 +59,7 @@
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'company',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'company'
|
||||
},
|
||||
@ -68,6 +69,7 @@
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'currency',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'currency'
|
||||
},
|
||||
@ -76,6 +78,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'prevdoc_detail_docname'
|
||||
},
|
||||
@ -84,6 +87,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'prevdoc_docname'
|
||||
},
|
||||
@ -92,6 +96,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parenttype',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'prevdoc_doctype'
|
||||
},
|
||||
@ -101,6 +106,7 @@
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'item_code',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'item_code'
|
||||
},
|
||||
@ -109,6 +115,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) ',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'received_qty'
|
||||
},
|
||||
@ -117,6 +124,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) ',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'qty'
|
||||
},
|
||||
@ -125,6 +133,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.conversion_factor)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'stock_qty'
|
||||
},
|
||||
@ -133,6 +142,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.import_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'import_amount'
|
||||
},
|
||||
@ -141,6 +151,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.purchase_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'amount'
|
||||
},
|
||||
@ -149,6 +160,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'schedule_date',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'schedule_date'
|
||||
},
|
||||
@ -157,6 +169,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'net_total',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'net_total'
|
||||
},
|
||||
@ -165,6 +178,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'grand_total',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'grand_total'
|
||||
},
|
||||
@ -173,10 +187,20 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'total_tax',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'total_tax'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'transaction_date',
|
||||
'map': 'No',
|
||||
'match_id': 0,
|
||||
'to_field': 'transaction_date'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
|
@ -307,7 +307,6 @@ class DocType:
|
||||
# item re-order
|
||||
# -------------
|
||||
def reorder_item(self,doc_type,doc_name):
|
||||
msgprint(get_value('Manage Account', None, 'auto_indent'))
|
||||
if get_value('Manage Account', None, 'auto_indent'):
|
||||
#check if re-order is required
|
||||
indent_detail_fields = sql("select re_order_level,item_name,description,brand,item_group,lead_time_days,min_order_qty,email_notify from tabItem where item_code = %s",(self.doc.item_code),as_dict=1)
|
||||
@ -331,7 +330,7 @@ class DocType:
|
||||
indent_details_child.item_code = self.doc.item_code
|
||||
indent_details_child.uom = self.doc.stock_uom
|
||||
indent_details_child.warehouse = self.doc.warehouse
|
||||
indent_details_child.schedule_date= add_days(nowdate(),i['lead_time_days'])
|
||||
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
|
||||
indent_details_child.item_name = i['item_name']
|
||||
indent_details_child.description = i['description']
|
||||
indent_details_child.item_group = i['item_group']
|
||||
|
@ -15,14 +15,14 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
if(!doc.transaction_date) set_multiple(dt,dn,{transaction_date:get_today()});
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
if(doc.__islocal && doc.customer) cur_frm.cscript.pull_item_details_onload(doc,dt,dn);
|
||||
if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
|
||||
|
||||
if(!doc.price_list_currency) {
|
||||
set_multiple(dt, dn, {price_list_currency: doc.currency, plc_conversion_rate:1});
|
||||
}
|
||||
if(!doc.posting_time) doc.posting_time = wn.datetime.get_cur_time()
|
||||
|
||||
if(doc.__islocal){
|
||||
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
@ -34,7 +34,6 @@ cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
// REFRESH
|
||||
// ================================================================================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.clear_custom_buttons();
|
||||
|
||||
if(doc.per_billed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
|
||||
|
@ -46,14 +46,15 @@ class DocType(TransactionBase):
|
||||
import datetime
|
||||
self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
||||
count = 0
|
||||
sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name))
|
||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||
self.validate_maintenance_detail()
|
||||
s_list =[]
|
||||
s_list = self.create_schedule_list(d.start_date, d.end_date, d.no_of_visits)
|
||||
|
||||
for i in range(d.no_of_visits):
|
||||
child = addchild(self.doc,'maintenance_schedule_detail','Maintenance Schedule Detail',1,self.doclist)
|
||||
child.item_code = d.item_code
|
||||
child.item_name = d.item_name
|
||||
child.scheduled_date = s_list[i].strftime('%Y-%m-%d')
|
||||
if d.serial_no:
|
||||
child.serial_no = d.serial_no
|
||||
@ -61,8 +62,51 @@ class DocType(TransactionBase):
|
||||
count = count+1
|
||||
child.incharge_name = d.incharge_name
|
||||
child.save(1)
|
||||
|
||||
self.on_update()
|
||||
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
if not getlist(self.doclist, 'maintenance_schedule_detail'):
|
||||
msgprint("Please click on 'Generate Schedule' to get schedule")
|
||||
raise Exception
|
||||
self.check_serial_no_added()
|
||||
self.validate_serial_no_warranty()
|
||||
self.validate_schedule()
|
||||
|
||||
email_map ={}
|
||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||
if d.serial_no:
|
||||
self.update_amc_date(d.serial_no, d.end_date)
|
||||
|
||||
if d.incharge_name not in email_map:
|
||||
e = sql("select email_id, name from `tabSales Person` where name='%s' " %(d.incharge_name),as_dict=1)[0]
|
||||
email_map[d.incharge_name] = (e['email_id'])
|
||||
|
||||
scheduled_date =sql("select scheduled_date from `tabMaintenance Schedule Detail` \
|
||||
where incharge_name='%s' and item_code='%s' and parent='%s' " %(d.incharge_name, \
|
||||
d.item_code, self.doc.name), as_dict=1, debug=1)
|
||||
|
||||
for key in scheduled_date:
|
||||
if email_map[d.incharge_name]:
|
||||
self.add_calender_event(key["scheduled_date"],email_map[d.incharge_name],d.item_code)
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
|
||||
def add_calender_event(self,scheduled_date,incharge_email,item_code):
|
||||
""" Add calendar event for Maintenece Schedule in calendar of Allocated person"""
|
||||
event = Document('Event')
|
||||
event.owner = incharge_email
|
||||
event.description = "Item Code:%s and Reference:%s" %(item_code,self.doc.name)
|
||||
event.event_date = scheduled_date
|
||||
event.event_hour = '10:00'
|
||||
event.event_type = 'Private'
|
||||
event.ref_type = 'Maintenance Schedule'
|
||||
event.ref_name = self.doc.name
|
||||
event.save(1)
|
||||
|
||||
|
||||
#get schedule dates
|
||||
#----------------------
|
||||
def create_schedule_list(self, start_date, end_date, no_of_visit):
|
||||
@ -97,6 +141,8 @@ class DocType(TransactionBase):
|
||||
msgprint("Weekly periodicity can be set for period of atleast 1 week or more")
|
||||
raise Exception
|
||||
|
||||
|
||||
|
||||
#get count on the basis of periodicity selected
|
||||
#----------------------------------------------------
|
||||
def get_no_of_visits(self, arg):
|
||||
@ -121,6 +167,8 @@ class DocType(TransactionBase):
|
||||
ret = {'no_of_visits':count}
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
def validate_maintenance_detail(self):
|
||||
if not getlist(self.doclist, 'item_maintenance_detail'):
|
||||
msgprint("Please enter Maintaince Details first")
|
||||
@ -269,17 +317,6 @@ class DocType(TransactionBase):
|
||||
msgprint("Please click on 'Generate Schedule' to fetch serial no added for item "+m.item_code)
|
||||
raise Exception
|
||||
|
||||
def on_submit(self):
|
||||
if not getlist(self.doclist, 'maintenance_schedule_detail'):
|
||||
msgprint("Please click on 'Generate Schedule' to get schedule")
|
||||
raise Exception
|
||||
self.check_serial_no_added()
|
||||
self.validate_serial_no_warranty()
|
||||
self.validate_schedule()
|
||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||
if d.serial_no:
|
||||
self.update_amc_date(d.serial_no, d.end_date)
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
|
||||
def on_cancel(self):
|
||||
@ -287,3 +324,8 @@ class DocType(TransactionBase):
|
||||
if d.serial_no:
|
||||
self.update_amc_date(d.serial_no, '')
|
||||
set(self.doc, 'status', 'Cancelled')
|
||||
sql("delete from `tabEvent` where ref_type='Maintenance Schedule' and ref_name='%s' " %(self.doc.name))
|
||||
def on_trash(self):
|
||||
sql("delete from `tabEvent` where ref_type='Maintenance Schedule' and ref_name='%s' " %(self.doc.name))
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user