mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 17:15:04 +00:00
fix: Change dynamic_field name and minor fixes
This commit is contained in:
@@ -90,11 +90,11 @@ class Lead(SellingController):
|
||||
return frappe.db.get_value("Customer", {"lead_name": self.name})
|
||||
|
||||
def has_opportunity(self):
|
||||
return frappe.db.get_value("Opportunity", {"customer_lead": self.name, "status": ["!=", "Lost"]})
|
||||
return frappe.db.get_value("Opportunity", {"party_name": self.name, "status": ["!=", "Lost"]})
|
||||
|
||||
def has_quotation(self):
|
||||
return frappe.db.get_value("Quotation", {
|
||||
"customer_lead": self.name,
|
||||
"party_name": self.name,
|
||||
"docstatus": 1,
|
||||
"status": ["!=", "Lost"]
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ frappe.ui.form.on("Opportunity", {
|
||||
});
|
||||
},
|
||||
|
||||
customer_lead: function(frm) {
|
||||
party_name: function(frm) {
|
||||
if (frm.doc.opportunity_from == "Customer") {
|
||||
frm.trigger('set_contact_link');
|
||||
erpnext.utils.get_party_details(frm);
|
||||
@@ -38,7 +38,7 @@ frappe.ui.form.on("Opportunity", {
|
||||
contact_person: erpnext.utils.get_contact_details,
|
||||
|
||||
opportunity_from: function(frm) {
|
||||
frm.toggle_reqd("customer_lead", frm.doc.opportunity_from);
|
||||
frm.toggle_reqd("party_name", frm.doc.opportunity_from);
|
||||
frm.trigger("set_dynamic_field_label");
|
||||
},
|
||||
|
||||
@@ -81,22 +81,17 @@ frappe.ui.form.on("Opportunity", {
|
||||
},
|
||||
|
||||
set_contact_link: function(frm) {
|
||||
if(frm.doc.opportunity_from == "Customer" && frm.doc.customer_lead) {
|
||||
if(frm.doc.opportunity_from == "Customer" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'customer', doctype: 'Customer'}
|
||||
} else if(frm.doc.opportunity_from == "Lead" && frm.doc.customer_lead) {
|
||||
} else if(frm.doc.opportunity_from == "Lead" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'lead', doctype: 'Lead'}
|
||||
}
|
||||
},
|
||||
|
||||
set_dynamic_field_label: function(frm){
|
||||
if (frm.doc.opportunity_from == "Customer")
|
||||
{
|
||||
frm.set_df_property("customer_lead", "label", "Customer");
|
||||
}
|
||||
|
||||
if (frm.doc.opportunity_from == "Lead")
|
||||
{
|
||||
frm.set_df_property("customer_lead", "label", "Lead");
|
||||
if (frm.doc.opportunity_from) {
|
||||
frm.set_df_property("party_name", "label", frm.doc.opportunity_from);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -162,7 +157,7 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
|
||||
$.extend(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm}));
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
if(doc.opportunity_from == 'Lead' && doc.customer_lead)
|
||||
if(doc.opportunity_from == 'Lead' && doc.party_name)
|
||||
cur_frm.cscript.lead(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
@@ -185,10 +180,10 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.lead = function(doc, cdt, cdn) {
|
||||
cur_frm.toggle_display("contact_info", doc.customer_lead);
|
||||
cur_frm.toggle_display("contact_info", doc.party_name);
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
||||
source_name: cur_frm.doc.customer_lead,
|
||||
source_name: cur_frm.doc.party_name,
|
||||
frm: cur_frm
|
||||
});
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_lead",
|
||||
"fieldname": "party_name",
|
||||
"fieldtype": "Dynamic Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@@ -148,7 +148,7 @@
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
@@ -162,6 +162,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_from": "party_name.customer_name",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_name",
|
||||
"fieldtype": "Data",
|
||||
@@ -1467,7 +1468,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-04-14 21:00:16.007097",
|
||||
"modified": "2019-04-25 17:10:09.399721",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Opportunity",
|
||||
@@ -1515,11 +1516,11 @@
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"search_fields": "status,transaction_date,customer_lead,opportunity_type,territory,company",
|
||||
"search_fields": "status,transaction_date,party_name,opportunity_type,territory,company",
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"timeline_field": "customer_lead",
|
||||
"timeline_field": "party_name",
|
||||
"title_field": "title",
|
||||
"track_changes": 0,
|
||||
"track_seen": 1,
|
||||
|
||||
@@ -17,7 +17,7 @@ sender_field = "contact_email"
|
||||
class Opportunity(TransactionBase):
|
||||
def after_insert(self):
|
||||
if self.opportunity_from == "Lead":
|
||||
frappe.get_doc("Lead", self.customer_lead).set_status(update=True)
|
||||
frappe.get_doc("Lead", self.party_name).set_status(update=True)
|
||||
|
||||
def validate(self):
|
||||
self._prev = frappe._dict({
|
||||
@@ -29,9 +29,6 @@ class Opportunity(TransactionBase):
|
||||
|
||||
self.make_new_lead_if_required()
|
||||
|
||||
if not self.opportunity_from:
|
||||
frappe.throw(_("Opportunity From field is mandatory"))
|
||||
|
||||
self.validate_item_details()
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
self.validate_lead_cust()
|
||||
@@ -45,7 +42,7 @@ class Opportunity(TransactionBase):
|
||||
|
||||
def make_new_lead_if_required(self):
|
||||
"""Set lead against new opportunity"""
|
||||
if (not self.get("customer_lead")) and self.contact_email:
|
||||
if (not self.get("party_name")) and self.contact_email:
|
||||
# check if customer is already created agains the self.contact_email
|
||||
customer = frappe.db.sql("""select
|
||||
distinct `tabDynamic Link`.link_name as customer
|
||||
@@ -61,7 +58,7 @@ class Opportunity(TransactionBase):
|
||||
`tabDynamic Link`.link_doctype='Customer'
|
||||
""".format(self.contact_email), as_dict=True)
|
||||
if customer and customer[0].customer:
|
||||
self.customer_lead = customer[0].customer
|
||||
self.party_name = customer[0].customer
|
||||
self.opportunity_from = "Customer"
|
||||
return
|
||||
|
||||
@@ -90,7 +87,7 @@ class Opportunity(TransactionBase):
|
||||
lead_name = lead.name
|
||||
|
||||
self.opportunity_from = "Lead"
|
||||
self.customer_lead = lead_name
|
||||
self.party_name = lead_name
|
||||
|
||||
def declare_enquiry_lost(self,arg):
|
||||
if not self.has_active_quotation():
|
||||
@@ -137,10 +134,10 @@ class Opportunity(TransactionBase):
|
||||
return True
|
||||
|
||||
def validate_cust_name(self):
|
||||
if self.customer_lead and self.opportunity_from == 'Customer':
|
||||
self.customer_name = frappe.db.get_value("Customer", self.customer_lead, "customer_name")
|
||||
elif self.customer_lead and self.opportunity_from == 'Lead':
|
||||
lead_name, company_name = frappe.db.get_value("Lead", self.customer_lead, ["lead_name", "company_name"])
|
||||
if self.party_name and self.opportunity_from == 'Customer':
|
||||
self.customer_name = frappe.db.get_value("Customer", self.party_name, "customer_name")
|
||||
elif self.party_name and self.opportunity_from == '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 on_update(self):
|
||||
@@ -153,16 +150,16 @@ class Opportunity(TransactionBase):
|
||||
opts.description = ""
|
||||
opts.contact_date = self.contact_date
|
||||
|
||||
if self.customer_lead and self.opportunity_from == 'Customer':
|
||||
if self.party_name and self.opportunity_from == 'Customer':
|
||||
if self.contact_person:
|
||||
opts.description = 'Contact '+cstr(self.contact_person)
|
||||
else:
|
||||
opts.description = 'Contact customer '+cstr(self.customer_lead)
|
||||
elif self.customer_lead and self.opportunity_from == 'Lead':
|
||||
opts.description = 'Contact customer '+cstr(self.party_name)
|
||||
elif self.party_name and self.opportunity_from == 'Lead':
|
||||
if self.contact_display:
|
||||
opts.description = 'Contact '+cstr(self.contact_display)
|
||||
else:
|
||||
opts.description = 'Contact lead '+cstr(self.customer_lead)
|
||||
opts.description = 'Contact lead '+cstr(self.party_name)
|
||||
|
||||
opts.subject = opts.description
|
||||
opts.description += '. By : ' + cstr(self.contact_by)
|
||||
@@ -187,14 +184,6 @@ class Opportunity(TransactionBase):
|
||||
for key in item_fields:
|
||||
if not d.get(key): d.set(key, item.get(key))
|
||||
|
||||
def validate_lead_cust(self):
|
||||
if self.opportunity_from == 'Lead':
|
||||
if not self.customer_lead:
|
||||
frappe.throw(_("Lead must be set if Opportunity is made from Lead"))
|
||||
elif self.opportunity_from == 'Customer':
|
||||
if not self.customer_lead:
|
||||
msgprint(_("Customer is mandatory if 'Opportunity From' is selected as Customer"), raise_exception=1)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_item_details(item_code):
|
||||
@@ -216,8 +205,11 @@ def make_quotation(source_name, target_doc=None):
|
||||
quotation = frappe.get_doc(target)
|
||||
|
||||
company_currency = frappe.get_cached_value('Company', quotation.company, "default_currency")
|
||||
party_account_currency = get_party_account_currency("Customer", quotation.customer_lead,
|
||||
quotation.company) if quotation.customer_lead else company_currency
|
||||
|
||||
if quotation.quotation_to == 'Customer' and quotation.party_name:
|
||||
party_account_currency = get_party_account_currency("Customer", quotation.party_name, quotation.company)
|
||||
else:
|
||||
party_account_currency = company_currency
|
||||
|
||||
quotation.currency = party_account_currency or company_currency
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ class TestOpportunity(unittest.TestCase):
|
||||
# new lead should be created against the new.opportunity@example.com
|
||||
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
|
||||
|
||||
self.assertTrue(opp_doc.customer_lead)
|
||||
self.assertTrue(opp_doc.party_name)
|
||||
self.assertEqual(opp_doc.opportunity_from, "Lead")
|
||||
self.assertEqual(frappe.db.get_value("Lead", opp_doc.customer_lead, "email_id"),
|
||||
self.assertEqual(frappe.db.get_value("Lead", opp_doc.party_name, "email_id"),
|
||||
'new.opportunity@example.com')
|
||||
|
||||
# create new customer and create new contact against 'new.opportunity@example.com'
|
||||
customer = make_customer(opp_doc.customer_lead).insert(ignore_permissions=True)
|
||||
customer = make_customer(opp_doc.party_name).insert(ignore_permissions=True)
|
||||
frappe.get_doc({
|
||||
"doctype": "Contact",
|
||||
"email_id": "new.opportunity@example.com",
|
||||
@@ -55,9 +55,9 @@ class TestOpportunity(unittest.TestCase):
|
||||
}).insert(ignore_permissions=True)
|
||||
|
||||
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
|
||||
self.assertTrue(opp_doc.customer_lead)
|
||||
self.assertTrue(opp_doc.party_name)
|
||||
self.assertEqual(opp_doc.opportunity_from, "Customer")
|
||||
self.assertEqual(opp_doc.customer_lead, customer.name)
|
||||
self.assertEqual(opp_doc.party_name, customer.name)
|
||||
|
||||
def make_opportunity(**args):
|
||||
args = frappe._dict(args)
|
||||
@@ -72,10 +72,10 @@ def make_opportunity(**args):
|
||||
})
|
||||
|
||||
if opp_doc.opportunity_from == 'Customer':
|
||||
opp_doc.customer_lead= args.customer or "_Test Customer"
|
||||
opp_doc.party_name= args.customer or "_Test Customer"
|
||||
|
||||
if opp_doc.opportunity_from == 'Lead':
|
||||
opp_doc.customer_lead = args.lead or "_T-Lead-00001"
|
||||
opp_doc.party_name = args.lead or "_T-Lead-00001"
|
||||
|
||||
if args.with_items:
|
||||
opp_doc.append('items', {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "_Test Opportunity 1",
|
||||
"opportunity_from": "Lead",
|
||||
"enquiry_type": "Sales",
|
||||
"customer_lead": "_T-Lead-00001",
|
||||
"party_name": "_T-Lead-00001",
|
||||
"transaction_date": "2013-12-12",
|
||||
"items": [{
|
||||
"item_name": "Test Item",
|
||||
|
||||
@@ -6,9 +6,9 @@ import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doctype("Quotation")
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set customer_lead = lead WHERE quotation_to = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set customer_lead = customer WHERE quotation_to = 'Customer' """)
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = lead WHERE quotation_to = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = customer WHERE quotation_to = 'Customer' """)
|
||||
|
||||
frappe.reload_doctype("Opportunity")
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set customer_lead = lead WHERE opportunity_from = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set customer_lead = customer WHERE opportunity_from = 'Customer' """)
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = lead WHERE opportunity_from = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = customer WHERE opportunity_from = 'Customer' """)
|
||||
@@ -104,9 +104,6 @@ class Customer(TransactionBase):
|
||||
if self.lead_name:
|
||||
frappe.db.set_value('Lead', self.lead_name, 'status', 'Converted', update_modified=False)
|
||||
|
||||
for d in frappe.get_all('Opportunity', {'customer_lead': self.lead_name}):
|
||||
frappe.db.set_value('Opportunity', d.name, 'customer_lead', self.name, update_modified=False)
|
||||
|
||||
def create_lead_address_contact(self):
|
||||
if self.lead_name:
|
||||
# assign lead address to customer (if already not set)
|
||||
|
||||
@@ -7,8 +7,8 @@ def get_data():
|
||||
'heatmap_message': _('This is based on transactions against this Customer. See timeline below for details'),
|
||||
'fieldname': 'customer',
|
||||
'non_standard_fieldnames': {
|
||||
'Quotation': 'customer_lead',
|
||||
'Opportunity': 'customer_lead'
|
||||
'Quotation': 'party_name',
|
||||
'Opportunity': 'party_name'
|
||||
},
|
||||
'transactions': [
|
||||
{
|
||||
|
||||
@@ -108,15 +108,15 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
set_dynamic_field_label: function(){
|
||||
if (this.frm.doc.quotation_to == "Customer")
|
||||
{
|
||||
this.frm.set_df_property("customer_lead", "label", "Customer");
|
||||
this.frm.fields_dict.customer_lead.get_query = null;
|
||||
this.frm.set_df_property("party_name", "label", "Customer");
|
||||
this.frm.fields_dict.party_name.get_query = null;
|
||||
}
|
||||
|
||||
if (this.frm.doc.quotation_to == "Lead")
|
||||
{
|
||||
this.frm.set_df_property("customer_lead", "label", "Lead");
|
||||
this.frm.set_df_property("party_name", "label", "Lead");
|
||||
|
||||
this.frm.fields_dict.customer_lead.get_query = function() {
|
||||
this.frm.fields_dict.party_name.get_query = function() {
|
||||
return{ query: "erpnext.controllers.queries.lead_query" }
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
var me = this;
|
||||
|
||||
// to overwrite the customer_filter trigger from queries.js
|
||||
this.frm.toggle_reqd("customer_lead", this.frm.doc.quotation_to);
|
||||
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);
|
||||
},
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_lead",
|
||||
"fieldname": "party_name",
|
||||
"fieldtype": "Dynamic Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@@ -3224,7 +3224,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 1,
|
||||
"menu_index": 0,
|
||||
"modified": "2019-04-02 10:18:58.506125",
|
||||
"modified": "2019-04-25 15:26:21.983298",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Quotation",
|
||||
@@ -3390,11 +3390,11 @@
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 1,
|
||||
"search_fields": "status,transaction_date,customer_lead,order_type",
|
||||
"search_fields": "status,transaction_date,party_name,order_type",
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"timeline_field": "customer_lead",
|
||||
"timeline_field": "party_name",
|
||||
"title_field": "title",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
|
||||
@@ -43,8 +43,8 @@ class Quotation(SellingController):
|
||||
super(Quotation, self).validate_order_type()
|
||||
|
||||
def update_lead(self):
|
||||
if self.quotation_to == "Lead" and self.customer_lead:
|
||||
frappe.get_doc("Lead", self.customer_lead).set_status(update=True)
|
||||
if self.quotation_to == "Lead" and self.party_name:
|
||||
frappe.get_doc("Lead", self.party_name).set_status(update=True)
|
||||
|
||||
def update_opportunity(self):
|
||||
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
|
||||
@@ -204,7 +204,7 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
|
||||
return doclist
|
||||
|
||||
def _make_customer(source_name, ignore_permissions=False):
|
||||
quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "customer_lead", "customer_name"])
|
||||
quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "party_name", "customer_name"])
|
||||
if quotation and quotation[1] and not quotation[2]:
|
||||
lead_name = quotation[1]
|
||||
customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name},
|
||||
|
||||
@@ -203,15 +203,15 @@ class TestQuotation(unittest.TestCase):
|
||||
|
||||
test_records = frappe.get_test_records('Quotation')
|
||||
|
||||
def get_quotation_dict(customer_lead=None, item_code=None):
|
||||
if not customer_lead:
|
||||
customer_lead = '_Test Customer'
|
||||
def get_quotation_dict(party_name=None, item_code=None):
|
||||
if not party_name:
|
||||
party_name = '_Test Customer'
|
||||
if not item_code:
|
||||
item_code = '_Test Item'
|
||||
|
||||
return {
|
||||
'doctype': 'Quotation',
|
||||
'customer_lead': customer_lead,
|
||||
'party_name': party_name,
|
||||
'items': [
|
||||
{
|
||||
'item_code': item_code,
|
||||
@@ -229,7 +229,7 @@ def make_quotation(**args):
|
||||
qo.transaction_date = args.transaction_date
|
||||
|
||||
qo.company = args.company or "_Test Company"
|
||||
qo.customer_lead = args.customer_lead or "_Test Customer"
|
||||
qo.party_name = args.party_name or "_Test Customer"
|
||||
qo.currency = args.currency or "INR"
|
||||
if args.selling_price_list:
|
||||
qo.selling_price_list = args.selling_price_list
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"company": "_Test Company",
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"customer_lead": "_Test Customer",
|
||||
"party_name": "_Test Customer",
|
||||
"customer_group": "_Test Customer Group",
|
||||
"customer_name": "_Test Customer",
|
||||
"doctype": "Quotation",
|
||||
|
||||
@@ -196,7 +196,7 @@ def _get_cart_quotation(party=None):
|
||||
party = get_party()
|
||||
|
||||
quotation = frappe.get_all("Quotation", fields=["name"], filters=
|
||||
{"customer_lead": party.name, "order_type": "Shopping Cart", "docstatus": 0},
|
||||
{"party_name": party.name, "order_type": "Shopping Cart", "docstatus": 0},
|
||||
order_by="modified desc", limit_page_length=1)
|
||||
|
||||
if quotation:
|
||||
@@ -211,7 +211,7 @@ def _get_cart_quotation(party=None):
|
||||
"status": "Draft",
|
||||
"docstatus": 0,
|
||||
"__islocal": 1,
|
||||
"customer_lead": party.name
|
||||
"party_name": party.name
|
||||
})
|
||||
|
||||
qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
|
||||
@@ -291,9 +291,9 @@ def _set_price_list(quotation, cart_settings):
|
||||
|
||||
# check if customer price list exists
|
||||
selling_price_list = None
|
||||
if quotation.customer_lead:
|
||||
if quotation.party_name:
|
||||
from erpnext.accounts.party import get_default_price_list
|
||||
selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.customer_lead))
|
||||
selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))
|
||||
|
||||
# else check for territory based price list
|
||||
if not selling_price_list:
|
||||
@@ -305,9 +305,9 @@ def set_taxes(quotation, cart_settings):
|
||||
"""set taxes based on billing territory"""
|
||||
from erpnext.accounts.party import set_taxes
|
||||
|
||||
customer_group = frappe.db.get_value("Customer", quotation.customer_lead, "customer_group")
|
||||
customer_group = frappe.db.get_value("Customer", quotation.party_name, "customer_group")
|
||||
|
||||
quotation.taxes_and_charges = set_taxes(quotation.customer_lead, "Customer", \
|
||||
quotation.taxes_and_charges = set_taxes(quotation.party_name, "Customer", \
|
||||
quotation.transaction_date, quotation.company, customer_group, None, \
|
||||
quotation.customer_address, quotation.shipping_address_name, 1)
|
||||
#
|
||||
|
||||
@@ -43,7 +43,7 @@ class TestShoppingCart(unittest.TestCase):
|
||||
# test if quotation with customer is fetched
|
||||
quotation = _get_cart_quotation()
|
||||
self.assertEqual(quotation.quotation_to, "Customer")
|
||||
self.assertEqual(quotation.customer_lead, "_Test Customer")
|
||||
self.assertEqual(quotation.party_name, "_Test Customer")
|
||||
self.assertEqual(quotation.contact_email, frappe.session.user)
|
||||
|
||||
return quotation
|
||||
@@ -105,7 +105,7 @@ class TestShoppingCart(unittest.TestCase):
|
||||
|
||||
from erpnext.accounts.party import set_taxes
|
||||
|
||||
tax_rule_master = set_taxes(quotation.customer_lead, "Customer", \
|
||||
tax_rule_master = set_taxes(quotation.party_name, "Customer", \
|
||||
quotation.transaction_date, quotation.company, None, None, \
|
||||
quotation.customer_address, quotation.shipping_address_name, 1)
|
||||
self.assertEqual(quotation.taxes_and_charges, tax_rule_master)
|
||||
@@ -120,7 +120,7 @@ class TestShoppingCart(unittest.TestCase):
|
||||
"doctype": "Quotation",
|
||||
"quotation_to": "Customer",
|
||||
"order_type": "Shopping Cart",
|
||||
"customer_lead": get_party(frappe.session.user).name,
|
||||
"party_name": get_party(frappe.session.user).name,
|
||||
"docstatus": 0,
|
||||
"contact_email": frappe.session.user,
|
||||
"selling_price_list": "_Test Price List Rest of the World",
|
||||
|
||||
Reference in New Issue
Block a user