[merge] merge with master

This commit is contained in:
Rushabh Mehta
2013-05-24 16:09:13 +05:30
120 changed files with 1431 additions and 712 deletions

View File

@@ -216,7 +216,7 @@ class DocType(TransactionBase):
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
def on_rename(self, new, old):
def on_rename(self, new, old, merge=False):
#update customer_name if not naming series
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
update_fields = [
@@ -244,7 +244,7 @@ class DocType(TransactionBase):
for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
if account.account_name != new:
webnotes.rename_doc("Account", account.name, new)
webnotes.rename_doc("Account", account.name, new, merge=merge)
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,

View File

@@ -1,4 +1,60 @@
from __future__ import unicode_literals
import webnotes
import unittest
class TestCustomer(unittest.TestCase):
def test_rename(self):
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"),
(("_Test Customer 1",),))
webnotes.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed")
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1 Renamed"),
(("_Test Customer 1 Renamed",),))
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), ())
def test_merge(self):
from webnotes.test_runner import make_test_records
make_test_records("Sales Invoice")
# clear transactions for new name
webnotes.conn.sql("""delete from `tabSales Invoice` where customer='_Test Customer 1'""")
# check if they exist
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"),
(("_Test Customer",),))
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"),
(("_Test Customer 1",),))
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"),
(("_Test Customer - _TC",),))
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer 1 - _TC"),
(("_Test Customer 1 - _TC",),))
# check if transactions exists
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where customer='_Test Customer'""", )[0][0], 0)
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where debit_to='_Test Customer - _TC'""", )[0][0], 0)
webnotes.rename_doc("Customer", "_Test Customer", "_Test Customer 1", merge=True)
# check that no transaction exists for old name
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where customer='_Test Customer 1'""", )[0][0], 0)
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where debit_to='_Test Customer 1 - _TC'""", )[0][0], 0)
# check that transactions exist for new name
self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where customer='_Test Customer'""", )[0][0], 0)
self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where debit_to='_Test Customer - _TC'""", )[0][0], 0)
# check that old name doesn't exist
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ())
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ())
test_records = [
[{
"doctype": "Customer",
@@ -7,5 +63,13 @@ test_records = [
"customer_group": "_Test Customer Group",
"territory": "_Test Territory",
"company": "_Test Company"
}],
[{
"doctype": "Customer",
"customer_name": "_Test Customer 1",
"customer_type": "Individual",
"customer_group": "_Test Customer Group",
"territory": "_Test Territory",
"company": "_Test Company"
}]
]

View File

@@ -18,9 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, getdate
from webnotes.model import db_exists
from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist, copy_doclist
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from stock.utils import get_valid_serial_nos
@@ -37,9 +35,6 @@ class DocType(TransactionBase):
self.tname = 'Installation Note Item'
self.fname = 'installed_item_details'
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def validate(self):
self.validate_fiscal_year()
self.validate_installation_date()

View File

@@ -1,13 +1,13 @@
[
{
"creation": "2013-01-10 16:34:18",
"creation": "2013-04-30 13:13:06",
"docstatus": 0,
"modified": "2013-01-22 14:56:02",
"modified": "2013-05-09 14:43:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"autoname": "IN/.####",
"autoname": "naming_series:",
"doctype": "DocType",
"is_submittable": 1,
"module": "Selling",
@@ -33,6 +33,7 @@
"permlevel": 0,
"read": 1,
"report": 1,
"role": "Sales User",
"submit": 1,
"write": 1
},
@@ -302,15 +303,6 @@
"options": "Installation Note Item"
},
{
"doctype": "DocPerm",
"role": "System Manager"
},
{
"doctype": "DocPerm",
"role": "Sales User"
},
{
"doctype": "DocPerm",
"role": "Sales Manager"
"doctype": "DocPerm"
}
]

View File

@@ -104,7 +104,17 @@ cur_frm.cscript['Create Customer'] = function(){
'from_to_list':"[['Lead', 'Customer']]"
},
function(r,rt) {
loaddoc("Customer", n);
wn.model.with_doctype("Customer", function() {
var customer = wn.model.get_doc("Customer", n);
var customer_copy = $.extend({}, customer);
var updated = wn.model.set_default_values(customer_copy);
$.each(updated, function(i, f) {
if(!customer[f]) customer[f] = customer_copy[f];
});
loaddoc("Customer", n);
});
}
);
}

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-04-03 09:10:44",
"creation": "2013-05-22 12:10:46",
"docstatus": 0,
"modified": "2013-04-03 09:58:02",
"modified": "2013-05-22 16:54:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -833,12 +833,11 @@
"width": "100px"
},
{
"description": "Keep a track on communications regarding this Quotation. This will help you remember earlier communications in case the Customer comes back again",
"doctype": "DocField",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"label": "Communication History",
"oldfieldtype": "Section Break",
"options": "Simple",
"print_hide": 1,
"read_only": 0
},
@@ -869,28 +868,23 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales Manager",
"role": "Sales User",
"submit": 1,
"write": 1
},
{
"doctype": "DocPerm",
"role": "Customer"
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales User",
"role": "Sales Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Customer",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-02-22 01:27:52",
"creation": "2013-03-07 11:42:57",
"docstatus": 0,
"modified": "2013-03-07 07:03:29",
"modified": "2013-05-22 12:08:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -37,6 +37,7 @@
"options": "Item",
"print_hide": 0,
"print_width": "150px",
"read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "150px"
@@ -60,6 +61,7 @@
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150px",
"read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "150px"
@@ -73,6 +75,7 @@
"oldfieldtype": "Small Text",
"print_hide": 0,
"print_width": "300px",
"read_only": 0,
"reqd": 1,
"width": "300px"
},
@@ -87,6 +90,7 @@
"oldfieldtype": "Currency",
"print_hide": 0,
"print_width": "100px",
"read_only": 0,
"reqd": 1,
"search_index": 0,
"width": "100px"
@@ -115,6 +119,7 @@
"options": "currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"reqd": 0,
"width": "100px"
},
@@ -128,6 +133,7 @@
"oldfieldtype": "Float",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"width": "100px"
},
{
@@ -142,6 +148,7 @@
"options": "currency",
"print_hide": 0,
"print_width": "100px",
"read_only": 0,
"reqd": 0,
"search_index": 0,
"width": "100px"
@@ -188,6 +195,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"reqd": 0,
"search_index": 0,
"width": "100px"
@@ -291,6 +299,7 @@
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
}
]

View File

@@ -217,7 +217,10 @@ class DocType(SellingController):
self.validate_proj_cust()
self.validate_po()
#self.validate_reference_value()
self.validate_for_items()
if self.doc.docstatus == 1:
self.validate_for_items()
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-02-22 01:27:52",
"creation": "2013-03-07 11:42:58",
"docstatus": 0,
"modified": "2013-03-07 07:03:30",
"modified": "2013-05-22 12:09:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -35,6 +35,7 @@
"oldfieldtype": "Link",
"options": "Item",
"print_width": "150px",
"read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "150px"
@@ -57,6 +58,7 @@
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150",
"read_only": 0,
"reqd": 1,
"width": "150"
},
@@ -69,6 +71,7 @@
"oldfieldname": "description",
"oldfieldtype": "Small Text",
"print_width": "300px",
"read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "300px"
@@ -82,6 +85,7 @@
"oldfieldname": "qty",
"oldfieldtype": "Currency",
"print_width": "100px",
"read_only": 0,
"reqd": 1,
"width": "100px"
},
@@ -109,6 +113,7 @@
"options": "currency",
"print_hide": 1,
"print_width": "70px",
"read_only": 0,
"reqd": 0,
"width": "70px"
},
@@ -122,6 +127,7 @@
"oldfieldtype": "Float",
"print_hide": 1,
"print_width": "70px",
"read_only": 0,
"width": "70px"
},
{
@@ -134,6 +140,7 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_width": "100px",
"read_only": 0,
"reqd": 0,
"width": "100px"
},
@@ -176,6 +183,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"reqd": 0,
"width": "100px"
},
@@ -206,6 +214,7 @@
"options": "Warehouse",
"print_hide": 1,
"print_width": "150px",
"read_only": 0,
"reqd": 0,
"width": "150px"
},
@@ -329,6 +338,7 @@
"hidden": 0,
"in_filter": 1,
"label": "Quotation No.",
"no_copy": 1,
"oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link",
"options": "Quotation",
@@ -345,6 +355,7 @@
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{