[fix] [minor] fixed conflict while merging with master

This commit is contained in:
Nabin Hait
2013-08-19 11:06:06 +05:30
206 changed files with 5830 additions and 1272 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:25",
"docstatus": 0,
"modified": "2013-07-25 16:36:35",
"modified": "2013-08-07 14:45:48",
"modified_by": "Administrator",
"owner": "Administrator"
},

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:09",
"docstatus": 0,
"modified": "2013-07-26 11:16:57",
"modified": "2013-08-09 14:46:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -63,7 +63,7 @@
"doctype": "DocField",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"label": "Document Numbering Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
@@ -285,7 +285,7 @@
{
"description": "Select the price list as entered in \"Price List\" master. This will pull the reference rates of items against this price list as specified in \"Item\" master.",
"doctype": "DocField",
"fieldname": "price_list_name",
"fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Price List",
"oldfieldname": "price_list_name",

View File

@@ -18,6 +18,8 @@ class TestDeliveryNote(unittest.TestCase):
pr.submit()
def test_over_billing_against_dn(self):
self._insert_purchase_receipt()
from stock.doctype.delivery_note.delivery_note import make_sales_invoice
self._insert_purchase_receipt()
dn = webnotes.bean(copy=test_records[0]).insert()
@@ -33,7 +35,7 @@ class TestDeliveryNote(unittest.TestCase):
# modify export_amount
si[1].export_rate = 200
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).submit)
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert)
def test_delivery_note_no_gl_entry(self):
@@ -113,7 +115,7 @@ test_records = [
"posting_date": "2013-02-21",
"posting_time": "9:00:00",
"price_list_currency": "INR",
"price_list_name": "_Test Price List",
"selling_price_list": "_Test Price List",
"status": "Draft",
"territory": "_Test Territory",
"net_total": 500.0,

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-22 13:15:44",
"docstatus": 0,
"modified": "2013-07-25 16:37:09",
"modified": "2013-08-07 14:45:30",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -95,7 +95,6 @@
"label": "Quantity and Rate"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "qty",
"fieldtype": "Float",
@@ -124,7 +123,6 @@
"width": "50px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "ref_rate",
"fieldtype": "Currency",
@@ -141,7 +139,6 @@
"width": "100px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "adj_rate",
"fieldtype": "Float",
@@ -199,7 +196,6 @@
"width": "100px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "basic_rate",
"fieldtype": "Currency",

View File

@@ -5,16 +5,16 @@ wn.provide("erpnext.stock");
erpnext.stock.Item = wn.ui.form.Controller.extend({
onload: function() {
this.frm.add_fetch("price_list_name", "currency", "ref_currency");
this.frm.add_fetch("price_list_name", "buying_or_selling", "buying_or_selling");
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_name && !row.ref_currency) {
if(row.price_list && !row.ref_currency) {
// execute fetch
var df = wn.meta.get_docfield(row.doctype, "price_list_name", row.parent);
this.frm.script_manager.validate_link_and_fetch(df, row.name, row.price_list_name);
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);
}
}
});

View File

@@ -130,16 +130,16 @@ class DocType(DocListController):
def validate_price_lists(self):
price_lists=[]
for d in getlist(self.doclist,'ref_rate_details'):
if d.price_list_name in price_lists:
msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list_name,
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_name, "currency")
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_name, raise_exception=PriceListCurrencyMismatch)
+ ": " + d.price_list, raise_exception=PriceListCurrencyMismatch)
price_lists.append(d.price_list_name)
price_lists.append(d.price_list)
def fill_customer_code(self):

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-03 10:45:46",
"docstatus": 0,
"modified": "2013-08-05 18:23:47",
"modified": "2013-08-08 14:22:25",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -55,7 +55,7 @@
"doctype": "DocField",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Naming Series",
"label": "Document Numbering Series",
"options": "\nITEM",
"read_only": 0
},

View File

@@ -61,7 +61,7 @@ test_records = [
}, {
"doctype": "Item Price",
"parentfield": "ref_rate_details",
"price_list_name": "_Test Price List",
"price_list": "_Test Price List",
"ref_rate": 100,
"ref_currency": "INR",
"buying_or_selling": "Selling"

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-02 16:29:48",
"docstatus": 0,
"modified": "2013-07-31 17:30:34",
"modified": "2013-08-09 14:46:58",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -30,7 +30,7 @@
},
{
"doctype": "DocField",
"fieldname": "price_list_name",
"fieldname": "price_list",
"fieldtype": "Link",
"in_filter": 1,
"label": "Price List Name",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-03-07 14:48:38",
"docstatus": 0,
"modified": "2013-07-15 17:50:38",
"modified": "2013-08-08 14:22:27",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -71,7 +71,7 @@
"doctype": "DocField",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"label": "Document Numbering Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-02-22 01:28:02",
"docstatus": 0,
"modified": "2013-08-01 12:23:40",
"modified": "2013-08-07 14:45:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -89,7 +89,6 @@
"width": "100px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "qty",
"fieldtype": "Float",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-11 15:32:24",
"docstatus": 0,
"modified": "2013-07-05 14:47:57",
"modified": "2013-08-08 14:22:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -78,7 +78,7 @@
"doctype": "DocField",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"label": "Document Numbering Series",
"no_copy": 0,
"options": "PS",
"print_hide": 1,

View File

@@ -127,7 +127,7 @@ cur_frm.cscript.new_contact = function(){
cur_frm.fields_dict['purchase_receipt_details'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) {
return{
filters:[
['project', 'status', 'not in', 'Completed, Cancelled']
['Project', 'status', 'not in', 'Completed, Cancelled']
]
}
}

View File

@@ -334,9 +334,6 @@ def make_purchase_invoice(source_name, target_doclist=None):
bean.run_method("set_missing_values")
bean.run_method("set_supplier_defaults")
def update_item(obj, target, source_parent):
target.conversion_factor = 1
doclist = get_mapped_doclist("Purchase Receipt", source_name, {
"Purchase Receipt": {
"doctype": "Purchase Invoice",
@@ -353,7 +350,6 @@ def make_purchase_invoice(source_name, target_doclist=None):
"prevdoc_docname": "purchase_order",
"purchase_rate": "rate"
},
"postprocess": update_item
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-07-23 15:26:50",
"modified": "2013-08-09 14:47:05",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -60,7 +60,7 @@
"doctype": "DocField",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"label": "Document Numbering Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
@@ -237,14 +237,14 @@
{
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
"doctype": "DocField",
"fieldname": "price_list_name",
"fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
"print_hide": 1
},
{
"depends_on": "price_list_name",
"depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "price_list_currency",
"fieldtype": "Link",
@@ -255,7 +255,7 @@
"read_only": 1
},
{
"depends_on": "price_list_name",
"depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:10",
"docstatus": 0,
"modified": "2013-07-25 16:30:24",
"modified": "2013-08-07 14:45:23",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -76,7 +76,6 @@
"label": "Received and Accepted"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "received_qty",
"fieldtype": "Float",
@@ -91,7 +90,6 @@
"width": "100px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "qty",
"fieldtype": "Float",
@@ -104,7 +102,6 @@
"width": "100px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "rejected_qty",
"fieldtype": "Float",
@@ -161,7 +158,6 @@
"read_only": 0
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "import_rate",
"fieldtype": "Currency",
@@ -197,7 +193,6 @@
"read_only": 0
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "purchase_rate",
"fieldtype": "Currency",
@@ -213,7 +208,6 @@
"width": "100px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "amount",
"fieldtype": "Currency",

View File

@@ -4,34 +4,7 @@
wn.require("public/app/js/controllers/stock_controller.js");
wn.provide("erpnext.stock");
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
onload: function() {
this.set_default_account();
},
set_default_account: function() {
var me = this;
if (cint(wn.defaults.get_default("perpetual_accounting")) && !this.frm.doc.expense_adjustment_account) {
if (this.frm.doc.purpose == "Sales Return")
account_for = "default_expense_account";
else if (this.frm.doc.purpose == "Purchase Return")
account_for = "stock_received_but_not_billed";
else account_for = "stock_adjustment_account";
return this.frm.call({
method: "accounts.utils.get_company_default",
args: {
"fieldname": account_for,
"company": this.frm.doc.company
},
callback: function(r) {
if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message);
}
});
}
},
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
setup: function() {
var me = this;
@@ -80,11 +53,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
onload_post_render: function() {
if(this.frm.doc.__islocal && (this.frm.doc.production_order || this.frm.doc.bom_no)
&& !getchildren('Stock Entry Detail', this.frm.doc.name, 'mtn_details').length) {
// if production order / bom is mentioned, get items
this.get_items();
}
this.set_default_account();
},
refresh: function() {
@@ -115,6 +84,33 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
after_cancel: function() {
this.clean_up();
},
set_default_account: function() {
var me = this;
if (cint(wn.defaults.get_default("auto_inventory_accounting")) && !this.frm.doc.expense_adjustment_account) {
var account_for = "stock_adjustment_account";
if (this.frm.doc.purpose == "Sales Return")
account_for = "stock_in_hand_account";
else if (this.frm.doc.purpose == "Purchase Return")
account_for = "stock_received_but_not_billed";
return this.frm.call({
method: "accounts.utils.get_company_default",
args: {
"fieldname": account_for,
"company": this.frm.doc.company
},
callback: function(r) {
if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message);
me.get_items();
}
});
} else {
me.get_items();
}
},
clean_up: function() {
// Clear Production Order record from locals, because it is updated via Stock Entry
@@ -126,13 +122,16 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
get_items: function() {
return this.frm.call({
doc: this.frm.doc,
method: "get_items",
callback: function(r) {
if(!r.exc) refresh_field("mtn_details");
}
});
if(this.frm.doc.production_order || this.frm.doc.bom_no) {
// if production order / bom is mentioned, get items
return this.frm.call({
doc: this.frm.doc,
method: "get_items",
callback: function(r) {
if(!r.exc) refresh_field("mtn_details");
}
});
}
},
qty: function(doc, cdt, cdn) {
@@ -212,7 +211,6 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
});
loaddoc("Journal Voucher", jv_name);
}
}
});
}

View File

@@ -19,6 +19,7 @@ sql = webnotes.conn.sql
class NotUpdateStockError(webnotes.ValidationError): pass
class StockOverReturnError(webnotes.ValidationError): pass
class IncorrectValuationRateError(webnotes.ValidationError): pass
from controllers.stock_controller import StockController
@@ -254,7 +255,7 @@ class DocType(StockController):
def validate_incoming_rate(self):
for d in getlist(self.doclist, 'mtn_details'):
if d.t_warehouse:
self.validate_value("incoming_rate", ">", 0, d)
self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
def validate_bom(self):
for d in getlist(self.doclist, 'mtn_details'):
@@ -587,7 +588,6 @@ class DocType(StockController):
for item in item_dict:
pending_to_issue = (max_qty * item_dict[item]["qty"]) - issued_item_qty.get(item, 0)
desire_to_transfer = flt(self.doc.fg_completed_qty) * item_dict[item]["qty"]
if desire_to_transfer <= pending_to_issue:
item_dict[item]["qty"] = desire_to_transfer
else:

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-09 11:43:55",
"docstatus": 0,
"modified": "2013-08-05 17:36:25",
"modified": "2013-08-08 14:22:31",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -72,7 +72,7 @@
"fieldtype": "Select",
"hidden": 0,
"in_filter": 0,
"label": "Series",
"label": "Document Numbering Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",

View File

@@ -118,7 +118,7 @@ class DocType:
elif purpose == 'Sales Return':
webnotes.conn.sql("update `tabSerial No` set status = 'Delivered', purchase_document_type = '', purchase_document_no = '' where name = '%s'" % serial_no)
else:
webnotes.conn.sql("update `tabSerial No` set docstatus = 2, status = 'Not in Use', purchase_document_type = '', purchase_document_no = '', purchase_date = null, purchase_rate = 0, supplier = null, supplier_name = '', supplier_address = '', warehouse = '' where name = '%s'" % serial_no)
webnotes.conn.sql("update `tabSerial No` set docstatus = 2, status = 'Not in Use', purchase_document_type = '', purchase_document_no = '', purchase_date = null, purchase_rate = 0, supplier = null, supplier_name = '', address_display = '', warehouse = '' where name = '%s'" % serial_no)
def check_serial_no_exists(self, serial_no, item_code):

View File

@@ -112,5 +112,4 @@ def on_doctype_update():
where Key_name="posting_sort_index" """):
webnotes.conn.commit()
webnotes.conn.sql("""alter table `tabStock Ledger Entry`
add index posting_sort_index(posting_date, posting_time, name)""")
webnotes.conn.begin()
add index posting_sort_index(posting_date, posting_time, name)""")

View File

@@ -286,12 +286,15 @@ class DocType(StockController):
item_list = [d.item_code for d in self.entries]
warehouse_list = [d.warehouse for d in self.entries]
if not (item_list and warehouse_list):
webnotes.throw(_("Invalid Item or Warehouse Data"))
stock_ledger_entries = self.get_stock_ledger_entries(item_list, warehouse_list)
stock_value_difference = {}
for d in self.entries:
diff = get_buying_amount(d.item_code, d.warehouse, d.actual_qty, self.doc.doctype,
self.doc.name, d.voucher_detail_no, stock_ledger_entries)
diff = get_buying_amount(d.item_code, self.doc.doctype, self.doc.name,
d.voucher_detail_no, stock_ledger_entries.get((d.item_code, d.warehouse), []))
stock_value_difference.setdefault(d.warehouse, 0.0)
stock_value_difference[d.warehouse] -= diff

View File

@@ -176,7 +176,8 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
xaxis: {
ticks: $.map(me.data, function(item, idx) { return [[idx+1, item.name]] }),
max: 20
}
},
series: { downsample: { threshold: 1000 } }
}
}
});

View File

@@ -133,8 +133,6 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
} else {
break;
}
me.round_item_values(item);
}
}

View File

@@ -235,6 +235,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
min: dateutil.str_to_obj(this.from_date).getTime(),
max: dateutil.str_to_obj(this.to_date).getTime(),
},
series: { downsample: { threshold: 1000 } }
}
},
get_tooltip_text: function(label, x, y) {

View File

@@ -58,7 +58,7 @@ def get_price_list():
rate = {}
price_list = webnotes.conn.sql("""select parent, selling, buying,
concat(price_list_name, " - ", ref_currency, " ", ref_rate) as price
concat(price_list, " - ", ref_currency, " ", ref_rate) as price
from `tabItem Price` where docstatus<2""", as_dict=1)
for j in price_list:

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-02-22 18:01:55",
"docstatus": 0,
"modified": "2013-05-07 11:50:46",
"modified": "2013-05-07 11:52:00",
"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_name 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.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",
"ref_doctype": "Item",
"report_name": "Item-Wise Price List",
"report_type": "Query Report"

View File

@@ -0,0 +1,22 @@
[
{
"creation": "2013-08-09 12:20:58",
"docstatus": 0,
"modified": "2013-08-09 12:25:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n mr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand not exists(select name from `tabSupplier Quotation Item` where prevdoc_docname=mr.name)\norder by mr.transaction_date asc",
"ref_doctype": "Material Request",
"report_name": "Material Requests for which Supplier Quotations are not created",
"report_type": "Query Report"
},
{
"doctype": "Report",
"name": "Material Requests for which Supplier Quotations are not created"
}
]

View File

@@ -8,6 +8,7 @@ from stock.utils import get_valuation_method
import json
# future reposting
class NegativeStockError(webnotes.ValidationError): pass
_exceptions = []
def update_entries_after(args, verbose=1):
@@ -253,9 +254,9 @@ def _raise_exceptions(args, verbose=1):
_exceptions[0]["voucher_type"], _exceptions[0]["voucher_no"],
abs(deficiency))
if verbose:
msgprint(msg, raise_exception=1)
msgprint(msg, raise_exception=NegativeStockError)
else:
raise webnotes.ValidationError, msg
raise NegativeStockError, msg
def get_previous_sle(args, for_update=False):
"""

View File

@@ -99,7 +99,7 @@ def get_incoming_rate(args):
if valuation_method == 'FIFO':
if not previous_sle:
return 0.0
previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]'))
previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]') or '[]')
in_rate = previous_stock_queue and \
get_fifo_rate(previous_stock_queue, args.get("qty") or 0) or 0
elif valuation_method == 'Moving Average':
@@ -182,32 +182,28 @@ def get_warehouse_list(doctype, txt, searchfield, start, page_len, filters):
wlist.append([w])
return wlist
def get_buying_amount(item_code, warehouse, qty, voucher_type, voucher_no, voucher_detail_no,
def get_buying_amount(item_code, voucher_type, voucher_no, voucher_detail_no,
stock_ledger_entries, item_sales_bom=None):
if item_sales_bom and item_sales_bom.get(item_code):
# sales bom item
buying_amount = 0.0
for bom_item in item_sales_bom[item_code]:
if bom_item.get("parent_detail_docname")==voucher_detail_no:
buying_amount += _get_buying_amount(voucher_type, voucher_no, voucher_detail_no,
bom_item.item_code, bom_item.warehouse or warehouse,
bom_item.total_qty or (bom_item.qty * qty), stock_ledger_entries)
buying_amount += _get_buying_amount(voucher_type, voucher_no, voucher_detail_no, stock_ledger_entries)
return buying_amount
else:
# doesn't have sales bom
return _get_buying_amount(voucher_type, voucher_no, voucher_detail_no,
item_code, warehouse, qty, stock_ledger_entries)
return _get_buying_amount(voucher_type, voucher_no, voucher_detail_no, stock_ledger_entries)
def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse, qty,
stock_ledger_entries):
relevant_stock_ledger_entries = [sle for sle in stock_ledger_entries
if sle.item_code == item_code and sle.warehouse == warehouse]
for i, sle in enumerate(relevant_stock_ledger_entries):
def _get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries):
# IMP NOTE
# stock_ledger_entries should already be filtered by item_code and warehouse and
# sorted by posting_date desc, posting_time desc
for i, sle in enumerate(stock_ledger_entries):
if sle.voucher_type == voucher_type and sle.voucher_no == voucher_no and \
sle.voucher_detail_no == item_row:
previous_stock_value = len(relevant_stock_ledger_entries) > i+1 and \
flt(relevant_stock_ledger_entries[i+1].stock_value) or 0.0
previous_stock_value = len(stock_ledger_entries) > i+1 and \
flt(stock_ledger_entries[i+1].stock_value) or 0.0
buying_amount = previous_stock_value - flt(sle.stock_value)
return buying_amount
@@ -217,8 +213,8 @@ def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse,
def reorder_item():
""" Reorder item if stock reaches reorder level"""
if not hasattr(webnotes, "auto_indent"):
webnotes.auto_indent = webnotes.conn.get_value('Stock Settings', None, 'auto_indent')
webnotes.auto_indent = cint(webnotes.conn.get_value('Stock Settings', None, 'auto_indent'))
if webnotes.auto_indent:
material_requests = {}
bin_list = webnotes.conn.sql("""select item_code, warehouse, projected_qty
@@ -313,8 +309,8 @@ def create_material_request(material_requests):
if mr_list:
if not hasattr(webnotes, "reorder_email_notify"):
webnotes.reorder_email_notify = webnotes.conn.get_value('Stock Settings', None,
'reorder_email_notify')
webnotes.reorder_email_notify = cint(webnotes.conn.get_value('Stock Settings', None,
'reorder_email_notify'))
if(webnotes.reorder_email_notify):
send_email_notification(mr_list)
@@ -340,7 +336,6 @@ def send_email_notification(mr_list):
msg += "<tr><td>" + item.item_code + "</td><td>" + item.warehouse + "</td><td>" + \
cstr(item.qty) + "</td><td>" + cstr(item.uom) + "</td></tr>"
msg += "</table>"
sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
def notify_errors(exceptions_list):