mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-29 17:11:33 +02:00
fix: provision to setup customer name on quotation save and patch for the same
This commit is contained in:
@@ -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
|
||||
27
erpnext/patches/v11_1/set_missing_title_for_quotation.py
Normal file
27
erpnext/patches/v11_1/set_missing_title_for_quotation.py
Normal 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'
|
||||
''')
|
||||
@@ -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",
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user