mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
Price List and Item Price : Validfor Buying and Selling as separate check box
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
// 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", "buying", "buying");
|
||||
cur_frm.add_fetch("price_list", "selling", "selling");
|
||||
cur_frm.add_fetch("price_list", "currency", "currency");
|
||||
|
||||
// Fetch item details
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
# For license information, please see license.txt
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
@@ -19,8 +17,11 @@ class DocType:
|
||||
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"])
|
||||
if not self.doc.selling and not self.doc.buying:
|
||||
self.doc.buying, self.doc.selling = webnotes.conn.get_value("Price List",
|
||||
self.doc.price_list, ["buying", "selling"])
|
||||
|
||||
self.doc.currency = webnotes.conn.get_value("Price List", self.doc.price_list, "currency")
|
||||
|
||||
def update_item_details(self):
|
||||
self.doc.item_name, self.doc.item_description = webnotes.conn.get_value("Item",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-02 16:29:48",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-10-31 12:59:02",
|
||||
"modified": "2014-01-07 18:11:10",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -43,6 +43,13 @@
|
||||
"doctype": "DocType",
|
||||
"name": "Item Price"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Price List",
|
||||
"options": "icon-tags"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list",
|
||||
@@ -52,6 +59,27 @@
|
||||
"options": "Price List",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "buying",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Buying"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "selling",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Selling"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Item",
|
||||
"options": "icon-tag"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_code",
|
||||
@@ -83,16 +111,6 @@
|
||||
"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",
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
.table-grid tbody tr {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table-grid thead tr {
|
||||
height: 50px;
|
||||
}
|
||||
@@ -3,16 +3,15 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes import msgprint, _, throw
|
||||
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.doc.buying and not self.doc.selling:
|
||||
throw(_("Price List must be one of Buying or Selling"))
|
||||
|
||||
if not self.doclist.get({"parentfield": "valid_for_territories"}):
|
||||
# if no territory, set default territory
|
||||
@@ -34,15 +33,15 @@ class DocType(DocListController):
|
||||
cart_settings.validate_price_lists()
|
||||
|
||||
def set_default_if_missing(self):
|
||||
if self.doc.buying_or_selling=="Selling":
|
||||
if self.doc.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":
|
||||
elif self.doc.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, modified=NOW() where price_list=%s""",
|
||||
(self.doc.currency, self.doc.buying_or_selling, self.doc.name))
|
||||
buying=%s, selling=%s, modified=NOW() where price_list=%s""",
|
||||
(self.doc.currency, self.doc.buying, self.doc.selling, self.doc.name))
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-25 11:35:09",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-10-31 19:24:33",
|
||||
"modified": "2014-01-06 18:28:23",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -61,14 +61,19 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "Selling",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "buying_or_selling",
|
||||
"fieldtype": "Select",
|
||||
"fieldname": "buying",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Valid for Buying or Selling?",
|
||||
"options": "Buying\nSelling",
|
||||
"reqd": 1
|
||||
"label": "Buying"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "selling",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Selling",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
|
||||
@@ -12,7 +12,7 @@ test_records = [
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List",
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
@@ -25,7 +25,7 @@ test_records = [
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List 2",
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
@@ -38,7 +38,7 @@ test_records = [
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List India",
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
@@ -51,7 +51,7 @@ test_records = [
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List Rest of the World",
|
||||
"currency": "USD",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
|
||||
@@ -65,13 +65,13 @@ def get_price_list():
|
||||
|
||||
rate = {}
|
||||
|
||||
price_list = webnotes.conn.sql("""select item_code, buying_or_selling,
|
||||
price_list = webnotes.conn.sql("""select item_code, buying, selling,
|
||||
concat(price_list, " - ", currency, " ", ref_rate) as price
|
||||
from `tabItem Price`""", as_dict=1)
|
||||
|
||||
for j in price_list:
|
||||
if j.price:
|
||||
rate.setdefault(j.item_code, {}).setdefault(j.buying_or_selling, []).append(j.price)
|
||||
rate.setdefault(j.item_code, {}).setdefault("Buying" if j.buying else "Selling", []).append(j.price)
|
||||
item_rate_map = {}
|
||||
|
||||
for item in rate:
|
||||
|
||||
Reference in New Issue
Block a user