patch for item price and price list
diff --git a/accounts/Print Format/POS Invoice/POS Invoice.txt b/accounts/Print Format/POS Invoice/POS Invoice.txt
index aab8e18..4f1b20a 100644
--- a/accounts/Print Format/POS Invoice/POS Invoice.txt
+++ b/accounts/Print Format/POS Invoice/POS Invoice.txt
@@ -2,14 +2,14 @@
{
"creation": "2011-12-21 11:08:55",
"docstatus": 0,
- "modified": "2013-09-13 17:17:47",
+ "modified": "2014-01-07 18:46:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doc_type": "Sales Invoice",
"doctype": "Print Format",
- "html": "<html>\n<head>\n<!--Item Table, Totals and Other Charges-->\n<script>\nfunction get_print_format() {\n var oc = getchildren('Sales Invoice Item', doc.name, 'entries');\n\tvar rows = '<table width=\"100%\" cellpadding=\"0\" class=\"cart\">\\\n <tr>\\\n <td colspan=\"3\"><hr></td>\\\n </tr>\\\n <tr>\\\n <td width=\"60%\" align=\"left\">ITEM NAME.</td>\\\n <td width=\"10%\" align=\"right\">QTY</td>\\\n <td width=\"30%\" align=\"right\">AMOUNT</td>\\\n </tr>\\\n <tr>\\\n <td colspan=\"3\"><hr></td>\\\n </tr>';\n\tfor (var x=0; x<oc.length; x++) {\n console.log(oc[x].item_code!=oc[x].item_name);\n\t\trows += '<tr>\\\n <td align=\"left\">' + oc[x].item_code + \n (oc[x].item_code!=oc[x].item_name ? ('<br>' + oc[x].item_name) : '') + '</td>\\\n <td align=\"right\" style=\"vertical-align:top;\">' + oc[x].qty + '</td>\\\n <td align=\"right\" valign=\"top\">' + format_currency(oc[x].export_amount, doc.currency) + '</td>\\\n </tr>';\n\t}\n rows += '<tr>\\\n <td colspan=\"3\"><hr></td>\\\n </tr>\\\n <tr>\\\n <td colspan=\"2\" align=\"right\">Net Total</td>\\\n <td align=\"right\">' + format_currency(doc.net_total_export, doc.currency) + '</td>\\\n </tr>';\n if (doc.other_charges_total_export != 0) {\n var taxes = wn.model.get_children(\"Sales Taxes and Charges\", doc.name, \"other_charges\", \"Sales Invoice\");\n\t\t$.each(taxes, function(i, d) {\n\t\t\trows += '<tr>\\\n \t\t\t\t<td colspan=\"2\" align=\"right\">' + d.description + '</td>\\\n \t\t\t\t<td style=\"text-align: right;\">' + format_currency(d.tax_amount / doc.conversion_rate, doc.currency) + '</td>\\\n \t\t\t<tr>';\n\t\t});\n }\n rows += '<tr>\\\n <td colspan=\"2\" align=\"right\" style=\"vertical-align:middle;\">Grand Total</td>\\\n <td align=\"right\"><hr width=\"90%\" align=\"right\">' + format_currency(doc.grand_total_export, doc.currency) + '<br>\\\n <hr width=\"90%\" align=\"right\"></td>\\\n </tr>\\\n <tr>\\\n <td align=\"center\" colspan=\"3\">Thank You. Please visit again.</td>\\\n </tr>\\\n </table>';\n\treturn rows;\n}\n</script>\n<style>\n table, tr, td, div, p {\n font-family: Monospace;\n line-height: 200%;\n }\n h1, h2, h3, h4, h5, h6 {\n text-align: center;\n }\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 4in;\n\t\t}\n\t}\n</style>\n</head>\n\n<body>\n<table width=\"100%\" cellpadding=\"4\">\n <tr>\n <td align=\"left\">RECEIPT NO: <script>doc.name</script></td>\n <td align=\"right\">DATE: <script>date.str_to_user(doc.posting_date)</script></td>\n </tr>\n <tr>\n <td>M/s <script>doc.customer</script></td>\n </tr>\n</table>\n<!--Item Table & Totals-->\n<div><script>get_print_format();</script></div>\n</body>\n</html>\n",
+ "html": "<html>\n<head>\n<!--Item Table, Totals and Other Charges-->\n<script>\nfunction get_print_format() {\n\tvar oc = getchildren('Sales Invoice Item', doc.name, 'entries');\n\tvar rows = '<table width=\"100%\" cellpadding=\"0\" class=\"cart\">\\\n <tr>\\\n <td colspan=\"3\"><hr></td>\\\n </tr>\\\n <tr>\\\n <td width=\"60%\" align=\"left\">ITEM CODE/DESC.</td>\\\n <td width=\"10%\" align=\"right\">QTY</td>\\\n <td width=\"30%\" align=\"right\">RATE</td>\\\n </tr>\\\n <tr>\\\n <td colspan=\"3\"><hr></td>\\\n </tr>';\n\tfor (var x=0; x<oc.length; x++) {\n\t\trows += '<tr>\\\n <td align=\"left\">' + oc[x].item_code + '<br>' + oc[x].item_name + '</td>\\\n <td align=\"right\" style=\"vertical-align:top;\">' + oc[x].qty + '</td>\\\n <td align=\"right\" valign=\"top\">' + format_currency(oc[x].export_amount) + '</td>\\\n </tr>';\n\t}\n rows += '<tr>\\\n <td colspan=\"3\"><hr></td>\\\n </tr>\\\n <tr>\\\n <td colspan=\"2\" align=\"right\">Net Total</td>\\\n <td align=\"right\">' + format_currency(doc.net_total_export) + '</td>\\\n </tr>';\n var taxes = wn.model.get_children(\"Sales Taxes and Charges\", doc.name, \"other_charges\", \"Sales Invoice\");\n if (doc.other_charges_total_export != 0) {\n\t\t$.each(taxes, function(i, d) {\n\t\t\trows += '<tr>\\\n \t\t\t\t<td colspan=\"2\" align=\"right\">' + d.description + '</td>\\\n \t\t\t\t<td style=\"text-align: right;\">' + format_currency(d.tax_amount) + '</td>\\\n \t\t\t<tr>';\n\t\t});\n }\n rows += '<tr>\\\n <td colspan=\"2\" align=\"right\" style=\"vertical-align:middle;\">Grand Total</td>\\\n <td align=\"right\"><hr width=\"90%\" align=\"right\">' + format_currency(doc.grand_total_export) + '<br>\\\n <hr width=\"90%\" align=\"right\"></td>\\\n </tr>\\\n <tr>\\\n <td align=\"center\" colspan=\"3\">Thank You. Please visit again.</td>\\\n </tr>\\\n </table>';\n\treturn rows;\n}\n</script>\n<style>\n table, tr, td, div, p {\n font-family: Monospace;\n line-height: 200%;\n }\n h1, h2, h3, h4, h5, h6 {\n text-align: center;\n }\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 4in;\n\t\t}\n\t}\n</style>\n</head>\n\n<body>\n<table width=\"100%\" cellpadding=\"4\">\n <tr>\n <td align=\"left\">RECEIPT NO: <script>doc.name</script></td>\n <td align=\"right\">DATE: <script>date.str_to_user(doc.posting_date)</script></td>\n </tr>\n <tr>\n <td>M/s <script>doc.customer</script></td>\n </tr>\n</table>\n<!--Item Table & Totals-->\n<div><script>get_print_format();</script></div>\n</body>\n</html>\n",
"module": "Accounts",
"name": "__common__",
"print_format_type": "Client",
diff --git a/patches/1401/__init__.py b/patches/1401/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/patches/1401/__init__.py
diff --git a/patches/1401/p01_make_buying_selling_as_check_box_in_price_list.py b/patches/1401/p01_make_buying_selling_as_check_box_in_price_list.py
new file mode 100644
index 0000000..d5eb3e8
--- /dev/null
+++ b/patches/1401/p01_make_buying_selling_as_check_box_in_price_list.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2014, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def execute():
+ webnotes.reload_doc("stock", "doctype", "price_list")
+ webnotes.reload_doc("stock", "doctype", "item_price")
+
+ if "buying_or_selling" in webnotes.conn.get_table_columns("Price List"):
+ webnotes.conn.sql("""update `tabPrice List` set
+ selling =
+ case
+ when buying_or_selling='Selling'
+ then 1
+ end,
+ buying =
+ case
+ when buying_or_selling='Buying'
+ then 1
+ end
+ """)
+ webnotes.conn.sql("""update `tabItem Price` ip, `tabPrice List` pl
+ set ip.buying=pl.buying, ip.selling=pl.selling
+ where ip.price_list=pl.name""")
+
+ webnotes.conn.sql("""udpate `tabItem Price` set selling=1 where ifnull(selling, 0)=0 and
+ ifnull(buying, 0)=0""")
\ No newline at end of file
diff --git a/stock/doctype/item_price/item_price.py b/stock/doctype/item_price/item_price.py
index 9a8e3d3..e2c9f2f 100644
--- a/stock/doctype/item_price/item_price.py
+++ b/stock/doctype/item_price/item_price.py
@@ -17,11 +17,8 @@
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",
diff --git a/stock/doctype/item_price/item_price.txt b/stock/doctype/item_price/item_price.txt
index b25fd30..f329a5f 100644
--- a/stock/doctype/item_price/item_price.txt
+++ b/stock/doctype/item_price/item_price.txt
@@ -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",
diff --git a/stock/doctype/price_list/price_list.py b/stock/doctype/price_list/price_list.py
index 569e759..40841cf 100644
--- a/stock/doctype/price_list/price_list.py
+++ b/stock/doctype/price_list/price_list.py
@@ -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 @@
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))
\ No newline at end of file
+ (self.doc.currency, cint(self.doc.buying), cint(self.doc.selling), self.doc.name))
\ No newline at end of file
diff --git a/stock/report/item_wise_price_list_rate/__init__.py b/stock/report/item_wise_price_list_rate/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/report/item_wise_price_list_rate/__init__.py
diff --git a/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt b/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt
new file mode 100644
index 0000000..f4d1d67
--- /dev/null
+++ b/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt
@@ -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"
+ }
+]
\ No newline at end of file