mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 04:39:11 +00:00
Merge branch 'develop' into crm-carry-forward-communication-comments
This commit is contained in:
@@ -8,7 +8,6 @@ from frappe.contacts.address_and_contact import load_address_and_contact
|
||||
from frappe.email.inbox import link_communication_to_document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.utils import (
|
||||
cint,
|
||||
comma_and,
|
||||
cstr,
|
||||
get_link_to_form,
|
||||
@@ -39,11 +38,7 @@ class Lead(SellingController):
|
||||
self.check_email_id_is_unique()
|
||||
self.validate_email_id()
|
||||
self.validate_contact_date()
|
||||
self._prev = frappe._dict({
|
||||
"contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if (not cint(self.is_new())) else None,
|
||||
"ends_on": frappe.db.get_value("Lead", self.name, "ends_on") if (not cint(self.is_new())) else None,
|
||||
"contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if (not cint(self.is_new())) else None,
|
||||
})
|
||||
self.set_prev()
|
||||
|
||||
def set_full_name(self):
|
||||
if self.first_name:
|
||||
@@ -75,6 +70,16 @@ class Lead(SellingController):
|
||||
self.add_calendar_event()
|
||||
self.update_prospects()
|
||||
|
||||
def set_prev(self):
|
||||
if self.is_new():
|
||||
self._prev = frappe._dict({
|
||||
"contact_date": None,
|
||||
"ends_on": None,
|
||||
"contact_by": None
|
||||
})
|
||||
else:
|
||||
self._prev = frappe.db.get_value("Lead", self.name, ["contact_date", "ends_on", "contact_by"], as_dict=1)
|
||||
|
||||
def before_insert(self):
|
||||
self.contact_doc = self.create_contact()
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
QUnit.module("sales");
|
||||
|
||||
QUnit.test("test: lead", function (assert) {
|
||||
assert.expect(4);
|
||||
let done = assert.async();
|
||||
let lead_name = frappe.utils.get_random(10);
|
||||
frappe.run_serially([
|
||||
// test lead creation
|
||||
() => frappe.set_route("List", "Lead"),
|
||||
() => frappe.new_doc("Lead"),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("lead_name", lead_name),
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
assert.ok(cur_frm.doc.lead_name.includes(lead_name),
|
||||
'name correctly set');
|
||||
frappe.lead_name = cur_frm.doc.name;
|
||||
},
|
||||
// create address and contact
|
||||
() => frappe.click_link('Address & Contact'),
|
||||
() => frappe.click_button('New Address'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.set_control('address_line1', 'Gateway'),
|
||||
() => frappe.set_control('city', 'Mumbai'),
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(3),
|
||||
() => assert.equal(frappe.get_route()[1], 'Lead',
|
||||
'back to lead form'),
|
||||
() => frappe.click_link('Address & Contact'),
|
||||
() => assert.ok($('.address-box').text().includes('Mumbai'),
|
||||
'city is seen in address box'),
|
||||
|
||||
// make opportunity
|
||||
() => frappe.click_button('Make'),
|
||||
() => frappe.click_link('Opportunity'),
|
||||
() => frappe.timeout(2),
|
||||
() => assert.equal(cur_frm.doc.lead, frappe.lead_name,
|
||||
'lead name correctly mapped'),
|
||||
|
||||
() => done()
|
||||
]);
|
||||
});
|
||||
@@ -1,55 +0,0 @@
|
||||
QUnit.module("sales");
|
||||
|
||||
QUnit.test("test: lead", function (assert) {
|
||||
assert.expect(5);
|
||||
let done = assert.async();
|
||||
let lead_name = frappe.utils.get_random(10);
|
||||
frappe.run_serially([
|
||||
// test lead creation
|
||||
() => frappe.set_route("List", "Lead"),
|
||||
() => frappe.new_doc("Lead"),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("company_name", lead_name),
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
assert.ok(cur_frm.doc.lead_name.includes(lead_name),
|
||||
'name correctly set');
|
||||
frappe.lead_name = cur_frm.doc.name;
|
||||
},
|
||||
// create address and contact
|
||||
() => frappe.click_link('Address & Contact'),
|
||||
() => frappe.click_button('New Address'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.set_control('address_line1', 'Gateway'),
|
||||
() => frappe.set_control('city', 'Mumbai'),
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(3),
|
||||
() => assert.equal(frappe.get_route()[1], 'Lead',
|
||||
'back to lead form'),
|
||||
() => frappe.click_link('Address & Contact'),
|
||||
() => assert.ok($('.address-box').text().includes('Mumbai'),
|
||||
'city is seen in address box'),
|
||||
|
||||
() => frappe.click_button('New Contact'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.set_control('first_name', 'John'),
|
||||
() => frappe.set_control('last_name', 'Doe'),
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(3),
|
||||
() => frappe.set_route('Form', 'Lead', cur_frm.doc.links[0].link_name),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_link('Address & Contact'),
|
||||
() => assert.ok($('.address-box').text().includes('John'),
|
||||
'contact is seen in contact box'),
|
||||
|
||||
// make customer
|
||||
() => frappe.click_button('Make'),
|
||||
() => frappe.click_link('Customer'),
|
||||
() => frappe.timeout(2),
|
||||
() => assert.equal(cur_frm.doc.lead_name, frappe.lead_name,
|
||||
'lead name correctly mapped'),
|
||||
|
||||
() => done()
|
||||
]);
|
||||
});
|
||||
@@ -1,56 +0,0 @@
|
||||
QUnit.test("test: opportunity", function (assert) {
|
||||
assert.expect(8);
|
||||
let done = assert.async();
|
||||
frappe.run_serially([
|
||||
() => frappe.set_route('List', 'Opportunity'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('New'),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value('opportunity_from', 'Customer'),
|
||||
() => cur_frm.set_value('customer', 'Test Customer 1'),
|
||||
|
||||
// check items
|
||||
() => cur_frm.set_value('with_items', 1),
|
||||
() => frappe.tests.set_grid_values(cur_frm, 'items', [
|
||||
[
|
||||
{item_code:'Test Product 1'},
|
||||
{qty: 4}
|
||||
]
|
||||
]),
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
assert.notOk(cur_frm.is_new(), 'saved');
|
||||
frappe.opportunity_name = cur_frm.doc.name;
|
||||
},
|
||||
|
||||
// close and re-open
|
||||
() => frappe.click_button('Close'),
|
||||
() => frappe.timeout(1),
|
||||
() => assert.equal(cur_frm.doc.status, 'Closed',
|
||||
'closed'),
|
||||
|
||||
() => frappe.click_button('Reopen'),
|
||||
() => assert.equal(cur_frm.doc.status, 'Open',
|
||||
'reopened'),
|
||||
() => frappe.timeout(1),
|
||||
|
||||
// make quotation
|
||||
() => frappe.click_button('Make'),
|
||||
() => frappe.click_link('Quotation', 1),
|
||||
() => frappe.timeout(2),
|
||||
() => {
|
||||
assert.equal(frappe.get_route()[1], 'Quotation',
|
||||
'made quotation');
|
||||
assert.equal(cur_frm.doc.customer, 'Test Customer 1',
|
||||
'customer set in quotation');
|
||||
assert.equal(cur_frm.doc.items[0].item_code, 'Test Product 1',
|
||||
'item set in quotation');
|
||||
assert.equal(cur_frm.doc.items[0].qty, 4,
|
||||
'qty set in quotation');
|
||||
assert.equal(cur_frm.doc.items[0].prevdoc_docname, frappe.opportunity_name,
|
||||
'opportunity set in quotation');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user