Merge pull request #17455 from saurabh6790/multiple_fixes

fix: data pulling based on quotation_to and party_name
This commit is contained in:
Nabin Hait
2019-05-02 16:01:07 +05:30
committed by GitHub
6 changed files with 56 additions and 7 deletions

View File

@@ -595,3 +595,4 @@ erpnext.patches.v11_1.woocommerce_set_creation_user
erpnext.patches.v11_1.delete_bom_browser
erpnext.patches.v11_1.set_salary_details_submittable
erpnext.patches.v11_1.rename_depends_on_lwp
erpnext.patches.v11_1.set_missing_title_for_quotation

View File

@@ -0,0 +1,27 @@
import frappe
def execute():
# update customer_name from Customer document if quotation_to is set to Customer
frappe.db.sql('''
update tabQuotation, tabCustomer
set
tabQuotation.customer_name = tabCustomer.customer_name,
tabQuotation.title = tabCustomer.customer_name
where
tabQuotation.customer_name is null
and tabQuotation.party_name = tabCustomer.name
and tabQuotation.quotation_to = 'Customer'
''')
# update customer_name from Lead document if quotation_to is set to Lead
frappe.db.sql('''
update tabQuotation, tabLead
set
tabQuotation.customer_name = case when ifnull(tabLead.company_name, '') != '' then tabLead.company_name else tabLead.lead_name end,
tabQuotation.title = case when ifnull(tabLead.company_name, '') != '' then tabLead.company_name else tabLead.lead_name end
where
tabQuotation.customer_name is null
and tabQuotation.party_name = tabLead.name
and tabQuotation.quotation_to = 'Lead'
''')

View File

@@ -103,7 +103,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field,
erpnext.utils.set_taxes = function(frm, address_field, display_field, is_your_company_address) {
if(frappe.meta.get_docfield(frm.doc.doctype, "taxes") && !is_your_company_address) {
if(!erpnext.utils.validate_mandatory(frm, "Lead/Customer/Supplier",
frm.doc.customer || frm.doc.supplier || frm.doc.lead, address_field)) {
frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name , address_field)) {
return;
}
@@ -125,6 +125,9 @@ erpnext.utils.set_taxes = function(frm, address_field, display_field, is_your_co
} else if (frm.doc.supplier) {
party_type = 'Supplier';
party = frm.doc.supplier;
} else if (frm.doc.quotation_to){
party_type = frm.doc.quotation_to;
party = frm.doc.party_name;
}
frappe.call({

View File

@@ -127,14 +127,24 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
// to overwrite the customer_filter trigger from queries.js
this.frm.toggle_reqd("party_name", this.frm.doc.quotation_to);
this.frm.set_query('customer_address', erpnext.queries.address_query);
this.frm.set_query('shipping_address_name', erpnext.queries.address_query);
this.frm.set_query('customer_address', this.address_query);
this.frm.set_query('shipping_address_name', this.address_query);
},
tc_name: function() {
this.get_terms();
},
address_query: function(doc) {
return {
query: 'frappe.contacts.doctype.address.address.address_query',
filters: {
link_doctype: frappe.dynamic_link.doctype,
link_name: doc.party_name
}
};
},
validate_company_and_party: function(party_field) {
if(!this.frm.doc.quotation_to) {
frappe.msgprint(__("Please select a value for {0} quotation_to {1}", [this.frm.doc.doctype, this.frm.doc.name]));

View File

@@ -195,7 +195,7 @@
"bold": 1,
"collapsible": 0,
"columns": 0,
"fetch_from": "customer.customer_name",
"fetch_from": "",
"fetch_if_empty": 0,
"fieldname": "customer_name",
"fieldtype": "Data",
@@ -441,7 +441,7 @@
"collapsible": 1,
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:(doc.customer || doc.lead)",
"depends_on": "eval:doc.party_name",
"fetch_if_empty": 0,
"fieldname": "contact_section",
"fieldtype": "Section Break",
@@ -542,7 +542,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.customer",
"depends_on": "eval:doc.quotaion_to=='Customer' && doc.party_name",
"fetch_if_empty": 0,
"fieldname": "contact_person",
"fieldtype": "Link",
@@ -3224,7 +3224,7 @@
"istable": 0,
"max_attachments": 1,
"menu_index": 0,
"modified": "2019-04-25 15:26:21.983298",
"modified": "2019-05-02 15:16:37.394455",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation",

View File

@@ -29,6 +29,7 @@ class Quotation(SellingController):
self.validate_order_type()
self.validate_uom_is_integer("stock_uom", "qty")
self.validate_valid_till()
self.set_customer_name()
if self.items:
self.with_items = 1
@@ -46,6 +47,13 @@ class Quotation(SellingController):
if self.quotation_to == "Lead" and self.party_name:
frappe.get_doc("Lead", self.party_name).set_status(update=True)
def set_customer_name(self):
if self.party_name and self.quotation_to == 'Customer':
self.customer_name = frappe.db.get_value("Customer", self.party_name, "customer_name")
elif self.party_name and self.quotation_to == 'Lead':
lead_name, company_name = frappe.db.get_value("Lead", self.party_name, ["lead_name", "company_name"])
self.customer_name = company_name or lead_name
def update_opportunity(self):
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
if opportunity: