diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt
index 27a0340f90..81b078528e 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:05",
"docstatus": 0,
- "modified": "2013-06-12 15:14:00",
+ "modified": "2013-06-27 11:35:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -432,7 +432,7 @@
"doctype": "DocField",
"fieldname": "charge",
"fieldtype": "Link",
- "label": "Taxes and Charges",
+ "label": "Apply Taxes and Charges Master",
"oldfieldname": "charge",
"oldfieldtype": "Link",
"options": "Sales Taxes and Charges Master",
@@ -446,10 +446,11 @@
},
{
"doctype": "DocField",
- "fieldname": "get_charges",
- "fieldtype": "Button",
- "label": "Get Taxes and Charges",
+ "fieldname": "shipping_rule",
+ "fieldtype": "Link",
+ "label": "Apply Shipping Rule",
"oldfieldtype": "Button",
+ "options": "Shipping Rule",
"print_hide": 1,
"read_only": 0
},
diff --git a/accounts/doctype/shipping_rule/shipping_rule.py b/accounts/doctype/shipping_rule/shipping_rule.py
index 5ed4ed38e0..87148656df 100644
--- a/accounts/doctype/shipping_rule/shipping_rule.py
+++ b/accounts/doctype/shipping_rule/shipping_rule.py
@@ -3,23 +3,80 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
+from webnotes.utils import flt, fmt_money
+from webnotes.model.controller import DocListController
+from setup.utils import get_company_currency
-class DocType:
+class OverlappingConditionError(webnotes.ValidationError): pass
+class FromGreaterThanToError(webnotes.ValidationError): pass
+class ManyBlankToValuesError(webnotes.ValidationError): pass
+
+class DocType(DocListController):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
- self.validate_to_value_of_shipping_rule_conditions()
+ self.shipping_rule_conditions = self.doclist.get({"parentfield": "shipping_rule_conditions"})
+ self.validate_from_to_values()
+ self.sort_shipping_rule_conditions()
self.validate_overlapping_shipping_rule_conditions()
+ def validate_from_to_values(self):
+ zero_to_values = []
- def validate_to_value_of_shipping_rule_conditions(self):
- """check if more than two or more rows has To Value = 0"""
- shipping_rule_conditions_with_0_to_value = self.doclist.get({
- "parentfield": "shipping_rule_conditions", "to_value": ["in", [0, None]]})
- if len(shipping_rule_conditions_with_0_to_value) >= 2:
- msgprint(_('''There can only be one shipping rule with 0 or blank value for "To Value"'''),
- raise_exception=True)
+ for d in self.shipping_rule_conditions:
+ self.round_floats_in(d)
+
+ # values cannot be negative
+ self.validate_value("from_value", ">=", 0.0, d)
+ self.validate_value("to_value", ">=", 0.0, d)
+
+ if d.to_value == 0:
+ zero_to_values.append(d)
+ elif d.from_value >= d.to_value:
+ msgprint(_("Error") + ": " + _("Row") + " # %d: " % d.idx +
+ _("From Value should be less than To Value"),
+ raise_exception=FromGreaterThanToError)
+
+ # check if more than two or more rows has To Value = 0
+ if len(zero_to_values) >= 2:
+ msgprint(_('''There can only be one Shipping Rule Condition with 0 or blank value for "To Value"'''),
+ raise_exception=ManyBlankToValuesError)
+ def sort_shipping_rule_conditions(self):
+ """Sort Shipping Rule Conditions based on increasing From Value"""
+ self.shipping_rules_conditions = sorted(self.shipping_rule_conditions, key=lambda d: flt(d.from_value))
+ for i, d in enumerate(self.shipping_rule_conditions):
+ d.idx = i + 1
+
def validate_overlapping_shipping_rule_conditions(self):
- pass
\ No newline at end of file
+ def overlap_exists_between((x1, x2), (y1, y2)):
+ """
+ (x1, x2) and (y1, y2) are two ranges
+ if condition x = 100 to 300
+ then condition y can only be like 50 to 99 or 301 to 400
+ hence, non-overlapping condition = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2)
+ """
+ separate = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2)
+ return (not separate)
+
+ overlaps = []
+ for i in xrange(0, len(self.shipping_rule_conditions)):
+ for j in xrange(i+1, len(self.shipping_rule_conditions)):
+ d1, d2 = self.shipping_rule_conditions[i], self.shipping_rule_conditions[j]
+ if d1.fields != d2.fields:
+ # in our case, to_value can be zero, hence pass the from_value if so
+ range_a = (d1.from_value, d1.to_value or d1.from_value)
+ range_b = (d2.from_value, d2.to_value or d2.from_value)
+ if overlap_exists_between(range_a, range_b):
+ overlaps.append([d1, d2])
+
+ if overlaps:
+ company_currency = get_company_currency(self.doc.company)
+ msgprint(_("Error") + ": " + _("Overlapping Conditions found between") + ":")
+ messages = []
+ for d1, d2 in overlaps:
+ messages.append("%s-%s = %s " % (d1.from_value, d1.to_value, fmt_money(d1.shipping_amount, currency=company_currency)) +
+ _("and") + " %s-%s = %s" % (d2.from_value, d2.to_value, fmt_money(d2.shipping_amount, currency=company_currency)))
+
+ msgprint("\n".join(messages), raise_exception=OverlappingConditionError)
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule/test_shipping_rule.py b/accounts/doctype/shipping_rule/test_shipping_rule.py
new file mode 100644
index 0000000000..ff217bc5a7
--- /dev/null
+++ b/accounts/doctype/shipping_rule/test_shipping_rule.py
@@ -0,0 +1,66 @@
+import webnotes
+import unittest
+from accounts.doctype.shipping_rule.shipping_rule import FromGreaterThanToError, ManyBlankToValuesError, OverlappingConditionError
+
+class TestShippingRule(unittest.TestCase):
+ def test_from_greater_than_to(self):
+ shipping_rule = webnotes.bean(copy=test_records[0])
+ shipping_rule.doclist[1].from_value = 101
+ self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
+
+ def test_many_zero_to_values(self):
+ shipping_rule = webnotes.bean(copy=test_records[0])
+ shipping_rule.doclist[1].to_value = 0
+ self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
+
+ def test_overlapping_conditions(self):
+ for range_a, range_b in [
+ ((50, 150), (0, 100)),
+ ((50, 150), (100, 200)),
+ ((50, 150), (75, 125)),
+ ((50, 150), (25, 175)),
+ ((50, 150), (50, 150)),
+ ]:
+ shipping_rule = webnotes.bean(copy=test_records[0])
+ shipping_rule.doclist[1].from_value = range_a[0]
+ shipping_rule.doclist[1].to_value = range_a[1]
+ shipping_rule.doclist[2].from_value = range_b[0]
+ shipping_rule.doclist[2].to_value = range_b[1]
+ self.assertRaises(OverlappingConditionError, shipping_rule.insert)
+
+test_records = [
+ [
+ {
+ "doctype": "Shipping Rule",
+ "calculate_based_on": "Amount",
+ "company": "_Test Company",
+ "account": "_Test Account Shipping Charges - _TC",
+ "cost_center": "_Test Cost Center - _TC"
+ },
+ {
+ "doctype": "Shipping Rule Condition",
+ "parentfield": "shipping_rule_conditions",
+ "from_value": 0,
+ "to_value": 100,
+ "shipping_amount": 50.0
+ },
+ {
+ "doctype": "Shipping Rule Condition",
+ "parentfield": "shipping_rule_conditions",
+ "from_value": 101,
+ "to_value": 200,
+ "shipping_amount": 100.0
+ },
+ {
+ "doctype": "Shipping Rule Condition",
+ "parentfield": "shipping_rule_conditions",
+ "from_value": 201,
+ "shipping_amount": 0.0
+ },
+ {
+ "doctype": "For Territory",
+ "parentfield": "valid_for_territories",
+ "territory": "_Test Territory"
+ }
+ ]
+]
\ No newline at end of file
diff --git a/accounts/utils.py b/accounts/utils.py
index fa93cb0628..4ca1b3a57a 100644
--- a/accounts/utils.py
+++ b/accounts/utils.py
@@ -351,4 +351,4 @@ def fix_total_debit_credit():
webnotes.conn.sql("""update `tabGL Entry` set %s = %s + %s
where voucher_type = %s and voucher_no = %s and %s > 0 limit 1""" %
(dr_or_cr, dr_or_cr, '%s', '%s', '%s', dr_or_cr),
- (d.diff, d.voucher_type, d.voucher_no), debug=1)
\ No newline at end of file
+ (d.diff, d.voucher_type, d.voucher_no))
\ No newline at end of file
diff --git a/buying/doctype/buying_settings/buying_settings.py b/buying/doctype/buying_settings/buying_settings.py
index 7a97349f22..b00bcef42f 100644
--- a/buying/doctype/buying_settings/buying_settings.py
+++ b/buying/doctype/buying_settings/buying_settings.py
@@ -8,6 +8,6 @@ class DocType:
self.doc, self.doclist = d, dl
def validate(self):
- for key in ["supplier_type", "maintain_same_rate"]:
+ for key in ["supplier_type", "supp_master_name", "maintain_same_rate"]:
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
\ No newline at end of file
diff --git a/controllers/js/contact_address_common.js b/controllers/js/contact_address_common.js
index ca9e084f5c..de1ab3478f 100644
--- a/controllers/js/contact_address_common.js
+++ b/controllers/js/contact_address_common.js
@@ -5,6 +5,11 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query;
+ if(cur_frm.fields_dict.lead) {
+ cur_frm.fields_dict.lead.get_query = erpnext.utils.lead_query;
+ cur_frm.add_fetch('lead', 'lead_name', 'lead_name');
+ }
+
if(doc.__islocal) {
var last_route = wn.route_history.slice(-2, -1)[0];
if(last_route && last_route[0]==="Form") {
@@ -13,14 +18,32 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
"Maintenance Schedule"]
.indexOf(last_route[1])!==-1) {
var refdoc = wn.model.get_doc(last_route[1], last_route[2]);
- cur_frm.set_value("customer", refdoc.customer || refdoc.name);
- cur_frm.set_value("customer_name", refdoc.customer_name);
+
+ if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Customer" : true) {
+ cur_frm.set_value("customer", refdoc.customer || refdoc.name);
+ cur_frm.set_value("customer_name", refdoc.customer_name);
+ if(cur_frm.doc.doctype==="Address")
+ cur_frm.set_value("address_title", cur_frm.doc.customer_name);
+ }
}
if(["Supplier", "Supplier Quotation", "Purchase Order", "Purchase Invoice", "Purchase Receipt"]
.indexOf(last_route[1])!==-1) {
- var customer = wn.model.get_doc(last_route[1], last_route[2]);
+ var refdoc = wn.model.get_doc(last_route[1], last_route[2]);
cur_frm.set_value("supplier", refdoc.supplier || refdoc.name);
cur_frm.set_value("supplier_name", refdoc.supplier_name);
+ if(cur_frm.doc.doctype==="Address")
+ cur_frm.set_value("address_title", cur_frm.doc.supplier_name);
+ }
+ if(["Lead", "Quotation"]
+ .indexOf(last_route[1])!==-1) {
+ var refdoc = wn.model.get_doc(last_route[1], last_route[2]);
+
+ if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Lead" : true) {
+ cur_frm.set_value("lead", refdoc.lead || refdoc.name);
+ cur_frm.set_value("lead_name", refdoc.customer_name || refdoc.company_name || refdoc.lead_name);
+ if(cur_frm.doc.doctype==="Address")
+ cur_frm.set_value("address_title", cur_frm.doc.lead_name);
+ }
}
}
}
diff --git a/manufacturing/doctype/bom/bom.js b/manufacturing/doctype/bom/bom.js
index b1f43f7620..d14590cb08 100644
--- a/manufacturing/doctype/bom/bom.js
+++ b/manufacturing/doctype/bom/bom.js
@@ -44,9 +44,9 @@ var set_operation_no = function(doc) {
var op = op_table[i].operation_no;
if (op && !inList(operations, op)) operations.push(op);
}
-
- cur_frm.fields_dict["bom_materials"].grid.get_field("operation_no")
- .df.options = operations.join("\n");
+
+ wn.meta.get_docfield("BOM Item", "operation_no",
+ cur_frm.docname).options = operations.join("\n");
$.each(getchildren("BOM Item", doc.name, "bom_materials"), function(i, v) {
if(!inList(operations, cstr(v.operation_no))) v.operation_no = null;
diff --git a/manufacturing/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt
index 922fd80363..d539ad0338 100644
--- a/manufacturing/doctype/bom/bom.txt
+++ b/manufacturing/doctype/bom/bom.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-22 15:11:38",
"docstatus": 0,
- "modified": "2013-01-29 17:32:53",
+ "modified": "2013-06-27 11:08:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -112,6 +112,7 @@
"options": "Specify the operations, operating cost and give a unique Operation no to your operations."
},
{
+ "depends_on": "with_operations",
"doctype": "DocField",
"fieldname": "bom_operations",
"fieldtype": "Table",
diff --git a/manufacturing/doctype/bom_item/bom_item.txt b/manufacturing/doctype/bom_item/bom_item.txt
index 14be95a336..2554adf21f 100644
--- a/manufacturing/doctype/bom_item/bom_item.txt
+++ b/manufacturing/doctype/bom_item/bom_item.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-02-22 01:27:49",
"docstatus": 0,
- "modified": "2013-03-07 07:03:18",
+ "modified": "2013-06-27 11:30:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -92,6 +92,7 @@
"reqd": 1
},
{
+ "description": "See \"Rate Of Materials Based On\" in Costing Section",
"doctype": "DocField",
"fieldname": "rate",
"fieldtype": "Float",
diff --git a/patches/february_2013/p09_timesheets.py b/patches/february_2013/p09_timesheets.py
index 2242d6b629..609dba33bc 100644
--- a/patches/february_2013/p09_timesheets.py
+++ b/patches/february_2013/p09_timesheets.py
@@ -49,7 +49,7 @@ def execute():
for key in custom_map["Timesheet Detail"]:
tl.doc.fields[key] = tsd.fields.get(key)
- tl.make_obj()
+ tl.make_controller()
tl.controller.set_status()
tl.controller.calculate_total_hours()
tl.doc.insert()
diff --git a/patches/june_2013/p07_taxes_price_list_for_territory.py b/patches/june_2013/p07_taxes_price_list_for_territory.py
index fbce11557a..9204866718 100644
--- a/patches/june_2013/p07_taxes_price_list_for_territory.py
+++ b/patches/june_2013/p07_taxes_price_list_for_territory.py
@@ -4,11 +4,12 @@ def execute():
webnotes.reload_doc("setup", "doctype", "for_territory")
webnotes.reload_doc("setup", "doctype", "price_list")
webnotes.reload_doc("accounts", "doctype", "sales_taxes_and_charges_master")
+ webnotes.reload_doc("accounts", "doctype", "shipping_rule")
from setup.utils import get_root_of
root_territory = get_root_of("Territory")
- for parenttype in ["Sales Taxes and Charges Master", "Price List"]:
+ for parenttype in ["Sales Taxes and Charges Master", "Price List", "Shipping Rule"]:
for name in webnotes.conn.sql_list("""select name from `tab%s` main
where not exists (select parent from `tabFor Territory` territory
where territory.parenttype=%s and territory.parent=main.name)""" % \
diff --git a/patches/june_2013/p10_lead_address.py b/patches/june_2013/p10_lead_address.py
new file mode 100644
index 0000000000..516e2a68e1
--- /dev/null
+++ b/patches/june_2013/p10_lead_address.py
@@ -0,0 +1,50 @@
+import webnotes
+
+def execute():
+ webnotes.reload_doc("utilities", "doctype", "address")
+
+ webnotes.conn.auto_commit_on_many_writes = True
+
+ for lead in webnotes.conn.sql("""select name as lead, lead_name, address_line1, address_line2, city, country,
+ state, pincode, status, company_name from `tabLead` where not exists
+ (select name from `tabAddress` where `tabAddress`.lead=`tabLead`.name) and
+ (ifnull(address_line1, '')!='' or ifnull(city, '')!='' or ifnull(country, '')!='' or ifnull(pincode, '')!='')""", as_dict=True):
+ if set_in_customer(lead):
+ continue
+
+ create_address_for(lead)
+
+ webnotes.conn.auto_commit_on_many_writes = False
+
+def set_in_customer(lead):
+ customer = webnotes.conn.get_value("Customer", {"lead_name": lead.lead})
+ if customer:
+ customer_address = webnotes.conn.sql("""select name from `tabAddress`
+ where customer=%s and (address_line1=%s or address_line2=%s or pincode=%s)""",
+ (customer, lead.address_line1, lead.address_line2, lead.pincode))
+ if customer_address:
+ webnotes.conn.sql("""update `tabAddress` set lead=%s, lead_name=%s
+ where name=%s""", (lead.lead, lead.company_name or lead.lead_name, customer_address[0][0]))
+ return True
+
+ return False
+
+def create_address_for(lead):
+ address_title = lead.company_name or lead.lead_name or lead.lead
+
+ for c in ['%', "'", '"', '#', '*', '?', '`']:
+ address_title = address_title.replace(c, "")
+
+ if webnotes.conn.get_value("Address", address_title.strip() + "-" + "Billing"):
+ address_title += " " + lead.lead
+
+ lead.update({
+ "doctype": "Address",
+ "address_type": "Billing",
+ "address_title": address_title
+ })
+
+ del lead["company_name"]
+ del lead["status"]
+
+ webnotes.bean(lead).insert()
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 8979f43ea2..aaf5102f64 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -247,5 +247,8 @@ patch_list = [
"patches.june_2013.p06_drop_unused_tables",
"patches.june_2013.p08_shopping_cart_settings",
"patches.june_2013.p05_remove_search_criteria_reports",
+ "patches.june_2013.p07_taxes_price_list_for_territory",
+ "patches.june_2013.p08_shopping_cart_settings",
"patches.june_2013.p09_update_global_defaults",
+ "patches.june_2013.p10_lead_address",
]
\ No newline at end of file
diff --git a/public/js/startup.js b/public/js/startup.js
index 96953ad1d0..26e521981d 100644
--- a/public/js/startup.js
+++ b/public/js/startup.js
@@ -36,11 +36,18 @@ erpnext.startup.start = function() {
erpnext.toolbar.setup();
// complete registration
- if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete=='No')) {
+ if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete==='No')) {
wn.require("app/js/complete_setup.js");
erpnext.complete_setup.show();
- }
- if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
+ } else if(!wn.boot.customer_count) {
+ if(wn.get_route()[0]!=="Setup") {
+ msgprint(""
+ + wn._("Proceed to Setup") + "\
+
"+ + wn._("This message goes away after you create your first customer.")+ + "
", wn._("Welcome")); + } + } else if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) { var today = dateutil.str_to_obj(wn.boot.server_date); var expires_on = dateutil.str_to_obj(wn.boot.expires_on); var diff = dateutil.get_diff(expires_on, today); diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 65ac865304..10d2ce52fb 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -62,49 +62,6 @@ class DocType(TransactionBase): def validate(self): self.validate_values() - def create_customer_address(self): - addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode] - address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds)) - - if self.doc.phone_1: - address_line = address_line + "\n" + "Phone: " + cstr(self.doc.phone_1) - if self.doc.email_id: - address_line = address_line + "\n" + "E-mail: " + cstr(self.doc.email_id) - webnotes.conn.set(self.doc,'address', address_line) - - telephone = "(O): " + cstr(self.doc.phone_1) +"\n"+ cstr(self.doc.phone_2) + "\n" + "(M): " + "\n" + "(fax): " + cstr(self.doc.fax_1) - webnotes.conn.set(self.doc,'telephone',telephone) - - def create_p_contact(self,nm,phn_no,email_id,mob_no,fax,cont_addr): - c1 = Document('Contact') - c1.first_name = nm - c1.contact_name = nm - c1.contact_no = phn_no - c1.email_id = email_id - c1.mobile_no = mob_no - c1.fax = fax - c1.contact_address = cont_addr - c1.is_primary_contact = 'Yes' - c1.is_customer =1 - c1.customer = self.doc.name - c1.customer_name = self.doc.customer_name - c1.customer_address = self.doc.address - c1.customer_group = self.doc.customer_group - c1.save(1) - - def create_customer_contact(self): - contact = sql("select distinct name from `tabContact` where customer_name=%s", (self.doc.customer_name)) - contact = contact and contact[0][0] or '' - if not contact: - # create primary contact for individual customer - if self.doc.customer_type == 'Individual': - self.create_p_contact(self.doc.customer_name,self.doc.phone_1,self.doc.email_id,'',self.doc.fax_1,self.doc.address) - - # create primary contact for lead - elif self.doc.lead_name: - c_detail = sql("select lead_name, company_name, contact_no, mobile_no, email_id, fax, address from `tabLead` where name =%s", self.doc.lead_name, as_dict=1) - self.create_p_contact(c_detail and c_detail[0]['lead_name'] or '', c_detail and c_detail[0]['contact_no'] or '', c_detail and c_detail[0]['email_id'] or '', c_detail and c_detail[0]['mobile_no'] or '', c_detail and c_detail[0]['fax'] or '', c_detail and c_detail[0]['address'] or '') - def update_lead_status(self): if self.doc.lead_name: sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name) @@ -139,31 +96,16 @@ class DocType(TransactionBase): def create_lead_address_contact(self): if self.doc.lead_name: - details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, phone, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1) - d = Document('Address') - d.address_line1 = details[0]['address_line1'] - d.address_line2 = details[0]['address_line2'] - d.city = details[0]['city'] - d.country = details[0]['country'] - d.pincode = details[0]['pincode'] - d.state = details[0]['state'] - d.fax = details[0]['fax'] - d.email_id = details[0]['email_id'] - d.phone = details[0]['phone'] - d.customer = self.doc.name - d.customer_name = self.doc.customer_name - d.is_primary_address = 1 - d.address_type = 'Office' - try: - d.save(1) - except NameError, e: - pass - + if not webnotes.conn.get_value("Address", {"lead": self.doc.lead_name, "customer": self.doc.customer}): + webnotes.conn.sql("""update `tabAddress` set customer=%s, customer_name=%s where lead=%s""", + (self.doc.name, self.doc.customer_name, self.doc.lead_name)) + + lead = webnotes.conn.get_value("Lead", self.doc.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True) c = Document('Contact') - c.first_name = details[0]['lead_name'] - c.email_id = details[0]['email_id'] - c.phone = details[0]['phone'] - c.mobile_no = details[0]['mobile_no'] + c.first_name = lead.lead_name + c.email_id = lead.email_id + c.phone = lead.phone + c.mobile_no = lead.mobile_no c.customer = self.doc.name c.customer_name = self.doc.customer_name c.is_primary_contact = 1 diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index c94aafa08a..8fb26c5a89 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -14,78 +14,79 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, seeSales Email Settings
\
- Automatically extract Leads from a mail box e.g. "sales@example.com"
Sales Email Settings
\
+ Automatically extract Leads from a mail box e.g. "sales@example.com"