fix: provision to setup customer name on quotation save and patch for the same

This commit is contained in:
Saurabh
2019-05-02 15:50:01 +05:30
parent 1417c7e828
commit 625191d20a
4 changed files with 38 additions and 2 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

@@ -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",
@@ -3224,7 +3224,7 @@
"istable": 0,
"max_attachments": 1,
"menu_index": 0,
"modified": "2019-05-02 14:10:43.355616",
"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: