mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-30 03:58:26 +00:00
Merge branch 'edge' of github.com:webnotes/erpnext into webshop
Conflicts: stock/doctype/item/item.txt
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
}]
|
||||
]
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-03 14:38:34",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-03 15:15:11",
|
||||
"modified": "2013-05-07 11:19:40",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -11,7 +11,7 @@
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Currency:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Currency:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc",
|
||||
"query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Float:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc",
|
||||
"ref_doctype": "Sales Order",
|
||||
"report_name": "Item-wise Sales History",
|
||||
"report_type": "Query Report"
|
||||
|
||||
@@ -32,8 +32,8 @@ def get_columns(filters):
|
||||
|
||||
return [filters["doc_type"] + ":Link/" + filters["doc_type"] + ":140",
|
||||
"Customer:Link/Customer:140", "Territory:Link/Territory:100", "Posting Date:Date:100",
|
||||
"Item Code:Link/Item:120", "Qty:Currency:100", "Amount:Currency:120",
|
||||
"Sales Person:Link/Sales Person:140", "Contribution %:Currency:110",
|
||||
"Item Code:Link/Item:120", "Qty:Float:100", "Amount:Currency:120",
|
||||
"Sales Person:Link/Sales Person:140", "Contribution %:Float:110",
|
||||
"Contribution Amount:Currency:140"]
|
||||
|
||||
def get_entries(filters):
|
||||
|
||||
Reference in New Issue
Block a user