mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
patch for item price and price list
This commit is contained in:
@@ -17,11 +17,8 @@ class DocType:
|
||||
self.update_item_details()
|
||||
|
||||
def update_price_list_details(self):
|
||||
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")
|
||||
self.doc.buying, self.doc.selling, self.doc.currency = webnotes.conn.get_value("Price List",
|
||||
self.doc.price_list, ["buying", "selling", "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": "2014-01-07 18:11:10",
|
||||
"modified": "2014-01-07 19:16:49",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -64,14 +64,16 @@
|
||||
"fieldname": "buying",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Buying"
|
||||
"label": "Buying",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "selling",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Selling"
|
||||
"label": "Selling",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _, throw
|
||||
from webnotes.utils import comma_or, cint
|
||||
from webnotes.utils import cint
|
||||
from webnotes.model.controller import DocListController
|
||||
import webnotes.defaults
|
||||
|
||||
class DocType(DocListController):
|
||||
def validate(self):
|
||||
if not self.doc.buying and not self.doc.selling:
|
||||
throw(_("Price List must be one of Buying or Selling"))
|
||||
if not cint(self.doc.buying) and not cint(self.doc.selling):
|
||||
throw(_("Price List must be applicable for Buying or Selling"))
|
||||
|
||||
if not self.doclist.get({"parentfield": "valid_for_territories"}):
|
||||
# if no territory, set default territory
|
||||
@@ -24,24 +24,24 @@ class DocType(DocListController):
|
||||
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.selling:
|
||||
if cint(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:
|
||||
elif cint(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=%s, selling=%s, modified=NOW() where price_list=%s""",
|
||||
(self.doc.currency, self.doc.buying, self.doc.selling, self.doc.name))
|
||||
(self.doc.currency, cint(self.doc.buying), cint(self.doc.selling), self.doc.name))
|
||||
0
stock/report/item_wise_price_list_rate/__init__.py
Normal file
0
stock/report/item_wise_price_list_rate/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-09-25 10:21:15",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-01-07 18:35:22",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"json": "{\"filters\":[[\"Item Price\",\"price_list\",\"like\",\"%\"],[\"Item Price\",\"item_code\",\"like\",\"%\"]],\"columns\":[[\"name\",\"Item Price\"],[\"price_list\",\"Item Price\"],[\"item_code\",\"Item Price\"],[\"item_name\",\"Item Price\"],[\"item_description\",\"Item Price\"],[\"ref_rate\",\"Item Price\"],[\"buying\",\"Item Price\"],[\"selling\",\"Item Price\"],[\"currency\",\"Item Price\"]],\"sort_by\":\"Item Price.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Price List",
|
||||
"report_name": "Item-wise Price List Rate",
|
||||
"report_type": "Report Builder"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"name": "Item-wise Price List Rate"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user