[issues #437] [fix] pulling terms and conditions
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index df81b48..2d4de49 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -247,7 +247,7 @@
# 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 @@
"""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 9dcac58..5a84a7e 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 1bb64e5..dfcafed 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -435,7 +435,7 @@
$.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 0e3b5f0..7a27d71 100644
--- a/buying/doctype/purchase_common/purchase_common.py
+++ b/buying/doctype/purchase_common/purchase_common.py
@@ -88,13 +88,6 @@
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 bf59389..d956971 100644
--- a/buying/doctype/purchase_order/purchase_order.py
+++ b/buying/doctype/purchase_order/purchase_order.py
@@ -102,10 +102,6 @@
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 902329b..62dd9a3 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 37e0e3c..bdb31fd 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 303eef3..312fb8e 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -50,12 +50,12 @@
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 @@
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 9004a99..b7df5b6 100644
--- a/public/js/transaction.js
+++ b/public/js/transaction.js
@@ -507,4 +507,18 @@
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 f4c30fc..1151e63 100644
--- a/selling/doctype/quotation/quotation.py
+++ b/selling/doctype/quotation/quotation.py
@@ -95,12 +95,6 @@
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 322be88..48f4255 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 5b391bb..5068ad3 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -81,12 +81,6 @@
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 79b37be..70d209b 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -67,9 +67,6 @@
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 fb5848f..327fadd 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 cb78d45..fa83571 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -91,9 +91,6 @@
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 4504db0..222426c 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 9f19a5b..dfed6c4 100644
--- a/stock/doctype/material_request/material_request.py
+++ b/stock/doctype/material_request/material_request.py
@@ -64,11 +64,6 @@
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 545d40f..3caf3a1 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 bc726c9..f47bdee 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -48,12 +48,6 @@
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 4e055dc..bfc8aa4 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 928aa9f..60403d4 100644
--- a/website/doctype/website_script/website_script.py
+++ b/website/doctype/website_script/website_script.py
@@ -5,4 +5,9 @@
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