From 1bf92fe03444bb8b668f1170b08419653369d751 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 27 Jun 2012 14:50:14 +0530 Subject: [PATCH 1/3] update modified time of GRN while updating QA no in GRN --- .../quality_inspection/quality_inspection.py | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.py b/erpnext/buying/doctype/quality_inspection/quality_inspection.py index 48ab1129d3..4704f967a5 100644 --- a/erpnext/buying/doctype/quality_inspection/quality_inspection.py +++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.py @@ -8,11 +8,11 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # Please edit this list and import only required elements import webnotes @@ -34,30 +34,35 @@ convert_to_lists = webnotes.conn.convert_to_lists class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist + def __init__(self, doc, doclist=[]): + self.doc = doc + self.doclist = doclist - # Autoname - # --------- - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') + # Autoname + # --------- + def autoname(self): + self.doc.name = make_autoname(self.doc.naming_series+'.#####') - def get_item_specification_details(self): - self.doc.clear_table(self.doclist, 'qa_specification_details') - specification = sql("select specification, value from `tabItem Quality Inspection Parameter` where parent = '%s' order by idx" % (self.doc.item_code)) - for d in specification: - child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist) - child.specification = d[0] - child.value = d[1] - child.status = 'Accepted' + def get_item_specification_details(self): + self.doc.clear_table(self.doclist, 'qa_specification_details') + specification = sql("select specification, value from `tabItem Quality Inspection Parameter` \ + where parent = '%s' order by idx" % (self.doc.item_code)) + for d in specification: + child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist) + child.specification = d[0] + child.value = d[1] + child.status = 'Accepted' - def on_submit(self): - if self.doc.purchase_receipt_no: - sql("update `tabPurchase Receipt Item` set qa_no = '%s' where parent = '%s' and item_code = '%s'" % (self.doc.name, self.doc.purchase_receipt_no, self.doc.item_code)) + def on_submit(self): + if self.doc.purchase_receipt_no: + sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \ + where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \ + % (self.doc.name, self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code)) + - - def on_cancel(self): - if self.doc.purchase_receipt_no: - sql("update `tabPurchase Receipt Item` set qa_no = '' where parent = '%s' and item_code = '%s'" % (self.doc.purchase_receipt_no, self.doc.item_code)) + def on_cancel(self): + if self.doc.purchase_receipt_no: + sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \ + where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \ + % (self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code)) \ No newline at end of file From 2c2a17f13880aa2e0ecdfba4b684909b2fa8b3fd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 27 Jun 2012 15:14:58 +0530 Subject: [PATCH 2/3] pull available qty in so and DN in selection of item --- erpnext/selling/doctype/sales_common/sales_common.py | 12 ++++++++++++ erpnext/selling/doctype/sales_order/sales_order.py | 8 +------- erpnext/stock/doctype/delivery_note/delivery_note.js | 2 +- erpnext/stock/doctype/delivery_note/delivery_note.py | 7 +------ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index 94fabeccdc..66d786e963 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -156,6 +156,10 @@ class DocType(TransactionBase): ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate) ret['base_ref_rate'] = flt(base_ref_rate) ret['basic_rate'] = flt(base_ref_rate) + + if ret['warehouse'] or ret['reserved_warehouse']: + av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']}) + ret.update(av_qty) return ret @@ -172,6 +176,14 @@ class DocType(TransactionBase): return ret + def get_available_qty(self,args): + tot_avail_qty = webnotes.conn.sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1) + ret = { + 'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0, + 'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0 + } + return ret + # ***************** Get Ref rate as entered in Item Master ******************** def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate): diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 1c24cfb578..8c09794289 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -116,13 +116,7 @@ class DocType(TransactionBase): # Get projected qty of item based on warehouse selected # ----------------------------------------------------- def get_available_qty(self,args): - args = eval(args) - tot_avail_qty = sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1) - ret = { - 'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0, - 'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0 - } - return ret + return get_obj('Sales Common').get_available_qty(eval(args)) # OTHER CHARGES TRIGGER FUNCTIONS # ==================================================================================== diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index ce5f9ddc70..5242f24fa6 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -175,7 +175,7 @@ cur_frm.cscript.delivery_type = function(doc, cdt, cdn) { if (doc.delivery_type = 'Sample') cfn_set_fields(doc, cdt, cdn); } -cur_frm.cscript.serial_no = function(doc, cdt , cdn) { +cur_frm.cscript.serial_no = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if (d.serial_no) { get_server_fields('get_serial_details',d.serial_no,'delivery_note_details',doc,cdt,cdn,1); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index dce4eaedf6..a7f623c8ab 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -133,12 +133,7 @@ class DocType(TransactionBase): # ********** Get Actual Qty of item in warehouse selected ************* def get_actual_qty(self,args): - args = eval(args) - actual_qty = sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1) - ret = { - 'actual_qty' : actual_qty and flt(actual_qty[0]['actual_qty']) or 0 - } - return ret + return get_obj('Sales Common').get_available_qty(eval(args)) # OTHER CHARGES TRIGGER FUNCTIONS From cbf181c390fbc2c70506ad11c39b28cfbc5f7c8b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Jun 2012 18:38:38 +0530 Subject: [PATCH 3/3] employee list -- show status --- erpnext/hr/doctype/employee/listview.js | 15 ++++++++++++--- .../support/doctype/support_ticket/listview.js | 5 +---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/erpnext/hr/doctype/employee/listview.js b/erpnext/hr/doctype/employee/listview.js index 4f92bbff29..fbd338e99a 100644 --- a/erpnext/hr/doctype/employee/listview.js +++ b/erpnext/hr/doctype/employee/listview.js @@ -12,8 +12,9 @@ wn.doclistviews['Employee'] = wn.views.ListView.extend({ "`tabEmployee`.company", "`tabEmployee`.reports_to", "`tabEmployee`.date_of_joining", + "`tabEmployee`.status", ]); - this.stats = this.stats.concat(['company']); + this.stats = this.stats.concat(['status', 'company']); }, prepare_data: function(data) { @@ -32,14 +33,22 @@ wn.doclistviews['Employee'] = wn.views.ListView.extend({ data.company && concat_list.push(data.company); data.branch && concat_list.push(data.branch); data.description = concat_list.join(", "); + + if(data.status=='Left') { + data.label_type = 'important'; + } else if(data.status=='Active') { + data.label_type = 'success'; + } + data.status_html = repl('%(status)s', data); }, columns: [ {width: '3%', content: 'check'}, - {width: '3%', content: 'docstatus'}, {width: '12%', content: 'name'}, {width: '25%', content: 'employee_name'}, - {width: '45%', content: 'description+tags', + {width: '10%', content: 'status_html'}, + {width: '38%', content: 'description+tags', css: {'color': '#aaa'}}, {width: '12%', content:'date_of_joining', css: {'text-align': 'right', 'color': '#777'}}, diff --git a/erpnext/support/doctype/support_ticket/listview.js b/erpnext/support/doctype/support_ticket/listview.js index eb0ba72551..503e2ab8ba 100644 --- a/erpnext/support/doctype/support_ticket/listview.js +++ b/erpnext/support/doctype/support_ticket/listview.js @@ -29,10 +29,7 @@ wn.doclistviews['Support Ticket'] = wn.views.ListView.extend({ data.status = 'Waiting' } data.status_html = repl('%(status)s', data); - var a = $(data.status_html).click(function() { - me.set_filter('status', $(this).text()); - }); - + // escape double quotes data.description = cstr(data.subject).replace(/"/gi, '\"') + " | " + cstr(data.description).replace(/"/gi, '\"');