From bf3e54a45b806e33cdf61643286b142cba214da8 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 5 Jun 2013 14:11:32 +0530 Subject: [PATCH] [issues #437] [fix] pulling terms and conditions --- accounts/doctype/sales_invoice/sales_invoice.py | 7 +------ accounts/doctype/sales_invoice/sales_invoice.txt | 3 +-- buying/doctype/purchase_common/purchase_common.js | 2 +- buying/doctype/purchase_common/purchase_common.py | 7 ------- buying/doctype/purchase_order/purchase_order.py | 4 ---- buying/doctype/purchase_order/purchase_order.txt | 5 ++--- .../supplier_quotation/supplier_quotation.txt | 5 ++--- controllers/buying_controller.py | 6 +++--- public/js/transaction.js | 14 ++++++++++++++ selling/doctype/quotation/quotation.py | 6 ------ selling/doctype/quotation/quotation.txt | 3 +-- selling/doctype/sales_common/sales_common.py | 6 ------ selling/doctype/sales_order/sales_order.py | 3 --- selling/doctype/sales_order/sales_order.txt | 3 +-- stock/doctype/delivery_note/delivery_note.py | 3 --- stock/doctype/delivery_note/delivery_note.txt | 3 +-- stock/doctype/material_request/material_request.py | 5 ----- .../doctype/material_request/material_request.txt | 5 ++--- stock/doctype/purchase_receipt/purchase_receipt.py | 6 ------ .../doctype/purchase_receipt/purchase_receipt.txt | 5 ++--- website/doctype/website_script/website_script.py | 7 ++++++- 21 files changed, 37 insertions(+), 71 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index df81b48c54..2d4de498ad 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -247,7 +247,7 @@ class DocType(SellingController): # fetch terms if self.doc.tc_name and not self.doc.terms: - self.get_tc_details() + self.doc.terms = webnotes.conn.get_value("Terms and Conditions", self.doc.tc_name, "terms") # fetch charges if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})): @@ -339,11 +339,6 @@ class DocType(SellingController): """Get Commission rate of Sales Partner""" return get_obj('Sales Common').get_comm_rate(sales_partner, self) - - def get_tc_details(self): - return get_obj('Sales Common').get_tc_details(self) - - def get_advances(self): super(DocType, self).get_advances(self.doc.debit_to, "Sales Invoice Advance", "advance_adjustment_details", "credit") diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index 9dcac589a0..5a84a7e206 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.txt +++ b/accounts/doctype/sales_invoice/sales_invoice.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:05", "docstatus": 0, - "modified": "2013-05-29 18:53:26", + "modified": "2013-05-29 18:53:30", "modified_by": "Administrator", "owner": "Administrator" }, @@ -727,7 +727,6 @@ "fieldtype": "Button", "label": "Get Terms and Conditions", "oldfieldtype": "Button", - "options": "get_tc_details", "print_hide": 1, "read_only": 0 }, diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index 1bb64e592c..dfcafed273 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -435,7 +435,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ $.each(field_label_map, function(fname, label) { $wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label); }); - } + }, }); // to save previous state of cur_frm.cscript diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index 0e3b5f02f2..7a27d71490 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -88,13 +88,6 @@ class DocType(BuyingController): msgprint("Supplier : %s does not exists" % (name)) raise Exception - # Get TERMS AND CONDITIONS - # ======================================================================================= - def get_tc_details(self,obj): - r = sql("select terms from `tabTerms and Conditions` where name = %s", obj.doc.tc_name) - if r: obj.doc.terms = r[0][0] - - # Get Available Qty at Warehouse def get_bin_details( self, arg = ''): arg = eval(arg) diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py index bf59389213..d9569711c9 100644 --- a/buying/doctype/purchase_order/purchase_order.py +++ b/buying/doctype/purchase_order/purchase_order.py @@ -102,10 +102,6 @@ class DocType(BuyingController): d.schedule_date = webnotes.conn.get_value("Material Request Item", d.prevdoc_detail_docname, "schedule_date") - def get_tc_details(self): - """get terms & conditions""" - return get_obj('Purchase Common').get_tc_details(self) - def get_last_purchase_rate(self): get_obj('Purchase Common').get_last_purchase_rate(self) diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt index 902329b050..62dd9a3eb1 100644 --- a/buying/doctype/purchase_order/purchase_order.txt +++ b/buying/doctype/purchase_order/purchase_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:39", "docstatus": 0, - "modified": "2013-05-28 12:20:33", + "modified": "2013-05-28 12:20:40", "modified_by": "Administrator", "owner": "Administrator" }, @@ -538,8 +538,7 @@ "fieldname": "get_terms", "fieldtype": "Button", "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "options": "get_tc_details" + "oldfieldtype": "Button" }, { "doctype": "DocField", diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt index 37e0e3c01c..bdb31fd63f 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.txt +++ b/buying/doctype/supplier_quotation/supplier_quotation.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:45", "docstatus": 0, - "modified": "2013-05-28 12:19:41", + "modified": "2013-05-28 12:19:50", "modified_by": "Administrator", "owner": "Administrator" }, @@ -504,8 +504,7 @@ "fieldname": "get_terms", "fieldtype": "Button", "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "options": "get_tc_details" + "oldfieldtype": "Button" }, { "doctype": "DocField", diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 303eef3894..312fb8ed9a 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -50,12 +50,12 @@ class BuyingController(StockController): self.set_missing_item_details(get_item_details) def set_supplier_defaults(self): - self.get_default_supplier_address(self.doc.fields) + self.doc.fields.update(self.get_default_supplier_address(self.doc.fields)) def get_purchase_tax_details(self): self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details") self.set_taxes() - + def validate_warehouse_belongs_to_company(self): for warehouse, company in webnotes.conn.get_values("Warehouse", self.doclist.get_distinct_values("warehouse"), "company").items(): @@ -286,4 +286,4 @@ class BuyingController(StockController): from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \ (", ".join((["%s"]*len(item_codes))),), item_codes)] - return self._purchase_items + return self._purchase_items \ No newline at end of file diff --git a/public/js/transaction.js b/public/js/transaction.js index 9004a999d0..b7df5b6876 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -507,4 +507,18 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({ item[base_field] = flt(item[print_field] * this.frm.doc.conversion_rate, precision(base_field, item)); }, + + get_terms: function() { + var me = this; + if(this.frm.doc.tc_name) { + this.frm.call({ + method: "webnotes.client.get_value", + args: { + doctype: "Terms and Conditions", + fieldname: "terms", + filters: { name: this.frm.doc.tc_name }, + }, + }); + } + }, }); \ No newline at end of file diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py index f4c30fcb93..1151e63de6 100644 --- a/selling/doctype/quotation/quotation.py +++ b/selling/doctype/quotation/quotation.py @@ -95,12 +95,6 @@ class DocType(SellingController): def get_rate(self,arg): return get_obj('Sales Common').get_rate(arg) -# GET TERMS AND CONDITIONS -# ==================================================================================== - def get_tc_details(self): - return get_obj('Sales Common').get_tc_details(self) - - # VALIDATE # ============================================================================================== diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index 322be88b6e..48f4255bda 100644 --- a/selling/doctype/quotation/quotation.txt +++ b/selling/doctype/quotation/quotation.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:08", "docstatus": 0, - "modified": "2013-05-28 14:50:59", + "modified": "2013-05-28 14:51:00", "modified_by": "Administrator", "owner": "Administrator" }, @@ -591,7 +591,6 @@ "fieldtype": "Button", "label": "Get Terms and Conditions", "oldfieldtype": "Button", - "options": "get_tc_details", "read_only": 0 }, { diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 5b391bbd3e..5068ad3b21 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -81,12 +81,6 @@ class DocType(TransactionBase): acc_head = webnotes.conn.sql("select name from `tabAccount` where name = '%s' and docstatus != 2" % (cstr(obj.doc.customer) + " - " + webnotes.conn.get_value('Company', obj.doc.company, 'abbr'))) obj.doc.debit_to = acc_head and acc_head[0][0] or '' - # Get TERMS AND CONDITIONS - # ======================================================================================= - def get_tc_details(self,obj): - r = webnotes.conn.sql("select terms from `tabTerms and Conditions` where name = %s", obj.doc.tc_name) - if r: obj.doc.terms = r[0][0] - #---------------------------------------- Get Tax Details -------------------------------# def get_tax_details(self, item_code, obj): import json diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 79b37be0e5..70d209b1aa 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -67,9 +67,6 @@ class DocType(SellingController): def get_rate(self,arg): return get_obj('Sales Common').get_rate(arg) - def get_tc_details(self): - return get_obj('Sales Common').get_tc_details(self) - def check_maintenance_schedule(self): nm = sql("select t1.name from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1", self.doc.name) nm = nm and nm[0][0] or '' diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt index fb5848f8c3..327fadd633 100644 --- a/selling/doctype/sales_order/sales_order.txt +++ b/selling/doctype/sales_order/sales_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:08", "docstatus": 0, - "modified": "2013-05-28 15:05:38", + "modified": "2013-05-28 15:05:40", "modified_by": "Administrator", "owner": "Administrator" }, @@ -579,7 +579,6 @@ "fieldtype": "Button", "label": "Get Terms and Conditions", "oldfieldtype": "Button", - "options": "get_tc_details", "print_hide": 1 }, { diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index cb78d45897..fa83571578 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -91,9 +91,6 @@ class DocType(SellingController): d.actual_qty = actual_qty and flt(actual_qty[0][0]) or 0 - def get_tc_details(self): - return get_obj('Sales Common').get_tc_details(self) - def get_barcode_details(self, barcode): return get_obj('Sales Common').get_barcode_details(barcode) diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt index 4504db047a..222426ce18 100644 --- a/stock/doctype/delivery_note/delivery_note.txt +++ b/stock/doctype/delivery_note/delivery_note.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:09", "docstatus": 0, - "modified": "2013-05-28 12:26:04", + "modified": "2013-05-28 12:26:10", "modified_by": "Administrator", "owner": "Administrator" }, @@ -602,7 +602,6 @@ "fieldtype": "Button", "label": "Get Terms and Conditions", "oldfieldtype": "Button", - "options": "get_tc_details", "print_hide": 1, "read_only": 0 }, diff --git a/stock/doctype/material_request/material_request.py b/stock/doctype/material_request/material_request.py index 9f19a5b10b..dfed6c4941 100644 --- a/stock/doctype/material_request/material_request.py +++ b/stock/doctype/material_request/material_request.py @@ -64,11 +64,6 @@ class DocType(BuyingController): def validate_fiscal_year(self): get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Material Request Date') - # GET TERMS & CONDITIONS - #----------------------------- - def get_tc_details(self): - return get_obj('Purchase Common').get_tc_details(self) - # Validate Schedule Date #-------------------------------- def validate_schedule_date(self): diff --git a/stock/doctype/material_request/material_request.txt b/stock/doctype/material_request/material_request.txt index 545d40f2fa..3caf3a14ec 100644 --- a/stock/doctype/material_request/material_request.txt +++ b/stock/doctype/material_request/material_request.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-07 14:48:38", "docstatus": 0, - "modified": "2013-04-24 10:47:50", + "modified": "2013-04-24 10:47:55", "modified_by": "Administrator", "owner": "Administrator" }, @@ -311,8 +311,7 @@ "fieldname": "get_terms", "fieldtype": "Button", "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "options": "get_tc_details" + "oldfieldtype": "Button" }, { "doctype": "DocField", diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index bc726c9dcc..f47bdee8f7 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -48,12 +48,6 @@ class DocType(BuyingController): def validate_fiscal_year(self): get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Transaction Date') - # GET TERMS & CONDITIONS - # ===================================================================================== - def get_tc_details(self): - return get_obj('Purchase Common').get_tc_details(self) - - # get available qty at warehouse def get_bin_details(self, arg = ''): return get_obj(dt='Purchase Common').get_bin_details(arg) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt index 4e055dcd54..bfc8aa43ea 100755 --- a/stock/doctype/purchase_receipt/purchase_receipt.txt +++ b/stock/doctype/purchase_receipt/purchase_receipt.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:39", "docstatus": 0, - "modified": "2013-05-28 12:21:17", + "modified": "2013-05-28 12:21:20", "modified_by": "Administrator", "owner": "Administrator" }, @@ -553,8 +553,7 @@ "fieldname": "get_terms", "fieldtype": "Button", "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "options": "get_tc_details" + "oldfieldtype": "Button" }, { "doctype": "DocField", diff --git a/website/doctype/website_script/website_script.py b/website/doctype/website_script/website_script.py index 928aa9ff9f..60403d42d3 100644 --- a/website/doctype/website_script/website_script.py +++ b/website/doctype/website_script/website_script.py @@ -5,4 +5,9 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + + def on_update(self): + # make js and css + from website.helpers.make_web_include_files import make + make() \ No newline at end of file