mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
[usability] item price moved to price list
This commit is contained in:
@@ -1,26 +1,6 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.provide("erpnext.stock");
|
||||
|
||||
erpnext.stock.Item = wn.ui.form.Controller.extend({
|
||||
onload: function() {
|
||||
this.frm.add_fetch("price_list", "currency", "ref_currency");
|
||||
this.frm.add_fetch("price_list", "buying_or_selling", "buying_or_selling");
|
||||
},
|
||||
|
||||
ref_rate_details_add: function(doc, cdt, cdn) {
|
||||
var row = wn.model.get_doc(cdt, cdn);
|
||||
if(row.price_list && !row.ref_currency) {
|
||||
// execute fetch
|
||||
var df = wn.meta.get_docfield(row.doctype, "price_list", row.parent);
|
||||
this.frm.script_manager.validate_link_and_fetch(df, row.name, row.price_list);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cur_frm.script_manager.make(erpnext.stock.Item);
|
||||
|
||||
cur_frm.cscript.refresh = function(doc) {
|
||||
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
|
||||
// read only if any stock ledger entry exists
|
||||
|
||||
@@ -11,7 +11,6 @@ from webnotes import msgprint, _
|
||||
|
||||
from webnotes.model.controller import DocListController
|
||||
|
||||
class PriceListCurrencyMismatch(Exception): pass
|
||||
class WarehouseNotSet(Exception): pass
|
||||
|
||||
class DocType(DocListController):
|
||||
@@ -32,9 +31,8 @@ class DocType(DocListController):
|
||||
self.check_stock_uom_with_bin()
|
||||
self.validate_conversion_factor()
|
||||
self.add_default_uom_in_conversion_factor_table()
|
||||
self.valiadte_item_type()
|
||||
self.validate_item_type()
|
||||
self.check_for_active_boms()
|
||||
self.validate_price_lists()
|
||||
self.fill_customer_code()
|
||||
self.check_item_tax()
|
||||
self.validate_barcode()
|
||||
@@ -87,7 +85,7 @@ class DocType(DocListController):
|
||||
As UOM: %s is not Stock UOM of Item: %s""" %
|
||||
(d.uom, d.uom, self.doc.name)), raise_exception=1)
|
||||
|
||||
def valiadte_item_type(self):
|
||||
def validate_item_type(self):
|
||||
if cstr(self.doc.is_manufactured_item) == "No":
|
||||
self.doc.is_pro_applicable = "No"
|
||||
|
||||
@@ -125,22 +123,7 @@ class DocType(DocListController):
|
||||
'is_pro_applicable' :'Allow Production Order'}
|
||||
for d in fl:
|
||||
if cstr(self.doc.fields.get(d)) != 'Yes':
|
||||
_check_for_active_boms(fl[d])
|
||||
|
||||
def validate_price_lists(self):
|
||||
price_lists=[]
|
||||
for d in getlist(self.doclist,'ref_rate_details'):
|
||||
if d.price_list in price_lists:
|
||||
msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list,
|
||||
raise_exception= webnotes.DuplicateEntryError)
|
||||
else:
|
||||
price_list_currency = webnotes.conn.get_value("Price List", d.price_list, "currency")
|
||||
if price_list_currency and d.ref_currency != price_list_currency:
|
||||
msgprint(_("Currency does not match Price List Currency for Price List") \
|
||||
+ ": " + d.price_list, raise_exception=PriceListCurrencyMismatch)
|
||||
|
||||
price_lists.append(d.price_list)
|
||||
|
||||
_check_for_active_boms(fl[d])
|
||||
|
||||
def fill_customer_code(self):
|
||||
""" Append all the customer codes and insert into "customer_code" field of item table """
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-03 10:45:46",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-30 16:21:38",
|
||||
"modified": "2013-09-11 11:50:10",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -625,25 +625,6 @@
|
||||
"options": "Item Tax",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Price Lists and Rates",
|
||||
"options": "icon-money",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "ref_rate_details",
|
||||
"fieldtype": "Table",
|
||||
"label": "Item Prices",
|
||||
"oldfieldname": "ref_rate_details",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "Item Price",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "inspection_criteria",
|
||||
|
||||
@@ -9,20 +9,6 @@ test_ignore = ["BOM"]
|
||||
test_dependencies = ["Warehouse"]
|
||||
|
||||
class TestItem(unittest.TestCase):
|
||||
def test_duplicate_price_list(self):
|
||||
item = webnotes.bean(copy=test_records[0])
|
||||
item.doc.item_code = "_Test Item 10"
|
||||
item_price = item.doclist.get({"doctype": "Item Price"})[0]
|
||||
item.doclist.append(webnotes.doc(item_price.fields.copy()))
|
||||
self.assertRaises(webnotes.DuplicateEntryError, item.insert)
|
||||
|
||||
def test_price_list_mismatch(self):
|
||||
from stock.doctype.item.item import PriceListCurrencyMismatch
|
||||
item = webnotes.bean(copy=test_records[0])
|
||||
item.doc.item_code = "_Test Item 11"
|
||||
item_price = item.doclist.get({"doctype": "Item Price"})[0].ref_currency="USD"
|
||||
self.assertRaises(PriceListCurrencyMismatch, item.insert)
|
||||
|
||||
def test_default_warehouse(self):
|
||||
from stock.doctype.item.item import WarehouseNotSet
|
||||
item = webnotes.bean(copy=test_records[0])
|
||||
@@ -57,14 +43,7 @@ test_records = [
|
||||
"warehouse_reorder_level": 20,
|
||||
"warehouse_reorder_qty": 20,
|
||||
"material_request_type": "Purchase"
|
||||
}, {
|
||||
"doctype": "Item Price",
|
||||
"parentfield": "ref_rate_details",
|
||||
"price_list": "_Test Price List",
|
||||
"ref_rate": 100,
|
||||
"ref_currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
}
|
||||
},
|
||||
],
|
||||
[{
|
||||
"doctype": "Item",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Price of the Item in a particular Price List.
|
||||
@@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -1,9 +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
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
@@ -1,78 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-05-02 16:29:48",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-09 14:46:58",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"autoname": "RFD/.#####",
|
||||
"doctype": "DocType",
|
||||
"in_create": 0,
|
||||
"istable": 1,
|
||||
"module": "Stock",
|
||||
"name": "__common__",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"in_list_view": 1,
|
||||
"name": "__common__",
|
||||
"parent": "Item Price",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Item Price"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list",
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
"label": "Price List Name",
|
||||
"oldfieldname": "price_list_name",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Price List",
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "ref_rate",
|
||||
"fieldtype": "Currency",
|
||||
"in_filter": 1,
|
||||
"label": "Ref Rate",
|
||||
"oldfieldname": "ref_rate",
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "ref_currency",
|
||||
"reqd": 1,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "ref_currency",
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
"label": "Currency",
|
||||
"oldfieldname": "ref_currency",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Currency",
|
||||
"read_only": 1,
|
||||
"reqd": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"default": "Selling",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "buying_or_selling",
|
||||
"fieldtype": "Select",
|
||||
"label": "Valid for Buying or Selling?",
|
||||
"options": "Buying\nSelling",
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user