Merge branch '1310' of github.com:webnotes/erpnext

Conflicts:
	setup/doctype/setup_control/setup_control.py
	stock/doctype/stock_entry/stock_entry.py
	utilities/demo/demo_docs/Price_List.csv
This commit is contained in:
Anand Doshi
2013-11-04 13:14:39 +05:30
37 changed files with 84 additions and 49 deletions

View File

@@ -1,5 +1,5 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
# MIT License. See license.txt
# For license information, please see license.txt

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-06-20 12:48:38",
"docstatus": 0,
"modified": "2013-07-10 14:54:09",
"modified": "2013-10-31 18:56:54",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -20,7 +20,7 @@
"label": "Territory",
"name": "__common__",
"options": "Territory",
"parent": "For Territory",
"parent": "Applicable Territory",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0,
@@ -28,7 +28,7 @@
},
{
"doctype": "DocType",
"name": "For Territory"
"name": "Applicable Territory"
},
{
"doctype": "DocField"

View File

@@ -1 +0,0 @@
Price of the Item in a particular Price List.

View File

@@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@@ -1,16 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// License: GNU General Public License v3. See license.txt
$.extend(cur_frm.cscript, {
onload: function () {
// Fetch price list details
cur_frm.add_fetch("price_list", "buying_or_selling", "buying_or_selling");
cur_frm.add_fetch("price_list", "currency", "currency");
// Fetch item details
cur_frm.add_fetch("item_code", "item_name", "item_name");
cur_frm.add_fetch("item_code", "description", "item_description");
}
});

View File

@@ -1,35 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# MIT License. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
class ItemPriceDuplicateItem(Exception): pass
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
self.check_duplicate_item()
self.update_price_list_details()
self.update_item_details()
def update_price_list_details(self):
self.doc.buying_or_selling, self.doc.currency = webnotes.conn.get_value("Price List",
self.doc.price_list, ["buying_or_selling", "currency"])
def update_item_details(self):
self.doc.item_name, self.doc.item_description = webnotes.conn.get_value("Item",
self.doc.item_code, ["item_name", "description"])
def check_duplicate_item(self):
if webnotes.conn.sql("""select name from `tabItem Price`
where item_code=%s and price_list=%s and name!=%s""",
(self.doc.item_code, self.doc.price_list, self.doc.name)):
webnotes.throw(_("Duplicate Item: ") + self.doc.item_code +
_(" already available in Price List: ") + self.doc.price_list,
ItemPriceDuplicateItem)

View File

@@ -1,127 +0,0 @@
[
{
"creation": "2013-05-02 16:29:48",
"docstatus": 0,
"modified": "2013-10-21 15:11:20",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"autoname": "RFD/.#####",
"description": "Multiple Item prices.",
"doctype": "DocType",
"document_type": "Master",
"icon": "icon-flag",
"in_create": 0,
"istable": 0,
"module": "Setup",
"name": "__common__",
"read_only": 0
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Item Price",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Item Price",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"write": 1
},
{
"doctype": "DocType",
"name": "Item Price"
},
{
"doctype": "DocField",
"fieldname": "price_list",
"fieldtype": "Link",
"in_filter": 1,
"label": "Price List",
"options": "Price List",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "item_code",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"label": "Item Code",
"oldfieldname": "price_list_name",
"oldfieldtype": "Select",
"options": "Item",
"reqd": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "ref_rate",
"fieldtype": "Currency",
"in_filter": 1,
"in_list_view": 1,
"label": "Rate",
"oldfieldname": "ref_rate",
"oldfieldtype": "Currency",
"options": "currency",
"reqd": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "col_br_1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "buying_or_selling",
"fieldtype": "Select",
"in_filter": 1,
"in_list_view": 1,
"label": "Valid for Buying or Selling?",
"options": "Selling\nBuying",
"reqd": 0
},
{
"doctype": "DocField",
"fieldname": "item_name",
"fieldtype": "Data",
"label": "Item Name",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "item_description",
"fieldtype": "Text",
"label": "Item Description",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "currency",
"fieldtype": "Link",
"hidden": 1,
"label": "Currency",
"options": "Currency",
"read_only": 1
},
{
"doctype": "DocPerm",
"role": "Sales Master Manager"
},
{
"doctype": "DocPerm",
"role": "Purchase Master Manager"
}
]

View File

@@ -1,23 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import unittest
import webnotes
from setup.doctype.item_price.item_price import ItemPriceDuplicateItem
class TestItem(unittest.TestCase):
def test_duplicate_item(self):
item_price = webnotes.bean(copy=test_records[0])
self.assertRaises(ItemPriceDuplicateItem, item_price.insert)
test_records = [
[
{
"doctype": "Item Price",
"price_list": "_Test Price List",
"item_code": "_Test Item",
"ref_rate": 100
}
]
]

View File

@@ -1 +0,0 @@
Item Price List master. Price Lists can be defined per Country, Currency.

View File

@@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@@ -1,7 +0,0 @@
.table-grid tbody tr {
cursor: pointer;
}
.table-grid thead tr {
height: 50px;
}

View File

@@ -1,17 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// License: GNU General Public License v3. See license.txt
$.extend(cur_frm.cscript, {
onload: function() {
erpnext.add_for_territory();
},
refresh: function() {
cur_frm.add_custom_button("Add / Edit Prices", function() {
wn.route_options = {
"price_list": cur_frm.doc.name
};
wn.set_route("Report", "Item Price");
}, "icon-money");
}
});

View File

@@ -1,48 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
from webnotes.utils import comma_or, cint
from webnotes.model.controller import DocListController
import webnotes.defaults
class DocType(DocListController):
def validate(self):
if self.doc.buying_or_selling not in ["Buying", "Selling"]:
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
comma_or(["Buying", "Selling"]), raise_exception=True)
if not self.doclist.get({"parentfield": "valid_for_territories"}):
# if no territory, set default territory
if webnotes.defaults.get_user_default("territory"):
self.doclist.append({
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": webnotes.defaults.get_user_default("territory")
})
else:
# at least one territory
self.validate_table_has_rows("valid_for_territories")
def on_update(self):
self.set_default_if_missing()
self.update_item_price()
cart_settings = webnotes.get_obj("Shopping Cart Settings")
if cint(cart_settings.doc.enabled):
cart_settings.validate_price_lists()
def set_default_if_missing(self):
if self.doc.buying_or_selling=="Selling":
if not webnotes.conn.get_value("Selling Settings", None, "selling_price_list"):
webnotes.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.doc.name)
elif self.doc.buying_or_selling=="Buying":
if not webnotes.conn.get_value("Buying Settings", None, "buying_price_list"):
webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name)
def update_item_price(self):
webnotes.conn.sql("""update `tabItem Price` set currency=%s,
buying_or_selling=%s where price_list=%s""",
(self.doc.currency, self.doc.buying_or_selling, self.doc.name))

View File

@@ -1,116 +0,0 @@
[
{
"creation": "2013-01-25 11:35:09",
"docstatus": 0,
"modified": "2013-10-18 13:33:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 0,
"allow_copy": 0,
"allow_email": 1,
"allow_print": 1,
"autoname": "field:price_list_name",
"description": "Price List Master",
"doctype": "DocType",
"document_type": "Master",
"icon": "icon-tags",
"max_attachments": 1,
"module": "Setup",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Price List",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"doctype": "DocPerm",
"name": "__common__",
"parent": "Price List",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1
},
{
"doctype": "DocType",
"name": "Price List"
},
{
"doctype": "DocField",
"fieldname": "price_list_name",
"fieldtype": "Data",
"label": "Price List Name",
"oldfieldname": "price_list_name",
"oldfieldtype": "Data",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "currency",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Currency",
"options": "Currency",
"reqd": 1
},
{
"default": "Selling",
"doctype": "DocField",
"fieldname": "buying_or_selling",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Valid for Buying or Selling?",
"options": "Buying\nSelling",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"description": "Specify a list of Territories, for which, this Price List is valid",
"doctype": "DocField",
"fieldname": "valid_for_territories",
"fieldtype": "Table",
"label": "Valid for Territories",
"options": "For Territory",
"reqd": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Sales User",
"submit": 0,
"write": 0
},
{
"amend": 0,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales Master Manager",
"submit": 0,
"write": 1
},
{
"doctype": "DocPerm",
"role": "Purchase User"
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Purchase Master Manager",
"write": 1
}
]

View File

@@ -1,67 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
# test_ignore = ["Item"]
test_records = [
[
{
"doctype": "Price List",
"price_list_name": "_Test Price List",
"currency": "INR",
"buying_or_selling": "Selling"
},
{
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": "All Territories"
},
],
[
{
"doctype": "Price List",
"price_list_name": "_Test Price List 2",
"currency": "INR",
"buying_or_selling": "Selling"
},
{
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": "_Test Territory Rest of the World"
}
],
[
{
"doctype": "Price List",
"price_list_name": "_Test Price List India",
"currency": "INR",
"buying_or_selling": "Selling"
},
{
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": "_Test Territory India"
}
],
[
{
"doctype": "Price List",
"price_list_name": "_Test Price List Rest of the World",
"currency": "USD",
"buying_or_selling": "Selling"
},
{
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": "_Test Territory Rest of the World"
},
{
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": "_Test Territory United States"
}
],
]

View File

@@ -108,7 +108,7 @@ def create_price_lists(args):
"currency": args["currency"]
},
{
"doctype": "For Territory",
"doctype": "Applicable Territory",
"parentfield": "valid_for_territories",
"territory": "All Territories"
}