mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
Merge branch 'website-wip'
This commit is contained in:
@@ -43,6 +43,9 @@ class DocType(SellingController):
|
||||
if billed_qty:
|
||||
total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "delivery_note_details"})))
|
||||
self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty
|
||||
|
||||
def get_portal_page(self):
|
||||
return "shipment" if self.doc.docstatus==1 else None
|
||||
|
||||
def get_contact_details(self):
|
||||
return get_obj('Sales Common').get_contact_details(self,0)
|
||||
|
||||
0
stock/doctype/delivery_note/templates/__init__.py
Normal file
0
stock/doctype/delivery_note/templates/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
{% extends "app/portal/templates/sale.html" %}
|
||||
16
stock/doctype/delivery_note/templates/pages/shipment.py
Normal file
16
stock/doctype/delivery_note/templates/pages/shipment.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
no_cache = True
|
||||
|
||||
def get_context():
|
||||
from portal.utils import get_transaction_context
|
||||
context = get_transaction_context("Delivery Note", webnotes.form_dict.name)
|
||||
context.update({
|
||||
"parent_link": "shipments",
|
||||
"parent_title": "Shipments"
|
||||
})
|
||||
return context
|
||||
@@ -0,0 +1 @@
|
||||
{% extends "app/portal/templates/sales_transactions.html" %}
|
||||
24
stock/doctype/delivery_note/templates/pages/shipments.py
Normal file
24
stock/doctype/delivery_note/templates/pages/shipments.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
no_cache = True
|
||||
|
||||
def get_context():
|
||||
from portal.utils import get_currency_context
|
||||
context = get_currency_context()
|
||||
context.update({
|
||||
"title": "Shipments",
|
||||
"method": "portal.templates.pages.shipments.get_shipments",
|
||||
"icon": "icon-truck",
|
||||
"empty_list_message": "No Shipments Found",
|
||||
"page": "shipment"
|
||||
})
|
||||
return context
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_shipments(start=0):
|
||||
from portal.utils import get_transaction_list
|
||||
return get_transaction_list("Delivery Note", start)
|
||||
@@ -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.add_default_uom_in_conversion_factor_table()
|
||||
self.validate_conversion_factor()
|
||||
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()
|
||||
@@ -109,7 +107,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"
|
||||
|
||||
@@ -147,22 +145,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 """
|
||||
@@ -227,7 +210,7 @@ class DocType(DocListController):
|
||||
|
||||
def update_website(self):
|
||||
def _invalidate_cache():
|
||||
from website.helpers.product import invalidate_cache_for
|
||||
from selling.utils.product import invalidate_cache_for
|
||||
|
||||
invalidate_cache_for(self.doc.item_group)
|
||||
|
||||
@@ -257,13 +240,13 @@ class DocType(DocListController):
|
||||
def get_tax_rate(self, tax_type):
|
||||
return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") }
|
||||
|
||||
def prepare_template_args(self):
|
||||
from website.helpers.product import get_parent_item_groups
|
||||
def get_context(self):
|
||||
from selling.utils.product import get_parent_item_groups
|
||||
self.parent_groups = get_parent_item_groups(self.doc.item_group) + [{"name":self.doc.name}]
|
||||
self.doc.title = self.doc.item_name
|
||||
|
||||
if self.doc.slideshow:
|
||||
from website.helpers.slideshow import get_slideshow
|
||||
from website.doctype.website_slideshow.website_slideshow import get_slideshow
|
||||
get_slideshow(self)
|
||||
|
||||
def get_file_details(self, arg = ''):
|
||||
|
||||
@@ -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",
|
||||
|
||||
0
stock/doctype/item/templates/__init__.py
Normal file
0
stock/doctype/item/templates/__init__.py
Normal file
0
stock/doctype/item/templates/generators/__init__.py
Normal file
0
stock/doctype/item/templates/generators/__init__.py
Normal file
78
stock/doctype/item/templates/generators/item.html
Normal file
78
stock/doctype/item/templates/generators/item.html
Normal file
@@ -0,0 +1,78 @@
|
||||
{% extends base_template %}
|
||||
|
||||
{% block javascript %}
|
||||
<script>
|
||||
{% include "app/stock/doctype/item/templates/includes/product_page.js" %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<style>
|
||||
{% include "app/stock/doctype/item/templates/includes/product_page.css" %}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% include 'app/stock/doctype/item/templates/includes/product_search_box.html' %}
|
||||
{% include 'app/stock/doctype/item/templates/includes/product_breadcrumbs.html' %}
|
||||
<div class="col-md-12 product-page-content" itemscope itemtype="http://schema.org/Product">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{% if slideshow %}
|
||||
{% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %}
|
||||
{% else %}
|
||||
{% if website_image %}
|
||||
<image itemprop="image" class="item-main-image"
|
||||
src="{{ website_image }}" />
|
||||
{% else %}
|
||||
<div class="img-area">
|
||||
{% include 'app/stock/doctype/item/templates/includes/product_missing_image.html' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h3 itemprop="name" style="margin-top: 0px;">{{ item_name }}</h3>
|
||||
<p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p>
|
||||
<h4>Product Description</h4>
|
||||
<div itemprop="description">
|
||||
{{ web_long_description or description or "[No description given]" }}
|
||||
</div>
|
||||
<div style="min-height: 100px; margin: 10px 0;">
|
||||
<div class="item-price-info" style="display: none;">
|
||||
<h4 class="item-price" itemprop="price"></h4>
|
||||
<div class="item-stock" itemprop="availablity"></div>
|
||||
<div id="item-add-to-cart">
|
||||
<button class="btn btn-primary">
|
||||
<i class="icon-shopping-cart"></i> Add to Cart</button>
|
||||
</div>
|
||||
<div id="item-update-cart" class="input-group col-md-4" style="display: none;
|
||||
padding-left: 0px; padding-right: 0px;">
|
||||
<input class="form-control" type="text">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-primary">
|
||||
<i class="icon-ok"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if obj.doclist.get({"doctype":"Item Website Specification"}) -%}
|
||||
<div class="row" style="margin-top: 20px">
|
||||
<div class="col-md-12">
|
||||
<h4>Specifications</h4>
|
||||
<table class="table table-bordered" style="width: 100%">
|
||||
{% for d in obj.doclist.get(
|
||||
{"doctype":"Item Website Specification"}) -%}
|
||||
<tr>
|
||||
<td style="width: 30%;">{{ d.label }}</td>
|
||||
<td>{{ d.description }}</td>
|
||||
</tr>
|
||||
{%- endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
2
stock/doctype/item/templates/generators/item.py
Normal file
2
stock/doctype/item/templates/generators/item.py
Normal file
@@ -0,0 +1,2 @@
|
||||
doctype = "Item"
|
||||
condition_field = "show_in_website"
|
||||
@@ -0,0 +1,12 @@
|
||||
{% if obj.parent_groups and (obj.parent_groups|length) > 1 %}
|
||||
<div class="col-md-12">
|
||||
<div class="clearfix">
|
||||
<ul class="breadcrumb">
|
||||
{% for ig in obj.parent_groups[:-1] %}
|
||||
<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a></li>
|
||||
{% endfor %}
|
||||
<li class="active">{{ obj.parent_groups[-1].name }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
14
stock/doctype/item/templates/includes/product_in_grid.html
Normal file
14
stock/doctype/item/templates/includes/product_in_grid.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="col-md-3">
|
||||
<div style="height: 120px; overflow: hidden;">
|
||||
<a href="{{ page_name }}">
|
||||
{%- if website_image -%}
|
||||
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
|
||||
{%- else -%}
|
||||
{% include 'app/stock/doctype/item/templates/includes/product_missing_image.html' %}
|
||||
{%- endif -%}
|
||||
</a>
|
||||
</div>
|
||||
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
||||
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
|
||||
</div>
|
||||
</div>
|
||||
15
stock/doctype/item/templates/includes/product_in_list.html
Normal file
15
stock/doctype/item/templates/includes/product_in_list.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!-- TODO product listing -->
|
||||
<div class="col-md-12">
|
||||
<div style="height: 120px; overflow: hidden;">
|
||||
<a href="{{ page_name }}">
|
||||
{%- if website_image -%}
|
||||
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
|
||||
{%- else -%}
|
||||
{% include 'app/website/templates/html/product_missing_image.html' %}
|
||||
{%- endif -%}
|
||||
</a>
|
||||
</div>
|
||||
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
||||
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
|
||||
</div>
|
||||
</div>
|
||||
52
stock/doctype/item/templates/includes/product_list.js
Normal file
52
stock/doctype/item/templates/includes/product_list.js
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
window.get_product_list = function() {
|
||||
$(".more-btn .btn").click(function() {
|
||||
window.get_product_list()
|
||||
});
|
||||
|
||||
if(window.start==undefined) {
|
||||
throw "product list not initialized (no start)"
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "server.py",
|
||||
dataType: "json",
|
||||
data: {
|
||||
cmd: "selling.utils.product.get_product_list",
|
||||
start: window.start,
|
||||
search: window.search,
|
||||
product_group: window.product_group
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
window.render_product_list(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
window.render_product_list = function(data) {
|
||||
if(data.length) {
|
||||
var table = $("#search-list .table");
|
||||
if(!table.length)
|
||||
var table = $("<table class='table'>").appendTo("#search-list");
|
||||
|
||||
$.each(data, function(i, d) {
|
||||
$(d).appendTo(table);
|
||||
});
|
||||
}
|
||||
if(data.length < 10) {
|
||||
if(!table) {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert alert-warning'>No products found.</div>");
|
||||
} else {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='text-muted'>Nothing more to show.</div>");
|
||||
}
|
||||
} else {
|
||||
$(".more-btn").toggle(true)
|
||||
}
|
||||
window.start += (data.length || 0);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<div class="missing-image"><i class="icon-camera"></i></div>
|
||||
13
stock/doctype/item/templates/includes/product_page.css
Normal file
13
stock/doctype/item/templates/includes/product_page.css
Normal file
@@ -0,0 +1,13 @@
|
||||
<style>
|
||||
.item-main-image {
|
||||
max-width: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
.web-long-description {
|
||||
font-size: 18px;
|
||||
line-height: 200%;
|
||||
}
|
||||
.item-stock {
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
</style>
|
||||
78
stock/doctype/item/templates/includes/product_page.js
Normal file
78
stock/doctype/item/templates/includes/product_page.js
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
$(document).ready(function() {
|
||||
var item_code = $('[itemscope] [itemprop="productID"]').text().trim();
|
||||
var qty = 0;
|
||||
|
||||
wn.call({
|
||||
type: "POST",
|
||||
method: "selling.utils.product.get_product_info",
|
||||
args: {
|
||||
item_code: "{{ name }}"
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.message && r.message.price) {
|
||||
$(".item-price")
|
||||
.html(r.message.price.formatted_price + " per " + r.message.uom);
|
||||
|
||||
if(r.message.stock==0) {
|
||||
$(".item-stock").html("<div class='help'>Not in stock</div>");
|
||||
}
|
||||
else if(r.message.stock==1) {
|
||||
$(".item-stock").html("<div style='color: green'>\
|
||||
<i class='icon-check'></i> Available (in stock)</div>");
|
||||
}
|
||||
|
||||
$(".item-price-info").toggle(true);
|
||||
|
||||
if(r.message.qty) {
|
||||
qty = r.message.qty;
|
||||
toggle_update_cart(qty);
|
||||
$("#item-update-cart input").val(qty);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$("#item-add-to-cart button").on("click", function() {
|
||||
erpnext.cart.update_cart({
|
||||
item_code: item_code,
|
||||
qty: 1,
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
toggle_update_cart(1);
|
||||
qty = 1;
|
||||
}
|
||||
},
|
||||
btn: this,
|
||||
});
|
||||
});
|
||||
|
||||
$("#item-update-cart button").on("click", function() {
|
||||
erpnext.cart.update_cart({
|
||||
item_code: item_code,
|
||||
qty: $("#item-update-cart input").val(),
|
||||
btn: this,
|
||||
callback: function(r) {
|
||||
if(r.exc) {
|
||||
$("#item-update-cart input").val(qty);
|
||||
} else {
|
||||
qty = $("#item-update-cart input").val();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if(localStorage && localStorage.getItem("pending_add_to_cart") && full_name) {
|
||||
localStorage.removeItem("pending_add_to_cart");
|
||||
$("#item-add-to-cart button").trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
var toggle_update_cart = function(qty) {
|
||||
$("#item-add-to-cart").toggle(qty ? false : true);
|
||||
$("#item-update-cart")
|
||||
.toggle(qty ? true : false)
|
||||
.find("input").val(qty);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<div class="row clearfix">
|
||||
<div class="pull-right" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<form class="form-search">
|
||||
<div class="input-group col-md-4 col-md-offset-8">
|
||||
<input class="form-control" type="text" id="product-search" placeholder="Product Search...">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button" id="btn-product-search">
|
||||
<i class="icon-search"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
// redirect to product search page
|
||||
$(document).ready(function() {
|
||||
$('.dropdown-toggle').dropdown()
|
||||
$("#btn-product-search").click(function() {
|
||||
var txt = $("#product-search").val();
|
||||
if(txt) {
|
||||
window.location.href="product_search.html?q=" + txt;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$("#product-search").keypress(function(e) {
|
||||
if(e.which==13) $("#product-search-btn").click();
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</div>
|
||||
0
stock/doctype/item/templates/pages/__init__.py
Normal file
0
stock/doctype/item/templates/pages/__init__.py
Normal file
33
stock/doctype/item/templates/pages/product_search.html
Normal file
33
stock/doctype/item/templates/pages/product_search.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{% extends base_template %}
|
||||
|
||||
{% set title="Product Search" %}
|
||||
|
||||
{% block javascript %}
|
||||
<script>{% include "app/stock/doctype/item/templates/includes/product_list.js" %}</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var txt = get_url_arg("q");
|
||||
$(".search-results").html("Search results for: " + txt);
|
||||
window.search = txt;
|
||||
window.start = 0;
|
||||
window.get_product_list();
|
||||
});
|
||||
</script>
|
||||
|
||||
{% include "app/stock/doctype/item/templates/includes/product_search_box.html" %}
|
||||
<div class="col-md-12">
|
||||
<h3 class="search-results">Search Results</h3>
|
||||
<div id="search-list" class="row">
|
||||
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<div class="more-btn"
|
||||
style="display: none; text-align: center;">
|
||||
<button class="btn">More...</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -2,8 +2,5 @@
|
||||
# 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
|
||||
no_cache = True
|
||||
@@ -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,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
|
||||
}
|
||||
]
|
||||
@@ -23,8 +23,8 @@ def execute(filters=None):
|
||||
item_map[item]["description"], item_map[item]["stock_uom"],
|
||||
flt(last_purchase_rate.get(item, 0), precision),
|
||||
flt(val_rate_map.get(item, 0), precision),
|
||||
pl.get(item, {}).get("selling"),
|
||||
pl.get(item, {}).get("buying"),
|
||||
pl.get(item, {}).get("Selling"),
|
||||
pl.get(item, {}).get("Buying"),
|
||||
flt(bom_rate.get(item, 0), precision),
|
||||
flt(item_map[item]["standard_rate"], precision)
|
||||
])
|
||||
@@ -56,24 +56,21 @@ def get_price_list():
|
||||
"""Get selling & buying price list of every item"""
|
||||
|
||||
rate = {}
|
||||
|
||||
price_list = webnotes.conn.sql("""select parent, selling, buying,
|
||||
concat(price_list, " - ", ref_currency, " ", ref_rate) as price
|
||||
from `tabItem Price` where docstatus<2""", as_dict=1)
|
||||
|
||||
price_list = webnotes.conn.sql("""select ip.item_code, pl.buying_or_selling,
|
||||
concat(pl.name, " - ", pl.currency, " ", ip.ref_rate) as price
|
||||
from `tabItem Price` ip, `tabPrice List` pl where
|
||||
ip.parent = pl.name and pl.docstatus<2""", as_dict=1)
|
||||
|
||||
for j in price_list:
|
||||
if j.price:
|
||||
if j.selling:
|
||||
rate.setdefault(j.parent, {}).setdefault("selling", []).append(j.price)
|
||||
if j.buying:
|
||||
rate.setdefault(j.parent, {}).setdefault("buying", []).append(j.price)
|
||||
|
||||
rate.setdefault(j.item_code, {}).setdefault(j.buying_or_selling, []).append(j.price)
|
||||
item_rate_map = {}
|
||||
|
||||
for item in rate:
|
||||
item_rate_map.setdefault(item, {}).setdefault("selling",
|
||||
", ".join(rate[item].get("selling", [])))
|
||||
item_rate_map[item]["buying"] = ", ".join(rate[item].get("buying", []))
|
||||
for buying_or_selling in rate[item]:
|
||||
item_rate_map.setdefault(item, {}).setdefault(buying_or_selling,
|
||||
", ".join(rate[item].get(buying_or_selling, [])))
|
||||
|
||||
return item_rate_map
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-02-22 18:01:55",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-07 11:52:00",
|
||||
"modified": "2013-09-10 15:50:26",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,7 +10,7 @@
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name",
|
||||
"query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.parent as \"Price List::80\",\n price_list.currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price, `tabPrice List` price_list\nwhere\n item_price.item_code = item.name and\n item_price.parent = price_list.name",
|
||||
"ref_doctype": "Item",
|
||||
"report_name": "Item-Wise Price List",
|
||||
"report_type": "Query Report"
|
||||
|
||||
Reference in New Issue
Block a user