[pull-mappers] no fields via custom button, started with quotation, material request, purchase order

This commit is contained in:
Rushabh Mehta
2013-07-08 15:52:24 +05:30
parent 11eda08cd5
commit 862a02b8d2
12 changed files with 123 additions and 269 deletions

View File

@@ -53,6 +53,25 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
}
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
}
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(wn._('From Opportunity'),
function() {
wn.model.map_current_doc({
method: "selling.doctype.opportunity.opportunity.make_quotation",
source_doctype: "Opportunity",
get_query_filters: {
docstatus: 1,
status: "Submitted",
enquiry_type: cur_frm.doc.order_type,
customer: cur_frm.doc.customer || undefined,
lead: cur_frm.doc.lead || undefined,
company: cur_frm.doc.company
}
})
});
}
if (!doc.__islocal) {
cur_frm.communication_view = new wn.views.CommunicationList({
@@ -70,6 +89,10 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
},
tc_name: function() {
this.get_terms();
},
validate_company_and_party: function(party_field) {
if(this.frm.doc.quotation_to == "Lead") {
@@ -113,17 +136,6 @@ cur_frm.cscript.lead = function(doc, cdt, cdn) {
}
// =====================================================================================
cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){
var cond='';
var cond1='';
if(doc.order_type) cond = 'ifnull(`tabOpportunity`.enquiry_type, "") = "'+doc.order_type+'" AND';
if(doc.customer) cond1 = '`tabOpportunity`.customer = "'+doc.customer+'" AND';
else if(doc.lead) cond1 = '`tabOpportunity`.lead = "'+doc.lead+'" AND';
return repl('SELECT `tabOpportunity`.`name` FROM `tabOpportunity` WHERE `tabOpportunity`.`docstatus` = 1 AND `tabOpportunity`.status = "Submitted" AND %(cond)s %(cond1)s `tabOpportunity`.`name` LIKE "%s" ORDER BY `tabOpportunity`.`name` ASC LIMIT 50', {cond:cond, cond1:cond1});
}
// Make Sales Order
// =====================================================================================
cur_frm.cscript['Make Sales Order'] = function() {
@@ -133,14 +145,6 @@ cur_frm.cscript['Make Sales Order'] = function() {
})
}
//pull enquiry details
cur_frm.cscript.pull_enquiry_detail = function(doc,cdt,cdn){
wn.model.map_current_doc({
method: "selling.doctype.opportunity.opportunity.make_quotation",
source_name: cur_frm.doc.enq_no,
})
}
// declare order lost
//-------------------------
cur_frm.cscript['Declare Order Lost'] = function(){

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
"modified": "2013-07-05 14:52:37",
"modified": "2013-07-08 15:51:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -344,42 +344,6 @@
"fieldtype": "Section Break",
"read_only": 0
},
{
"description": "To create Quotation against Opportunity, Select Opportunity No. and click on 'Pull Opportunity Details' ",
"doctype": "DocField",
"fieldname": "enq_no",
"fieldtype": "Link",
"hidden": 0,
"in_filter": 1,
"label": "Opportunity No",
"no_copy": 0,
"oldfieldname": "enq_no",
"oldfieldtype": "Link",
"options": "Opportunity",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "pull_enquiry_detail",
"fieldtype": "Button",
"hidden": 0,
"label": "Pull Opportunity Detail",
"no_copy": 0,
"oldfieldtype": "Button",
"print_hide": 0,
"read_only": 0,
"report_hide": 0
},
{
"doctype": "DocField",
"fieldname": "col_break34",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
"doctype": "DocField",
"fieldname": "net_total_export",
@@ -634,24 +598,6 @@
"read_only": 0,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "column_break_54",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "get_terms",
"fieldtype": "Button",
"label": "Get Terms and Conditions",
"oldfieldtype": "Button",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break_56",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "terms",

View File

@@ -325,21 +325,18 @@ class DocType(TransactionBase):
if so_status == 'Stopped':
msgprint("You cannot do any transaction against Sales Order : '%s' as it is Stopped." %(ref_doc_name))
raise Exception
# ****** Check for Item.is_sales_item = 'Yes' and Item.docstatus != 2 *******
def check_active_sales_items(self,obj):
for d in getlist(obj.doclist, obj.fname):
if d.item_code: # extra condn coz item_code is not mandatory in RV
valid_item = webnotes.conn.sql("select docstatus,is_sales_item, is_service_item from tabItem where name = %s",d.item_code)
if valid_item and valid_item[0][0] == 2:
msgprint("Item : '%s' does not exist in system." %(d.item_code))
raise Exception
sales_item = valid_item and valid_item[0][1] or 'No'
service_item = valid_item and valid_item[0][2] or 'No'
if sales_item == 'No' and service_item == 'No':
msgprint("Item : '%s' is neither Sales nor Service Item"%(d.item_code))
if d.item_code:
item = webnotes.conn.sql("""select docstatus, is_sales_item,
is_service_item, default_income_account, default_expense_account from tabItem where name = %s""",
d.item_code, as_dict=True)
if item.sales_item == 'No' and item.service_item == 'No':
msgprint("Item : '%s' is neither Sales nor Service Item" % (d.item_code))
raise Exception
if d.income_account and not default_income_account:
webnotes.conn.set_value("Item", d.item_code, "default_income_account", d.income_account)
# **************************************************************************************************************************************************