mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
-webnotes +frappe 💥
This commit is contained in:
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
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import add_days, cint,flt, nowdate, get_url_to_form, formatdate
|
||||
from webnotes import msgprint, _
|
||||
import frappe
|
||||
from frappe.utils import add_days, cint,flt, nowdate, get_url_to_form, formatdate
|
||||
from frappe import msgprint, _
|
||||
|
||||
import webnotes.defaults
|
||||
import frappe.defaults
|
||||
|
||||
|
||||
class DocType:
|
||||
@@ -16,7 +16,7 @@ class DocType:
|
||||
|
||||
def validate(self):
|
||||
if self.doc.fields.get("__islocal") or not self.doc.stock_uom:
|
||||
self.doc.stock_uom = webnotes.conn.get_value('Item', self.doc.item_code, 'stock_uom')
|
||||
self.doc.stock_uom = frappe.conn.get_value('Item', self.doc.item_code, 'stock_uom')
|
||||
|
||||
self.validate_mandatory()
|
||||
|
||||
@@ -60,7 +60,7 @@ class DocType:
|
||||
self.doc.save()
|
||||
|
||||
def get_first_sle(self):
|
||||
sle = webnotes.conn.sql("""
|
||||
sle = frappe.conn.sql("""
|
||||
select * from `tabStock Ledger Entry`
|
||||
where item_code = %s
|
||||
and warehouse = %s
|
||||
|
||||
@@ -12,7 +12,7 @@ cur_frm.cscript.sales_team_fname = "sales_team";
|
||||
{% include 'utilities/doctype/sms_control/sms_control.js' %}
|
||||
{% include 'accounts/doctype/sales_invoice/pos.js' %}
|
||||
|
||||
wn.provide("erpnext.stock");
|
||||
frappe.provide("erpnext.stock");
|
||||
erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend({
|
||||
refresh: function(doc, dt, dn) {
|
||||
this._super();
|
||||
@@ -26,20 +26,20 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
});
|
||||
|
||||
if(!from_sales_invoice)
|
||||
cur_frm.add_custom_button(wn._('Make Invoice'), this.make_sales_invoice);
|
||||
cur_frm.add_custom_button(frappe._('Make Invoice'), this.make_sales_invoice);
|
||||
}
|
||||
|
||||
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1)
|
||||
cur_frm.add_custom_button(wn._('Make Installation Note'), this.make_installation_note);
|
||||
cur_frm.add_custom_button(frappe._('Make Installation Note'), this.make_installation_note);
|
||||
|
||||
if (doc.docstatus==1) {
|
||||
cur_frm.appframe.add_button(wn._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
|
||||
cur_frm.appframe.add_button(frappe._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
}
|
||||
|
||||
if(doc.docstatus==0 && !doc.__islocal) {
|
||||
cur_frm.add_custom_button(wn._('Make Packing Slip'), cur_frm.cscript['Make Packing Slip']);
|
||||
cur_frm.add_custom_button(frappe._('Make Packing Slip'), cur_frm.cscript['Make Packing Slip']);
|
||||
}
|
||||
|
||||
set_print_hide(doc, dt, dn);
|
||||
@@ -49,9 +49,9 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled);
|
||||
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(wn._('From Sales Order'),
|
||||
cur_frm.add_custom_button(frappe._('From Sales Order'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||
source_doctype: "Sales Order",
|
||||
get_query_filters: {
|
||||
@@ -69,14 +69,14 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
},
|
||||
|
||||
make_sales_invoice: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
},
|
||||
|
||||
make_installation_note: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note",
|
||||
source_name: cur_frm.doc.name
|
||||
});
|
||||
@@ -96,7 +96,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
$.extend(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm}));
|
||||
|
||||
cur_frm.cscript.new_contact = function(){
|
||||
tn = wn.model.make_new_doc_and_get_name('Contact');
|
||||
tn = frappe.model.make_new_doc_and_get_name('Contact');
|
||||
locals['Contact'][tn].is_customer = 1;
|
||||
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
|
||||
loaddoc('Contact', tn);
|
||||
@@ -120,15 +120,15 @@ cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
|
||||
}
|
||||
|
||||
cur_frm.cscript['Make Packing Slip'] = function() {
|
||||
n = wn.model.make_new_doc_and_get_name('Packing Slip');
|
||||
n = frappe.model.make_new_doc_and_get_name('Packing Slip');
|
||||
ps = locals["Packing Slip"][n];
|
||||
ps.delivery_note = cur_frm.doc.name;
|
||||
loaddoc('Packing Slip', n);
|
||||
}
|
||||
|
||||
var set_print_hide= function(doc, cdt, cdn){
|
||||
var dn_fields = wn.meta.docfield_map['Delivery Note'];
|
||||
var dn_item_fields = wn.meta.docfield_map['Delivery Note Item'];
|
||||
var dn_fields = frappe.meta.docfield_map['Delivery Note'];
|
||||
var dn_item_fields = frappe.meta.docfield_map['Delivery Note Item'];
|
||||
var dn_fields_copy = dn_fields;
|
||||
var dn_item_fields_copy = dn_item_fields;
|
||||
|
||||
@@ -195,8 +195,8 @@ cur_frm.pformat.sales_order_no= function(doc, cdt, cdn){
|
||||
}
|
||||
|
||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
if(cint(wn.boot.notification_settings.delivery_note)) {
|
||||
cur_frm.email_doc(wn.boot.notification_settings.delivery_note_message);
|
||||
if(cint(frappe.boot.notification_settings.delivery_note)) {
|
||||
cur_frm.email_doc(frappe.boot.notification_settings.delivery_note_message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cstr, flt, cint
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
import webnotes.defaults
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.utils import cstr, flt, cint
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
import frappe.defaults
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
from erpnext.stock.utils import update_bin
|
||||
from erpnext.controllers.selling_controller import SellingController
|
||||
|
||||
@@ -34,7 +34,7 @@ class DocType(SellingController):
|
||||
}]
|
||||
|
||||
def onload(self):
|
||||
billed_qty = webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item`
|
||||
billed_qty = frappe.conn.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item`
|
||||
where docstatus=1 and delivery_note=%s""", self.doc.name)
|
||||
if billed_qty:
|
||||
total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "delivery_note_details"})))
|
||||
@@ -46,12 +46,12 @@ class DocType(SellingController):
|
||||
def set_actual_qty(self):
|
||||
for d in getlist(self.doclist, 'delivery_note_details'):
|
||||
if d.item_code and d.warehouse:
|
||||
actual_qty = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code, d.warehouse))
|
||||
actual_qty = frappe.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code, d.warehouse))
|
||||
d.actual_qty = actual_qty and flt(actual_qty[0][0]) or 0
|
||||
|
||||
def so_required(self):
|
||||
"""check in manage account if sales order required or not"""
|
||||
if webnotes.conn.get_value("Selling Settings", None, 'so_required') == 'Yes':
|
||||
if frappe.conn.get_value("Selling Settings", None, 'so_required') == 'Yes':
|
||||
for d in getlist(self.doclist,'delivery_note_details'):
|
||||
if not d.against_sales_order:
|
||||
msgprint("Sales Order No. required against item %s"%d.item_code)
|
||||
@@ -92,7 +92,7 @@ class DocType(SellingController):
|
||||
},
|
||||
})
|
||||
|
||||
if cint(webnotes.defaults.get_global_default('maintain_same_sales_rate')):
|
||||
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
|
||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||
fn[0] + " Item": {
|
||||
"ref_dn_field": "prevdoc_detail_docname",
|
||||
@@ -104,7 +104,7 @@ class DocType(SellingController):
|
||||
def validate_proj_cust(self):
|
||||
"""check for does customer belong to same project as entered.."""
|
||||
if self.doc.project_name and self.doc.customer:
|
||||
res = webnotes.conn.sql("select name from `tabProject` where name = '%s' and (customer = '%s' or ifnull(customer,'')='')"%(self.doc.project_name, self.doc.customer))
|
||||
res = frappe.conn.sql("select name from `tabProject` where name = '%s' and (customer = '%s' or ifnull(customer,'')='')"%(self.doc.project_name, self.doc.customer))
|
||||
if not res:
|
||||
msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.doc.customer,self.doc.project_name,self.doc.project_name))
|
||||
raise Exception
|
||||
@@ -115,7 +115,7 @@ class DocType(SellingController):
|
||||
e = [d.item_code, d.description, d.warehouse, d.against_sales_order or d.against_sales_invoice, d.batch_no or '']
|
||||
f = [d.item_code, d.description, d.against_sales_order or d.against_sales_invoice]
|
||||
|
||||
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
|
||||
if frappe.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
|
||||
if e in check_list:
|
||||
msgprint("Please check whether item %s has been entered twice wrongly."
|
||||
% d.item_code)
|
||||
@@ -130,7 +130,7 @@ class DocType(SellingController):
|
||||
|
||||
def validate_warehouse(self):
|
||||
for d in self.get_item_list():
|
||||
if webnotes.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
|
||||
if frappe.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
|
||||
if not d['warehouse']:
|
||||
msgprint("Please enter Warehouse for item %s as it is stock item"
|
||||
% d['item_code'], raise_exception=1)
|
||||
@@ -138,11 +138,11 @@ class DocType(SellingController):
|
||||
|
||||
def update_current_stock(self):
|
||||
for d in getlist(self.doclist, 'delivery_note_details'):
|
||||
bin = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
bin = frappe.conn.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||
|
||||
for d in getlist(self.doclist, 'packing_details'):
|
||||
bin = webnotes.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
bin = frappe.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
|
||||
|
||||
@@ -163,7 +163,7 @@ class DocType(SellingController):
|
||||
self.make_gl_entries()
|
||||
|
||||
# set DN status
|
||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
||||
frappe.conn.set(self.doc, 'status', 'Submitted')
|
||||
|
||||
|
||||
def on_cancel(self):
|
||||
@@ -174,7 +174,7 @@ class DocType(SellingController):
|
||||
|
||||
self.update_stock_ledger()
|
||||
|
||||
webnotes.conn.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.conn.set(self.doc, 'status', 'Cancelled')
|
||||
self.cancel_packing_slips()
|
||||
|
||||
self.make_cancel_gl_entries()
|
||||
@@ -198,15 +198,15 @@ class DocType(SellingController):
|
||||
if packing_error_list:
|
||||
err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \
|
||||
+ ", Packed: " + cstr(d[2])) for d in packing_error_list])
|
||||
webnotes.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
|
||||
frappe.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
|
||||
|
||||
def check_next_docstatus(self):
|
||||
submit_rv = webnotes.conn.sql("select t1.name from `tabSales Invoice` t1,`tabSales Invoice Item` t2 where t1.name = t2.parent and t2.delivery_note = '%s' and t1.docstatus = 1" % (self.doc.name))
|
||||
submit_rv = frappe.conn.sql("select t1.name from `tabSales Invoice` t1,`tabSales Invoice Item` t2 where t1.name = t2.parent and t2.delivery_note = '%s' and t1.docstatus = 1" % (self.doc.name))
|
||||
if submit_rv:
|
||||
msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted !")
|
||||
raise Exception , "Validation Error."
|
||||
|
||||
submit_in = webnotes.conn.sql("select t1.name from `tabInstallation Note` t1, `tabInstallation Note Item` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % (self.doc.name))
|
||||
submit_in = frappe.conn.sql("select t1.name from `tabInstallation Note` t1, `tabInstallation Note Item` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % (self.doc.name))
|
||||
if submit_in:
|
||||
msgprint("Installation Note : "+cstr(submit_in[0][0]) +" has already been submitted !")
|
||||
raise Exception , "Validation Error."
|
||||
@@ -215,21 +215,21 @@ class DocType(SellingController):
|
||||
"""
|
||||
Cancel submitted packing slips related to this delivery note
|
||||
"""
|
||||
res = webnotes.conn.sql("""SELECT name FROM `tabPacking Slip` WHERE delivery_note = %s
|
||||
res = frappe.conn.sql("""SELECT name FROM `tabPacking Slip` WHERE delivery_note = %s
|
||||
AND docstatus = 1""", self.doc.name)
|
||||
|
||||
if res:
|
||||
from webnotes.model.bean import Bean
|
||||
from frappe.model.bean import Bean
|
||||
for r in res:
|
||||
ps = Bean(dt='Packing Slip', dn=r[0])
|
||||
ps.cancel()
|
||||
webnotes.msgprint(_("Packing Slip(s) Cancelled"))
|
||||
frappe.msgprint(_("Packing Slip(s) Cancelled"))
|
||||
|
||||
|
||||
def update_stock_ledger(self):
|
||||
sl_entries = []
|
||||
for d in self.get_item_list():
|
||||
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
|
||||
if frappe.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
|
||||
and d.warehouse:
|
||||
self.update_reserved_qty(d)
|
||||
|
||||
@@ -243,7 +243,7 @@ class DocType(SellingController):
|
||||
if d['reserved_qty'] < 0 :
|
||||
# Reduce reserved qty from reserved warehouse mentioned in so
|
||||
if not d["reserved_warehouse"]:
|
||||
webnotes.throw(_("Reserved Warehouse is missing in Sales Order"))
|
||||
frappe.throw(_("Reserved Warehouse is missing in Sales Order"))
|
||||
|
||||
args = {
|
||||
"item_code": d['item_code'],
|
||||
@@ -270,7 +270,7 @@ def get_invoiced_qty_map(delivery_note):
|
||||
"""returns a map: {dn_detail: invoiced_qty}"""
|
||||
invoiced_qty_map = {}
|
||||
|
||||
for dn_detail, qty in webnotes.conn.sql("""select dn_detail, qty from `tabSales Invoice Item`
|
||||
for dn_detail, qty in frappe.conn.sql("""select dn_detail, qty from `tabSales Invoice Item`
|
||||
where delivery_note=%s and docstatus=1""", delivery_note):
|
||||
if not invoiced_qty_map.get(dn_detail):
|
||||
invoiced_qty_map[dn_detail] = 0
|
||||
@@ -278,12 +278,12 @@ def get_invoiced_qty_map(delivery_note):
|
||||
|
||||
return invoiced_qty_map
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_sales_invoice(source_name, target_doclist=None):
|
||||
invoiced_qty_map = get_invoiced_qty_map(source_name)
|
||||
|
||||
def update_accounts(source, target):
|
||||
si = webnotes.bean(target)
|
||||
si = frappe.bean(target)
|
||||
si.doc.is_pos = 0
|
||||
si.run_method("onload_post_render")
|
||||
|
||||
@@ -291,7 +291,7 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
si.doclist.get({"parentfield": "entries", "qty": [">", 0]}))
|
||||
|
||||
if len(si.doclist.get({"parentfield": "entries"})) == 0:
|
||||
webnotes.msgprint(_("Hey! All these items have already been invoiced."),
|
||||
frappe.msgprint(_("Hey! All these items have already been invoiced."),
|
||||
raise_exception=True)
|
||||
|
||||
return si.doclist
|
||||
@@ -332,7 +332,7 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_installation_note(source_name, target_doclist=None):
|
||||
def update_item(obj, target, source_parent):
|
||||
target.qty = flt(obj.qty) - flt(obj.installed_qty)
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import webnotes
|
||||
import webnotes.defaults
|
||||
from webnotes.utils import cint
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries, set_perpetual_inventory, test_records as pr_test_records
|
||||
|
||||
def _insert_purchase_receipt(item_code=None):
|
||||
if not item_code:
|
||||
item_code = pr_test_records[0][1]["item_code"]
|
||||
|
||||
pr = webnotes.bean(copy=pr_test_records[0])
|
||||
pr = frappe.bean(copy=pr_test_records[0])
|
||||
pr.doclist[1].item_code = item_code
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
@@ -25,12 +25,12 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
|
||||
from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
||||
_insert_purchase_receipt()
|
||||
dn = webnotes.bean(copy=test_records[0]).insert()
|
||||
dn = frappe.bean(copy=test_records[0]).insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_sales_invoice,
|
||||
self.assertRaises(frappe.ValidationError, make_sales_invoice,
|
||||
dn.doc.name)
|
||||
|
||||
dn = webnotes.bean("Delivery Note", dn.doc.name)
|
||||
dn = frappe.bean("Delivery Note", dn.doc.name)
|
||||
dn.submit()
|
||||
si = make_sales_invoice(dn.doc.name)
|
||||
|
||||
@@ -38,21 +38,21 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
|
||||
# modify amount
|
||||
si[1].rate = 200
|
||||
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert)
|
||||
self.assertRaises(frappe.ValidationError, frappe.bean(si).insert)
|
||||
|
||||
|
||||
def test_delivery_note_no_gl_entry(self):
|
||||
self.clear_stock_account_balance()
|
||||
set_perpetual_inventory(0)
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 0)
|
||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 0)
|
||||
|
||||
_insert_purchase_receipt()
|
||||
|
||||
dn = webnotes.bean(copy=test_records[0])
|
||||
dn = frappe.bean(copy=test_records[0])
|
||||
dn.insert()
|
||||
dn.submit()
|
||||
|
||||
stock_value, stock_value_difference = webnotes.conn.get_value("Stock Ledger Entry",
|
||||
stock_value, stock_value_difference = frappe.conn.get_value("Stock Ledger Entry",
|
||||
{"voucher_type": "Delivery Note", "voucher_no": dn.doc.name,
|
||||
"item_code": "_Test Item"}, ["stock_value", "stock_value_difference"])
|
||||
self.assertEqual(stock_value, 0)
|
||||
@@ -63,16 +63,16 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
def test_delivery_note_gl_entry(self):
|
||||
self.clear_stock_account_balance()
|
||||
set_perpetual_inventory()
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
webnotes.conn.set_value("Item", "_Test Item", "valuation_method", "FIFO")
|
||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
frappe.conn.set_value("Item", "_Test Item", "valuation_method", "FIFO")
|
||||
|
||||
_insert_purchase_receipt()
|
||||
|
||||
dn = webnotes.bean(copy=test_records[0])
|
||||
dn = frappe.bean(copy=test_records[0])
|
||||
dn.doclist[1].expense_account = "Cost of Goods Sold - _TC"
|
||||
dn.doclist[1].cost_center = "Main - _TC"
|
||||
|
||||
stock_in_hand_account = webnotes.conn.get_value("Account",
|
||||
stock_in_hand_account = frappe.conn.get_value("Account",
|
||||
{"master_name": dn.doclist[1].warehouse})
|
||||
|
||||
from erpnext.accounts.utils import get_balance_on
|
||||
@@ -95,7 +95,7 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
self.assertEquals(bal, prev_bal - 375.0)
|
||||
|
||||
# back dated purchase receipt
|
||||
pr = webnotes.bean(copy=pr_test_records[0])
|
||||
pr = frappe.bean(copy=pr_test_records[0])
|
||||
pr.doc.posting_date = "2013-01-01"
|
||||
pr.doclist[1].rate = 100
|
||||
pr.doclist[1].base_amount = 100
|
||||
@@ -123,11 +123,11 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
_insert_purchase_receipt()
|
||||
_insert_purchase_receipt("_Test Item Home Desktop 100")
|
||||
|
||||
dn = webnotes.bean(copy=test_records[0])
|
||||
dn = frappe.bean(copy=test_records[0])
|
||||
dn.doclist[1].item_code = "_Test Sales BOM Item"
|
||||
dn.doclist[1].qty = 1
|
||||
|
||||
stock_in_hand_account = webnotes.conn.get_value("Account",
|
||||
stock_in_hand_account = frappe.conn.get_value("Account",
|
||||
{"master_name": dn.doclist[1].warehouse})
|
||||
|
||||
from erpnext.accounts.utils import get_balance_on
|
||||
@@ -162,16 +162,16 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
se = make_serialized_item()
|
||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||
|
||||
dn = webnotes.bean(copy=test_records[0])
|
||||
dn = frappe.bean(copy=test_records[0])
|
||||
dn.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
dn.doclist[1].qty = 1
|
||||
dn.doclist[1].serial_no = serial_nos[0]
|
||||
dn.insert()
|
||||
dn.submit()
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "status"), "Delivered")
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0], "warehouse"))
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0],
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "status"), "Delivered")
|
||||
self.assertFalse(frappe.conn.get_value("Serial No", serial_nos[0], "warehouse"))
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0],
|
||||
"delivery_document_no"), dn.doc.name)
|
||||
|
||||
return dn
|
||||
@@ -183,9 +183,9 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
|
||||
serial_nos = get_serial_nos(dn.doclist[1].serial_no)
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "status"), "Available")
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC")
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0],
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "status"), "Available")
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC")
|
||||
self.assertFalse(frappe.conn.get_value("Serial No", serial_nos[0],
|
||||
"delivery_document_no"))
|
||||
|
||||
def test_serialize_status(self):
|
||||
@@ -195,11 +195,11 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
se = make_serialized_item()
|
||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||
|
||||
sr = webnotes.bean("Serial No", serial_nos[0])
|
||||
sr = frappe.bean("Serial No", serial_nos[0])
|
||||
sr.doc.status = "Not Available"
|
||||
sr.save()
|
||||
|
||||
dn = webnotes.bean(copy=test_records[0])
|
||||
dn = frappe.bean(copy=test_records[0])
|
||||
dn.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
dn.doclist[1].qty = 1
|
||||
dn.doclist[1].serial_no = serial_nos[0]
|
||||
@@ -208,9 +208,9 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
self.assertRaises(SerialNoStatusError, dn.submit)
|
||||
|
||||
def clear_stock_account_balance(self):
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.conn.sql("delete from `tabGL Entry`")
|
||||
frappe.conn.sql("""delete from `tabBin`""")
|
||||
frappe.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
frappe.conn.sql("delete from `tabGL Entry`")
|
||||
|
||||
test_dependencies = ["Sales BOM"]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -29,7 +29,7 @@ cur_frm.cscript.make_dashboard = function() {
|
||||
|
||||
cur_frm.cscript.edit_prices_button = function() {
|
||||
cur_frm.add_custom_button("Add / Edit Prices", function() {
|
||||
wn.set_route("Report", "Item Price", {"item_code": cur_frm.doc.name});
|
||||
frappe.set_route("Report", "Item Price", {"item_code": cur_frm.doc.name});
|
||||
}, "icon-money");
|
||||
}
|
||||
|
||||
@@ -117,14 +117,14 @@ cur_frm.fields_dict['item_group'].get_query = function(doc,cdt,cdn) {
|
||||
|
||||
cur_frm.cscript.add_image = function(doc, dt, dn) {
|
||||
if(!doc.image) {
|
||||
msgprint(wn._('Please select an "Image" first'));
|
||||
msgprint(frappe._('Please select an "Image" first'));
|
||||
return;
|
||||
}
|
||||
|
||||
doc.description_html = repl('<table style="width: 100%; table-layout: fixed;">' +
|
||||
'<tr><td style="width:110px"><img src="%(imgurl)s" width="100px"></td>' +
|
||||
'<td>%(desc)s</td></tr>' +
|
||||
'</table>', {imgurl: wn.utils.get_file_link(doc.image), desc:doc.description});
|
||||
'</table>', {imgurl: frappe.utils.get_file_link(doc.image), desc:doc.description});
|
||||
|
||||
refresh_field('description_html');
|
||||
}
|
||||
@@ -132,7 +132,7 @@ cur_frm.cscript.add_image = function(doc, dt, dn) {
|
||||
// Quotation to validation - either customer or lead mandatory
|
||||
cur_frm.cscript.weight_to_validate = function(doc, cdt, cdn){
|
||||
if((doc.nett_weight || doc.gross_weight) && !doc.weight_uom) {
|
||||
msgprint(wn._('Weight is mentioned,\nPlease mention "Weight UOM" too'));
|
||||
msgprint(frappe._('Weight is mentioned,\nPlease mention "Weight UOM" too'));
|
||||
validated = 0;
|
||||
}
|
||||
}
|
||||
@@ -150,10 +150,10 @@ cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query =
|
||||
}
|
||||
|
||||
cur_frm.cscript.copy_from_item_group = function(doc) {
|
||||
wn.model.with_doc("Item Group", doc.item_group, function() {
|
||||
$.each(wn.model.get("Item Website Specification", {parent:doc.item_group}),
|
||||
frappe.model.with_doc("Item Group", doc.item_group, function() {
|
||||
$.each(frappe.model.get("Item Website Specification", {parent:doc.item_group}),
|
||||
function(i, d) {
|
||||
var n = wn.model.add_child(doc, "Item Website Specification",
|
||||
var n = frappe.model.add_child(doc, "Item Website Specification",
|
||||
"item_website_specifications");
|
||||
n.label = d.label;
|
||||
n.description = d.description;
|
||||
@@ -169,7 +169,7 @@ cur_frm.cscript.image = function() {
|
||||
if(!cur_frm.doc.description_html)
|
||||
cur_frm.cscript.add_image(cur_frm.doc);
|
||||
else {
|
||||
msgprint(wn._("You may need to update: ") +
|
||||
wn.meta.get_docfield(cur_frm.doc.doctype, "description_html").label);
|
||||
msgprint(frappe._("You may need to update: ") +
|
||||
frappe.meta.get_docfield(cur_frm.doc.doctype, "description_html").label);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,14 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cstr, flt, getdate, now_datetime, formatdate
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint, _
|
||||
from frappe.utils import cstr, flt, getdate, now_datetime, formatdate
|
||||
from frappe.model.doc import addchild
|
||||
from frappe.model.bean import getlist
|
||||
from frappe import msgprint, _
|
||||
|
||||
from webnotes.model.controller import DocListController
|
||||
from frappe.model.controller import DocListController
|
||||
|
||||
class WarehouseNotSet(Exception): pass
|
||||
|
||||
@@ -18,8 +18,8 @@ class DocType(DocListController):
|
||||
self.doc.fields["__sle_exists"] = self.check_if_sle_exists()
|
||||
|
||||
def autoname(self):
|
||||
if webnotes.conn.get_default("item_naming_by")=="Naming Series":
|
||||
from webnotes.model.doc import make_autoname
|
||||
if frappe.conn.get_default("item_naming_by")=="Naming Series":
|
||||
from frappe.model.doc import make_autoname
|
||||
self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
|
||||
elif not self.doc.item_code:
|
||||
msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1)
|
||||
@@ -43,7 +43,7 @@ class DocType(DocListController):
|
||||
self.validate_item_type_for_reorder()
|
||||
|
||||
if self.doc.name:
|
||||
self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_name')
|
||||
self.old_page_name = frappe.conn.get_value('Item', self.doc.name, 'page_name')
|
||||
|
||||
def on_update(self):
|
||||
self.validate_name_with_item_group()
|
||||
@@ -51,7 +51,7 @@ class DocType(DocListController):
|
||||
|
||||
def check_warehouse_is_set_for_stock_item(self):
|
||||
if self.doc.is_stock_item=="Yes" and not self.doc.default_warehouse:
|
||||
webnotes.msgprint(_("Default Warehouse is mandatory for Stock Item."),
|
||||
frappe.msgprint(_("Default Warehouse is mandatory for Stock Item."),
|
||||
raise_exception=WarehouseNotSet)
|
||||
|
||||
def add_default_uom_in_conversion_factor_table(self):
|
||||
@@ -69,13 +69,13 @@ class DocType(DocListController):
|
||||
def check_stock_uom_with_bin(self):
|
||||
if not self.doc.fields.get("__islocal"):
|
||||
matched=True
|
||||
ref_uom = webnotes.conn.get_value("Stock Ledger Entry",
|
||||
ref_uom = frappe.conn.get_value("Stock Ledger Entry",
|
||||
{"item_code": self.doc.name}, "stock_uom")
|
||||
if ref_uom:
|
||||
if cstr(ref_uom) != cstr(self.doc.stock_uom):
|
||||
matched = False
|
||||
else:
|
||||
bin_list = webnotes.conn.sql("select * from tabBin where item_code=%s",
|
||||
bin_list = frappe.conn.sql("select * from tabBin where item_code=%s",
|
||||
self.doc.item_code, as_dict=1)
|
||||
for bin in bin_list:
|
||||
if (bin.reserved_qty > 0 or bin.ordered_qty > 0 or bin.indented_qty > 0 \
|
||||
@@ -84,11 +84,11 @@ class DocType(DocListController):
|
||||
break
|
||||
|
||||
if matched and bin_list:
|
||||
webnotes.conn.sql("""update tabBin set stock_uom=%s where item_code=%s""",
|
||||
frappe.conn.sql("""update tabBin set stock_uom=%s where item_code=%s""",
|
||||
(self.doc.stock_uom, self.doc.name))
|
||||
|
||||
if not matched:
|
||||
webnotes.throw(_("Default Unit of Measure can not be changed directly because you have already made some transaction(s) with another UOM. To change default UOM, use 'UOM Replace Utility' tool under Stock module."))
|
||||
frappe.throw(_("Default Unit of Measure can not be changed directly because you have already made some transaction(s) with another UOM. To change default UOM, use 'UOM Replace Utility' tool under Stock module."))
|
||||
|
||||
def validate_conversion_factor(self):
|
||||
check_list = []
|
||||
@@ -111,7 +111,7 @@ class DocType(DocListController):
|
||||
self.doc.is_pro_applicable = "No"
|
||||
|
||||
if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No':
|
||||
webnotes.throw(_("As Production Order can be made for this item, \
|
||||
frappe.throw(_("As Production Order can be made for this item, \
|
||||
it must be a stock item."))
|
||||
|
||||
if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
|
||||
@@ -119,20 +119,20 @@ class DocType(DocListController):
|
||||
|
||||
def check_for_active_boms(self):
|
||||
if self.doc.is_purchase_item != "Yes":
|
||||
bom_mat = webnotes.conn.sql("""select distinct t1.parent
|
||||
bom_mat = frappe.conn.sql("""select distinct t1.parent
|
||||
from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent
|
||||
and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1
|
||||
and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
|
||||
|
||||
if bom_mat and bom_mat[0][0]:
|
||||
webnotes.throw(_("Item must be a purchase item, \
|
||||
frappe.throw(_("Item must be a purchase item, \
|
||||
as it is present in one or many Active BOMs"))
|
||||
|
||||
if self.doc.is_manufactured_item != "Yes":
|
||||
bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s
|
||||
bom = frappe.conn.sql("""select name from `tabBOM` where item = %s
|
||||
and is_active = 1""", (self.doc.name,))
|
||||
if bom and bom[0][0]:
|
||||
webnotes.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many \
|
||||
frappe.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many \
|
||||
active BOMs present for this item"""))
|
||||
|
||||
def fill_customer_code(self):
|
||||
@@ -147,7 +147,7 @@ class DocType(DocListController):
|
||||
check_list=[]
|
||||
for d in getlist(self.doclist,'item_tax'):
|
||||
if d.tax_type:
|
||||
account_type = webnotes.conn.get_value("Account", d.tax_type, "account_type")
|
||||
account_type = frappe.conn.get_value("Account", d.tax_type, "account_type")
|
||||
|
||||
if account_type not in ['Tax', 'Chargeable', 'Income Account', 'Expense Account']:
|
||||
msgprint("'%s' is not Tax / Chargeable / Income / Expense Account" % d.tax_type, raise_exception=1)
|
||||
@@ -159,7 +159,7 @@ class DocType(DocListController):
|
||||
|
||||
def validate_barcode(self):
|
||||
if self.doc.barcode:
|
||||
duplicate = webnotes.conn.sql("""select name from tabItem where barcode = %s
|
||||
duplicate = frappe.conn.sql("""select name from tabItem where barcode = %s
|
||||
and name != %s""", (self.doc.barcode, self.doc.name))
|
||||
if duplicate:
|
||||
msgprint("Barcode: %s already used in item: %s" %
|
||||
@@ -167,36 +167,36 @@ class DocType(DocListController):
|
||||
|
||||
def cant_change(self):
|
||||
if not self.doc.fields.get("__islocal"):
|
||||
vals = webnotes.conn.get_value("Item", self.doc.name,
|
||||
vals = frappe.conn.get_value("Item", self.doc.name,
|
||||
["has_serial_no", "is_stock_item", "valuation_method"], as_dict=True)
|
||||
|
||||
if vals and ((self.doc.is_stock_item == "No" and vals.is_stock_item == "Yes") or
|
||||
vals.has_serial_no != self.doc.has_serial_no or
|
||||
cstr(vals.valuation_method) != cstr(self.doc.valuation_method)):
|
||||
if self.check_if_sle_exists() == "exists":
|
||||
webnotes.throw(_("As there are existing stock transactions for this item, you can not change the values of 'Has Serial No', 'Is Stock Item' and 'Valuation Method'"))
|
||||
frappe.throw(_("As there are existing stock transactions for this item, you can not change the values of 'Has Serial No', 'Is Stock Item' and 'Valuation Method'"))
|
||||
|
||||
def validate_item_type_for_reorder(self):
|
||||
if self.doc.re_order_level or len(self.doclist.get({"parentfield": "item_reorder",
|
||||
"material_request_type": "Purchase"})):
|
||||
if not self.doc.is_purchase_item:
|
||||
webnotes.msgprint(_("""To set reorder level, item must be Purchase Item"""),
|
||||
frappe.msgprint(_("""To set reorder level, item must be Purchase Item"""),
|
||||
raise_exception=1)
|
||||
|
||||
def check_if_sle_exists(self):
|
||||
sle = webnotes.conn.sql("""select name from `tabStock Ledger Entry`
|
||||
sle = frappe.conn.sql("""select name from `tabStock Ledger Entry`
|
||||
where item_code = %s""", self.doc.name)
|
||||
return sle and 'exists' or 'not exists'
|
||||
|
||||
def validate_name_with_item_group(self):
|
||||
# causes problem with tree build
|
||||
if webnotes.conn.exists("Item Group", self.doc.name):
|
||||
webnotes.msgprint("An item group exists with same name (%s), \
|
||||
if frappe.conn.exists("Item Group", self.doc.name):
|
||||
frappe.msgprint("An item group exists with same name (%s), \
|
||||
please change the item name or rename the item group" %
|
||||
self.doc.name, raise_exception=1)
|
||||
|
||||
def update_item_price(self):
|
||||
webnotes.conn.sql("""update `tabItem Price` set item_name=%s,
|
||||
frappe.conn.sql("""update `tabItem Price` set item_name=%s,
|
||||
item_description=%s, modified=NOW() where item_code=%s""",
|
||||
(self.doc.item_name, self.doc.description, self.doc.name))
|
||||
|
||||
@@ -209,10 +209,10 @@ class DocType(DocListController):
|
||||
return page_name_from
|
||||
|
||||
def get_tax_rate(self, tax_type):
|
||||
return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") }
|
||||
return { "tax_rate": frappe.conn.get_value("Account", tax_type, "tax_rate") }
|
||||
|
||||
def get_file_details(self, arg = ''):
|
||||
file = webnotes.conn.sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)
|
||||
file = frappe.conn.sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)
|
||||
|
||||
ret = {
|
||||
'file_group' : file and file[0]['file_group'] or '',
|
||||
@@ -221,24 +221,24 @@ class DocType(DocListController):
|
||||
return ret
|
||||
|
||||
def on_trash(self):
|
||||
webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
|
||||
frappe.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
|
||||
|
||||
def before_rename(self, olddn, newdn, merge=False):
|
||||
if merge:
|
||||
# Validate properties before merging
|
||||
if not webnotes.conn.exists("Item", newdn):
|
||||
webnotes.throw(_("Item ") + newdn +_(" does not exists"))
|
||||
if not frappe.conn.exists("Item", newdn):
|
||||
frappe.throw(_("Item ") + newdn +_(" does not exists"))
|
||||
|
||||
field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"]
|
||||
new_properties = [cstr(d) for d in webnotes.conn.get_value("Item", newdn, field_list)]
|
||||
new_properties = [cstr(d) for d in frappe.conn.get_value("Item", newdn, field_list)]
|
||||
if new_properties != [cstr(self.doc.fields[fld]) for fld in field_list]:
|
||||
webnotes.throw(_("To merge, following properties must be same for both items")
|
||||
frappe.throw(_("To merge, following properties must be same for both items")
|
||||
+ ": \n" + ", ".join([self.meta.get_label(fld) for fld in field_list]))
|
||||
|
||||
webnotes.conn.sql("delete from `tabBin` where item_code=%s", olddn)
|
||||
frappe.conn.sql("delete from `tabBin` where item_code=%s", olddn)
|
||||
|
||||
def after_rename(self, olddn, newdn, merge):
|
||||
webnotes.conn.set_value("Item", newdn, "item_code", newdn)
|
||||
frappe.conn.set_value("Item", newdn, "item_code", newdn)
|
||||
|
||||
if merge:
|
||||
self.set_last_purchase_rate(newdn)
|
||||
@@ -246,23 +246,23 @@ class DocType(DocListController):
|
||||
|
||||
def set_last_purchase_rate(self, newdn):
|
||||
last_purchase_rate = get_last_purchase_details(newdn).get("base_rate", 0)
|
||||
webnotes.conn.set_value("Item", newdn, "last_purchase_rate", last_purchase_rate)
|
||||
frappe.conn.set_value("Item", newdn, "last_purchase_rate", last_purchase_rate)
|
||||
|
||||
def recalculate_bin_qty(self, newdn):
|
||||
from erpnext.utilities.repost_stock import repost_stock
|
||||
webnotes.conn.auto_commit_on_many_writes = 1
|
||||
webnotes.conn.set_default("allow_negative_stock", 1)
|
||||
frappe.conn.auto_commit_on_many_writes = 1
|
||||
frappe.conn.set_default("allow_negative_stock", 1)
|
||||
|
||||
for warehouse in webnotes.conn.sql("select name from `tabWarehouse`"):
|
||||
for warehouse in frappe.conn.sql("select name from `tabWarehouse`"):
|
||||
repost_stock(newdn, warehouse[0])
|
||||
|
||||
webnotes.conn.set_default("allow_negative_stock",
|
||||
webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
|
||||
webnotes.conn.auto_commit_on_many_writes = 0
|
||||
frappe.conn.set_default("allow_negative_stock",
|
||||
frappe.conn.get_value("Stock Settings", None, "allow_negative_stock"))
|
||||
frappe.conn.auto_commit_on_many_writes = 0
|
||||
|
||||
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
|
||||
if not end_of_life:
|
||||
end_of_life = webnotes.conn.get_value("Item", item_code, "end_of_life")
|
||||
end_of_life = frappe.conn.get_value("Item", item_code, "end_of_life")
|
||||
|
||||
if end_of_life and getdate(end_of_life) <= now_datetime().date():
|
||||
msg = (_("Item") + " %(item_code)s: " + _("reached its end of life on") + \
|
||||
@@ -270,14 +270,14 @@ def validate_end_of_life(item_code, end_of_life=None, verbose=1):
|
||||
"in Item master") % {
|
||||
"item_code": item_code,
|
||||
"date": formatdate(end_of_life),
|
||||
"end_of_life_label": webnotes.get_doctype("Item").get_label("end_of_life")
|
||||
"end_of_life_label": frappe.get_doctype("Item").get_label("end_of_life")
|
||||
}
|
||||
|
||||
_msgprint(msg, verbose)
|
||||
|
||||
def validate_is_stock_item(item_code, is_stock_item=None, verbose=1):
|
||||
if not is_stock_item:
|
||||
is_stock_item = webnotes.conn.get_value("Item", item_code, "is_stock_item")
|
||||
is_stock_item = frappe.conn.get_value("Item", item_code, "is_stock_item")
|
||||
|
||||
if is_stock_item != "Yes":
|
||||
msg = (_("Item") + " %(item_code)s: " + _("is not a Stock Item")) % {
|
||||
@@ -288,7 +288,7 @@ def validate_is_stock_item(item_code, is_stock_item=None, verbose=1):
|
||||
|
||||
def validate_cancelled_item(item_code, docstatus=None, verbose=1):
|
||||
if docstatus is None:
|
||||
docstatus = webnotes.conn.get_value("Item", item_code, "docstatus")
|
||||
docstatus = frappe.conn.get_value("Item", item_code, "docstatus")
|
||||
|
||||
if docstatus == 2:
|
||||
msg = (_("Item") + " %(item_code)s: " + _("is a cancelled Item")) % {
|
||||
@@ -301,13 +301,13 @@ def _msgprint(msg, verbose):
|
||||
if verbose:
|
||||
msgprint(msg, raise_exception=True)
|
||||
else:
|
||||
raise webnotes.ValidationError, msg
|
||||
raise frappe.ValidationError, msg
|
||||
|
||||
|
||||
def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
"""returns last purchase details in stock uom"""
|
||||
# get last purchase order item details
|
||||
last_purchase_order = webnotes.conn.sql("""\
|
||||
last_purchase_order = frappe.conn.sql("""\
|
||||
select po.name, po.transaction_date, po.conversion_rate,
|
||||
po_item.conversion_factor, po_item.base_price_list_rate,
|
||||
po_item.discount_percentage, po_item.base_rate
|
||||
@@ -318,7 +318,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
limit 1""", (item_code, cstr(doc_name)), as_dict=1)
|
||||
|
||||
# get last purchase receipt item details
|
||||
last_purchase_receipt = webnotes.conn.sql("""\
|
||||
last_purchase_receipt = frappe.conn.sql("""\
|
||||
select pr.name, pr.posting_date, pr.posting_time, pr.conversion_rate,
|
||||
pr_item.conversion_factor, pr_item.base_price_list_rate, pr_item.discount_percentage,
|
||||
pr_item.base_rate
|
||||
@@ -346,10 +346,10 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
purchase_date = purchase_receipt_date
|
||||
|
||||
else:
|
||||
return webnotes._dict()
|
||||
return frappe._dict()
|
||||
|
||||
conversion_factor = flt(last_purchase.conversion_factor)
|
||||
out = webnotes._dict({
|
||||
out = frappe._dict({
|
||||
"base_price_list_rate": flt(last_purchase.base_price_list_rate) / conversion_factor,
|
||||
"base_rate": flt(last_purchase.base_rate) / conversion_factor,
|
||||
"discount_percentage": flt(last_purchase.discount_percentage),
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.test_runner import make_test_records
|
||||
from frappe.test_runner import make_test_records
|
||||
|
||||
test_ignore = ["BOM"]
|
||||
test_dependencies = ["Warehouse"]
|
||||
@@ -13,7 +13,7 @@ test_dependencies = ["Warehouse"]
|
||||
class TestItem(unittest.TestCase):
|
||||
def test_default_warehouse(self):
|
||||
from erpnext.stock.doctype.item.item import WarehouseNotSet
|
||||
item = webnotes.bean(copy=test_records[0])
|
||||
item = frappe.bean(copy=test_records[0])
|
||||
item.doc.is_stock_item = "Yes"
|
||||
item.doc.default_warehouse = None
|
||||
self.assertRaises(WarehouseNotSet, item.insert)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import throw, _
|
||||
import frappe
|
||||
from frappe import throw, _
|
||||
|
||||
class ItemPriceDuplicateItem(webnotes.ValidationError): pass
|
||||
class ItemPriceDuplicateItem(frappe.ValidationError): pass
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -19,7 +19,7 @@ class DocType:
|
||||
self.update_item_details()
|
||||
|
||||
def validate_item(self):
|
||||
if not webnotes.conn.exists("Item", self.doc.item_code):
|
||||
if not frappe.conn.exists("Item", self.doc.item_code):
|
||||
throw("{doctype}: {item} {not_found}".format(**{
|
||||
"doctype": _("Item"),
|
||||
"item": self.doc.item_code,
|
||||
@@ -27,7 +27,7 @@ class DocType:
|
||||
}))
|
||||
|
||||
def validate_price_list(self):
|
||||
enabled = webnotes.conn.get_value("Price List", self.doc.price_list, "enabled")
|
||||
enabled = frappe.conn.get_value("Price List", self.doc.price_list, "enabled")
|
||||
if not enabled:
|
||||
throw("{message}: {price_list} {disabled}".format(**{
|
||||
"message": _("Price List"),
|
||||
@@ -36,7 +36,7 @@ class DocType:
|
||||
}))
|
||||
|
||||
def check_duplicate_item(self):
|
||||
if webnotes.conn.sql("""select name from `tabItem Price`
|
||||
if frappe.conn.sql("""select name from `tabItem Price`
|
||||
where item_code=%s and price_list=%s and name!=%s""",
|
||||
(self.doc.item_code, self.doc.price_list, self.doc.name)):
|
||||
throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{
|
||||
@@ -48,10 +48,10 @@ class DocType:
|
||||
|
||||
def update_price_list_details(self):
|
||||
self.doc.buying, self.doc.selling, self.doc.currency = \
|
||||
webnotes.conn.get_value("Price List", {"name": self.doc.price_list, "enabled": 1},
|
||||
frappe.conn.get_value("Price List", {"name": self.doc.price_list, "enabled": 1},
|
||||
["buying", "selling", "currency"])
|
||||
|
||||
def update_item_details(self):
|
||||
self.doc.item_name, self.doc.item_description = webnotes.conn.get_value("Item",
|
||||
self.doc.item_name, self.doc.item_description = frappe.conn.get_value("Item",
|
||||
self.doc.item_code, ["item_name", "description"])
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class TestItem(unittest.TestCase):
|
||||
def test_duplicate_item(self):
|
||||
from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem
|
||||
bean = webnotes.bean(copy=test_records[0])
|
||||
bean = frappe.bean(copy=test_records[0])
|
||||
self.assertRaises(ItemPriceDuplicateItem, bean.insert)
|
||||
|
||||
test_records = [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
wn.provide("erpnext.stock");
|
||||
wn.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
frappe.provide("erpnext.stock");
|
||||
frappe.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
|
||||
erpnext.stock.LandedCostWizard = erpnext.stock.StockController.extend({
|
||||
setup: function() {
|
||||
var me = this;
|
||||
this.frm.fields_dict.lc_pr_details.grid.get_field('purchase_receipt').get_query =
|
||||
function() {
|
||||
if(!me.frm.doc.company) msgprint(wn._("Please enter company first"));
|
||||
if(!me.frm.doc.company) msgprint(frappe._("Please enter company first"));
|
||||
return {
|
||||
filters:[
|
||||
['Purchase Receipt', 'docstatus', '=', '1'],
|
||||
@@ -20,7 +20,7 @@ erpnext.stock.LandedCostWizard = erpnext.stock.StockController.extend({
|
||||
};
|
||||
|
||||
this.frm.fields_dict.landed_cost_details.grid.get_field('account_head').get_query = function() {
|
||||
if(!me.frm.doc.company) msgprint(wn._("Please enter company first"));
|
||||
if(!me.frm.doc.company) msgprint(frappe._("Please enter company first"));
|
||||
return {
|
||||
filters:[
|
||||
['Account', 'group_or_ledger', '=', 'Ledger'],
|
||||
@@ -34,7 +34,7 @@ erpnext.stock.LandedCostWizard = erpnext.stock.StockController.extend({
|
||||
|
||||
this.frm.fields_dict.landed_cost_details.grid.get_field('cost_center').get_query =
|
||||
function() {
|
||||
if(!me.frm.doc.company) msgprint(wn._("Please enter company first"));
|
||||
if(!me.frm.doc.company) msgprint(frappe._("Please enter company first"));
|
||||
return {
|
||||
filters:[
|
||||
['Cost Center', 'group_or_ledger', '=', 'Ledger'],
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint, cstr, flt
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
import frappe
|
||||
from frappe.utils import cint, cstr, flt
|
||||
from frappe.model.doc import addchild
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -30,15 +30,15 @@ class DocType:
|
||||
|
||||
def validate_purchase_receipts(self, purchase_receipts):
|
||||
for pr in purchase_receipts:
|
||||
if webnotes.conn.get_value("Purchase Receipt", pr, "docstatus") != 1:
|
||||
webnotes.throw(_("Purchase Receipt") + ": " + pr + _(" is not submitted document"))
|
||||
if frappe.conn.get_value("Purchase Receipt", pr, "docstatus") != 1:
|
||||
frappe.throw(_("Purchase Receipt") + ": " + pr + _(" is not submitted document"))
|
||||
|
||||
def add_charges_in_pr(self, purchase_receipts):
|
||||
""" Add additional charges in selected pr proportionately"""
|
||||
total_amt = self.get_total_pr_amt(purchase_receipts)
|
||||
|
||||
for pr in purchase_receipts:
|
||||
pr_bean = webnotes.bean('Purchase Receipt', pr)
|
||||
pr_bean = frappe.bean('Purchase Receipt', pr)
|
||||
idx = max([d.idx for d in pr_bean.doclist.get({"parentfield": "other_charges"})])
|
||||
|
||||
for lc in self.doclist.get({"parentfield": "landed_cost_details"}):
|
||||
@@ -76,24 +76,24 @@ class DocType:
|
||||
d.save()
|
||||
|
||||
def get_total_pr_amt(self, purchase_receipts):
|
||||
return webnotes.conn.sql("""SELECT SUM(net_total) FROM `tabPurchase Receipt`
|
||||
return frappe.conn.sql("""SELECT SUM(net_total) FROM `tabPurchase Receipt`
|
||||
WHERE name in (%s)""" % ', '.join(['%s']*len(purchase_receipts)),
|
||||
tuple(purchase_receipts))[0][0]
|
||||
|
||||
def cancel_pr(self, purchase_receipts):
|
||||
for pr in purchase_receipts:
|
||||
pr_bean = webnotes.bean("Purchase Receipt", pr)
|
||||
pr_bean = frappe.bean("Purchase Receipt", pr)
|
||||
|
||||
pr_bean.run_method("update_ordered_qty")
|
||||
|
||||
webnotes.conn.sql("""delete from `tabStock Ledger Entry`
|
||||
frappe.conn.sql("""delete from `tabStock Ledger Entry`
|
||||
where voucher_type='Purchase Receipt' and voucher_no=%s""", pr)
|
||||
webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type='Purchase Receipt'
|
||||
frappe.conn.sql("""delete from `tabGL Entry` where voucher_type='Purchase Receipt'
|
||||
and voucher_no=%s""", pr)
|
||||
|
||||
def submit_pr(self, purchase_receipts):
|
||||
for pr in purchase_receipts:
|
||||
pr_bean = webnotes.bean("Purchase Receipt", pr)
|
||||
pr_bean = frappe.bean("Purchase Receipt", pr)
|
||||
pr_bean.run_method("update_ordered_qty")
|
||||
pr_bean.run_method("update_stock")
|
||||
pr_bean.run_method("make_gl_entries")
|
||||
@@ -15,40 +15,40 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
||||
cur_frm.dashboard.reset();
|
||||
if(doc.docstatus===1) {
|
||||
if(doc.status==="Stopped") {
|
||||
cur_frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop")
|
||||
cur_frm.dashboard.set_headline_alert(frappe._("Stopped"), "alert-danger", "icon-stop")
|
||||
}
|
||||
cur_frm.dashboard.add_progress(cint(doc.per_ordered) + "% "
|
||||
+ wn._("Fulfilled"), cint(doc.per_ordered));
|
||||
+ frappe._("Fulfilled"), cint(doc.per_ordered));
|
||||
}
|
||||
|
||||
if(doc.docstatus==0) {
|
||||
cur_frm.add_custom_button(wn._("Get Items from BOM"), cur_frm.cscript.get_items_from_bom, "icon-sitemap");
|
||||
cur_frm.add_custom_button(frappe._("Get Items from BOM"), cur_frm.cscript.get_items_from_bom, "icon-sitemap");
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped') {
|
||||
if(doc.material_request_type === "Purchase")
|
||||
cur_frm.add_custom_button(wn._("Make Supplier Quotation"),
|
||||
cur_frm.add_custom_button(frappe._("Make Supplier Quotation"),
|
||||
this.make_supplier_quotation);
|
||||
|
||||
if(doc.material_request_type === "Transfer" && doc.status === "Submitted")
|
||||
cur_frm.add_custom_button(wn._("Transfer Material"), this.make_stock_entry);
|
||||
cur_frm.add_custom_button(frappe._("Transfer Material"), this.make_stock_entry);
|
||||
|
||||
if(flt(doc.per_ordered, 2) < 100) {
|
||||
if(doc.material_request_type === "Purchase")
|
||||
cur_frm.add_custom_button(wn._('Make Purchase Order'),
|
||||
cur_frm.add_custom_button(frappe._('Make Purchase Order'),
|
||||
this.make_purchase_order);
|
||||
|
||||
cur_frm.add_custom_button(wn._('Stop Material Request'),
|
||||
cur_frm.add_custom_button(frappe._('Stop Material Request'),
|
||||
cur_frm.cscript['Stop Material Request'], "icon-exclamation");
|
||||
}
|
||||
cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
|
||||
cur_frm.add_custom_button(frappe._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
|
||||
|
||||
}
|
||||
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(wn._('From Sales Order'),
|
||||
cur_frm.add_custom_button(frappe._('From Sales Order'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request",
|
||||
source_doctype: "Sales Order",
|
||||
get_query_filters: {
|
||||
@@ -62,7 +62,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button(wn._('Unstop Material Request'),
|
||||
cur_frm.add_custom_button(frappe._('Unstop Material Request'),
|
||||
cur_frm.cscript['Unstop Material Request'], "icon-check");
|
||||
|
||||
},
|
||||
@@ -70,7 +70,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
||||
schedule_date: function(doc, cdt, cdn) {
|
||||
var val = locals[cdt][cdn].schedule_date;
|
||||
if(val) {
|
||||
$.each(wn.model.get("Material Request Item", { parent: cur_frm.doc.name }), function(i, d) {
|
||||
$.each(frappe.model.get("Material Request Item", { parent: cur_frm.doc.name }), function(i, d) {
|
||||
if(!d.schedule_date) {
|
||||
d.schedule_date = val;
|
||||
}
|
||||
@@ -80,26 +80,26 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
||||
},
|
||||
|
||||
get_items_from_bom: function() {
|
||||
var d = new wn.ui.Dialog({
|
||||
title: wn._("Get Items from BOM"),
|
||||
var d = new frappe.ui.Dialog({
|
||||
title: frappe._("Get Items from BOM"),
|
||||
fields: [
|
||||
{"fieldname":"bom", "fieldtype":"Link", "label":wn._("BOM"),
|
||||
{"fieldname":"bom", "fieldtype":"Link", "label":frappe._("BOM"),
|
||||
options:"BOM"},
|
||||
{"fieldname":"fetch_exploded", "fieldtype":"Check",
|
||||
"label":wn._("Fetch exploded BOM (including sub-assemblies)"), "default":1},
|
||||
{fieldname:"fetch", "label":wn._("Get Items from BOM"), "fieldtype":"Button"}
|
||||
"label":frappe._("Fetch exploded BOM (including sub-assemblies)"), "default":1},
|
||||
{fieldname:"fetch", "label":frappe._("Get Items from BOM"), "fieldtype":"Button"}
|
||||
]
|
||||
});
|
||||
d.get_input("fetch").on("click", function() {
|
||||
var values = d.get_values();
|
||||
if(!values) return;
|
||||
|
||||
wn.call({
|
||||
frappe.call({
|
||||
method: "erpnext.manufacturing.doctype.bom.bom.get_bom_items",
|
||||
args: values,
|
||||
callback: function(r) {
|
||||
$.each(r.message, function(i, item) {
|
||||
var d = wn.model.add_child(cur_frm.doc, "Material Request Item", "indent_details");
|
||||
var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "indent_details");
|
||||
d.item_code = item.item_code;
|
||||
d.description = item.description;
|
||||
d.warehouse = item.default_warehouse;
|
||||
@@ -127,21 +127,21 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
||||
},
|
||||
|
||||
make_purchase_order: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
},
|
||||
|
||||
make_supplier_quotation: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_supplier_quotation",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
},
|
||||
|
||||
make_stock_entry: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_stock_entry",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
@@ -154,15 +154,15 @@ $.extend(cur_frm.cscript, new erpnext.buying.MaterialRequestController({frm: cur
|
||||
cur_frm.cscript.qty = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (flt(d.qty) < flt(d.min_order_qty))
|
||||
alert(wn._("Warning: Material Requested Qty is less than Minimum Order Qty"));
|
||||
alert(frappe._("Warning: Material Requested Qty is less than Minimum Order Qty"));
|
||||
};
|
||||
|
||||
cur_frm.cscript['Stop Material Request'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
var check = confirm(wn._("Do you really want to STOP this Material Request?"));
|
||||
var check = confirm(frappe._("Do you really want to STOP this Material Request?"));
|
||||
|
||||
if (check) {
|
||||
return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
@@ -170,10 +170,10 @@ cur_frm.cscript['Stop Material Request'] = function() {
|
||||
|
||||
cur_frm.cscript['Unstop Material Request'] = function(){
|
||||
var doc = cur_frm.doc;
|
||||
var check = confirm(wn._("Do you really want to UNSTOP this Material Request?"));
|
||||
var check = confirm(frappe._("Do you really want to UNSTOP this Material Request?"));
|
||||
|
||||
if (check) {
|
||||
return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.utils import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe.model.utils import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
|
||||
from erpnext.controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
@@ -37,25 +37,25 @@ class DocType(BuyingController):
|
||||
|
||||
for so_no in so_items.keys():
|
||||
for item in so_items[so_no].keys():
|
||||
already_indented = webnotes.conn.sql("""select sum(ifnull(qty, 0))
|
||||
already_indented = frappe.conn.sql("""select sum(ifnull(qty, 0))
|
||||
from `tabMaterial Request Item`
|
||||
where item_code = %s and sales_order_no = %s and
|
||||
docstatus = 1 and parent != %s""", (item, so_no, self.doc.name))
|
||||
already_indented = already_indented and flt(already_indented[0][0]) or 0
|
||||
|
||||
actual_so_qty = webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tabSales Order Item`
|
||||
actual_so_qty = frappe.conn.sql("""select sum(ifnull(qty, 0)) from `tabSales Order Item`
|
||||
where parent = %s and item_code = %s and docstatus = 1""", (so_no, item))
|
||||
actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0
|
||||
|
||||
if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty):
|
||||
webnotes.throw("You can raise indent of maximum qty: %s for item: %s against sales order: %s\
|
||||
frappe.throw("You can raise indent of maximum qty: %s for item: %s against sales order: %s\
|
||||
\n Anyway, you can add more qty in new row for the same item."
|
||||
% (actual_so_qty - already_indented, item, so_no))
|
||||
|
||||
def validate_schedule_date(self):
|
||||
for d in getlist(self.doclist, 'indent_details'):
|
||||
if d.schedule_date < self.doc.transaction_date:
|
||||
webnotes.throw(_("Expected Date cannot be before Material Request Date"))
|
||||
frappe.throw(_("Expected Date cannot be before Material Request Date"))
|
||||
|
||||
# Validate
|
||||
# ---------------------
|
||||
@@ -85,9 +85,9 @@ class DocType(BuyingController):
|
||||
|
||||
from erpnext.stock.utils import update_bin
|
||||
for d in getlist(self.doclist, 'indent_details'):
|
||||
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
|
||||
if frappe.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
|
||||
if not d.warehouse:
|
||||
webnotes.throw("Please Enter Warehouse for Item %s as it is stock item"
|
||||
frappe.throw("Please Enter Warehouse for Item %s as it is stock item"
|
||||
% cstr(d.item_code))
|
||||
|
||||
qty =flt(d.qty)
|
||||
@@ -103,17 +103,17 @@ class DocType(BuyingController):
|
||||
update_bin(args)
|
||||
|
||||
def on_submit(self):
|
||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
||||
frappe.conn.set(self.doc, 'status', 'Submitted')
|
||||
self.update_bin(is_submit = 1, is_stopped = 0)
|
||||
|
||||
def check_modified_date(self):
|
||||
mod_db = webnotes.conn.sql("""select modified from `tabMaterial Request` where name = %s""",
|
||||
mod_db = frappe.conn.sql("""select modified from `tabMaterial Request` where name = %s""",
|
||||
self.doc.name)
|
||||
date_diff = webnotes.conn.sql("""select TIMEDIFF('%s', '%s')"""
|
||||
date_diff = frappe.conn.sql("""select TIMEDIFF('%s', '%s')"""
|
||||
% (mod_db[0][0], cstr(self.doc.modified)))
|
||||
|
||||
if date_diff and date_diff[0][0]:
|
||||
webnotes.throw(cstr(self.doc.doctype) + " => " + cstr(self.doc.name) + " has been modified. Please Refresh.")
|
||||
frappe.throw(cstr(self.doc.doctype) + " => " + cstr(self.doc.name) + " has been modified. Please Refresh.")
|
||||
|
||||
def update_status(self, status):
|
||||
self.check_modified_date()
|
||||
@@ -121,7 +121,7 @@ class DocType(BuyingController):
|
||||
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
|
||||
|
||||
# Step 2:=> Set status
|
||||
webnotes.conn.set(self.doc, 'status', cstr(status))
|
||||
frappe.conn.set(self.doc, 'status', cstr(status))
|
||||
|
||||
# Step 3:=> Acknowledge User
|
||||
msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
|
||||
@@ -140,7 +140,7 @@ class DocType(BuyingController):
|
||||
self.update_bin(is_submit = 0, is_stopped = (cstr(self.doc.status) == 'Stopped') and 1 or 0)
|
||||
|
||||
# Step 5:=> Set Status
|
||||
webnotes.conn.set(self.doc,'status','Cancelled')
|
||||
frappe.conn.set(self.doc,'status','Cancelled')
|
||||
|
||||
def update_completed_qty(self, mr_items=None):
|
||||
if self.doc.material_request_type != "Transfer":
|
||||
@@ -154,11 +154,11 @@ class DocType(BuyingController):
|
||||
per_ordered = 0.0
|
||||
for d in item_doclist:
|
||||
if d.name in mr_items:
|
||||
d.ordered_qty = flt(webnotes.conn.sql("""select sum(transfer_qty)
|
||||
d.ordered_qty = flt(frappe.conn.sql("""select sum(transfer_qty)
|
||||
from `tabStock Entry Detail` where material_request = %s
|
||||
and material_request_item = %s and docstatus = 1""",
|
||||
(self.doc.name, d.name))[0][0])
|
||||
webnotes.conn.set_value(d.doctype, d.name, "ordered_qty", d.ordered_qty)
|
||||
frappe.conn.set_value(d.doctype, d.name, "ordered_qty", d.ordered_qty)
|
||||
|
||||
# note: if qty is 0, its row is still counted in len(item_doclist)
|
||||
# hence adding 1 to per_ordered
|
||||
@@ -168,7 +168,7 @@ class DocType(BuyingController):
|
||||
per_ordered += flt(d.ordered_qty / flt(d.qty))
|
||||
|
||||
self.doc.per_ordered = flt((per_ordered / flt(len(item_doclist))) * 100.0, 2)
|
||||
webnotes.conn.set_value(self.doc.doctype, self.doc.name, "per_ordered", self.doc.per_ordered)
|
||||
frappe.conn.set_value(self.doc.doctype, self.doc.name, "per_ordered", self.doc.per_ordered)
|
||||
|
||||
def update_completed_qty(bean, method):
|
||||
if bean.doc.doctype == "Stock Entry":
|
||||
@@ -179,13 +179,13 @@ def update_completed_qty(bean, method):
|
||||
material_request_map.setdefault(d.material_request, []).append(d.material_request_item)
|
||||
|
||||
for mr_name, mr_items in material_request_map.items():
|
||||
mr_obj = webnotes.get_obj("Material Request", mr_name, with_children=1)
|
||||
mr_doctype = webnotes.get_doctype("Material Request")
|
||||
mr_obj = frappe.get_obj("Material Request", mr_name, with_children=1)
|
||||
mr_doctype = frappe.get_doctype("Material Request")
|
||||
|
||||
if mr_obj.doc.status in ["Stopped", "Cancelled"]:
|
||||
webnotes.throw(_("Material Request") + ": %s, " % mr_obj.doc.name
|
||||
frappe.throw(_("Material Request") + ": %s, " % mr_obj.doc.name
|
||||
+ _(mr_doctype.get_label("status")) + " = %s. " % _(mr_obj.doc.status)
|
||||
+ _("Cannot continue."), exc=webnotes.InvalidStatusError)
|
||||
+ _("Cannot continue."), exc=frappe.InvalidStatusError)
|
||||
|
||||
_update_requested_qty(bean, mr_obj, mr_items)
|
||||
|
||||
@@ -221,16 +221,16 @@ def _update_requested_qty(bean, mr_obj, mr_items):
|
||||
})
|
||||
|
||||
def set_missing_values(source, target_doclist):
|
||||
po = webnotes.bean(target_doclist)
|
||||
po = frappe.bean(target_doclist)
|
||||
po.run_method("set_missing_values")
|
||||
|
||||
def update_item(obj, target, source_parent):
|
||||
target.conversion_factor = 1
|
||||
target.qty = flt(obj.qty) - flt(obj.ordered_qty)
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
|
||||
doclist = get_mapped_doclist("Material Request", source_name, {
|
||||
"Material Request": {
|
||||
@@ -255,13 +255,13 @@ def make_purchase_order(source_name, target_doclist=None):
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order_based_on_supplier(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
if target_doclist:
|
||||
if isinstance(target_doclist, basestring):
|
||||
import json
|
||||
target_doclist = webnotes.doclist(json.loads(target_doclist))
|
||||
target_doclist = frappe.doclist(json.loads(target_doclist))
|
||||
target_doclist = target_doclist.get({"parentfield": ["!=", "po_details"]})
|
||||
|
||||
material_requests, supplier_items = get_material_requests_based_on_supplier(source_name)
|
||||
@@ -298,9 +298,9 @@ def make_purchase_order_based_on_supplier(source_name, target_doclist=None):
|
||||
return [d.fields for d in target_doclist]
|
||||
|
||||
def get_material_requests_based_on_supplier(supplier):
|
||||
supplier_items = [d[0] for d in webnotes.conn.get_values("Item",
|
||||
supplier_items = [d[0] for d in frappe.conn.get_values("Item",
|
||||
{"default_supplier": supplier})]
|
||||
material_requests = webnotes.conn.sql_list("""select distinct mr.name
|
||||
material_requests = frappe.conn.sql_list("""select distinct mr.name
|
||||
from `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
|
||||
where mr.name = mr_item.parent
|
||||
and mr_item.item_code in (%s)
|
||||
@@ -311,9 +311,9 @@ def get_material_requests_based_on_supplier(supplier):
|
||||
tuple(supplier_items))
|
||||
return material_requests, supplier_items
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_supplier_quotation(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
|
||||
doclist = get_mapped_doclist("Material Request", source_name, {
|
||||
"Material Request": {
|
||||
@@ -335,9 +335,9 @@ def make_supplier_quotation(source_name, target_doclist=None):
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_stock_entry(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
|
||||
def update_item(obj, target, source_parent):
|
||||
target.conversion_factor = 1
|
||||
@@ -346,7 +346,7 @@ def make_stock_entry(source_name, target_doclist=None):
|
||||
|
||||
def set_missing_values(source, target):
|
||||
target[0].purpose = "Material Transfer"
|
||||
se = webnotes.bean(target)
|
||||
se = frappe.bean(target)
|
||||
se.run_method("get_stock_and_rate")
|
||||
|
||||
doclist = get_mapped_doclist("Material Request", source_name, {
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes, unittest
|
||||
from webnotes.utils import flt
|
||||
import frappe, unittest
|
||||
from frappe.utils import flt
|
||||
|
||||
class TestMaterialRequest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
frappe.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
|
||||
def test_make_purchase_order(self):
|
||||
from erpnext.stock.doctype.material_request.material_request import make_purchase_order
|
||||
|
||||
mr = webnotes.bean(copy=test_records[0]).insert()
|
||||
mr = frappe.bean(copy=test_records[0]).insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_purchase_order,
|
||||
self.assertRaises(frappe.ValidationError, make_purchase_order,
|
||||
mr.doc.name)
|
||||
|
||||
mr = webnotes.bean("Material Request", mr.doc.name)
|
||||
mr = frappe.bean("Material Request", mr.doc.name)
|
||||
mr.submit()
|
||||
po = make_purchase_order(mr.doc.name)
|
||||
|
||||
@@ -30,12 +30,12 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
def test_make_supplier_quotation(self):
|
||||
from erpnext.stock.doctype.material_request.material_request import make_supplier_quotation
|
||||
|
||||
mr = webnotes.bean(copy=test_records[0]).insert()
|
||||
mr = frappe.bean(copy=test_records[0]).insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_supplier_quotation,
|
||||
self.assertRaises(frappe.ValidationError, make_supplier_quotation,
|
||||
mr.doc.name)
|
||||
|
||||
mr = webnotes.bean("Material Request", mr.doc.name)
|
||||
mr = frappe.bean("Material Request", mr.doc.name)
|
||||
mr.submit()
|
||||
sq = make_supplier_quotation(mr.doc.name)
|
||||
|
||||
@@ -46,12 +46,12 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
def test_make_stock_entry(self):
|
||||
from erpnext.stock.doctype.material_request.material_request import make_stock_entry
|
||||
|
||||
mr = webnotes.bean(copy=test_records[0]).insert()
|
||||
mr = frappe.bean(copy=test_records[0]).insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_stock_entry,
|
||||
self.assertRaises(frappe.ValidationError, make_stock_entry,
|
||||
mr.doc.name)
|
||||
|
||||
mr = webnotes.bean("Material Request", mr.doc.name)
|
||||
mr = frappe.bean("Material Request", mr.doc.name)
|
||||
mr.doc.material_request_type = "Transfer"
|
||||
mr.submit()
|
||||
se = make_stock_entry(mr.doc.name)
|
||||
@@ -65,13 +65,13 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
self.assertEquals(val, doclist[i].fields.get(fieldname))
|
||||
|
||||
def _test_requested_qty(self, qty1, qty2):
|
||||
self.assertEqual(flt(webnotes.conn.get_value("Bin", {"item_code": "_Test Item Home Desktop 100",
|
||||
self.assertEqual(flt(frappe.conn.get_value("Bin", {"item_code": "_Test Item Home Desktop 100",
|
||||
"warehouse": "_Test Warehouse - _TC"}, "indented_qty")), qty1)
|
||||
self.assertEqual(flt(webnotes.conn.get_value("Bin", {"item_code": "_Test Item Home Desktop 200",
|
||||
self.assertEqual(flt(frappe.conn.get_value("Bin", {"item_code": "_Test Item Home Desktop 200",
|
||||
"warehouse": "_Test Warehouse - _TC"}, "indented_qty")), qty2)
|
||||
|
||||
def _insert_stock_entry(self, qty1, qty2):
|
||||
se = webnotes.bean([
|
||||
se = frappe.bean([
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Stock Entry",
|
||||
@@ -109,10 +109,10 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
se.submit()
|
||||
|
||||
def test_completed_qty_for_purchase(self):
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
frappe.conn.sql("""delete from `tabBin`""")
|
||||
|
||||
# submit material request of type Purchase
|
||||
mr = webnotes.bean(copy=test_records[0])
|
||||
mr = frappe.bean(copy=test_records[0])
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
|
||||
@@ -133,14 +133,14 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
|
||||
|
||||
# check for stopped status of Material Request
|
||||
po = webnotes.bean(copy=po_doclist)
|
||||
po = frappe.bean(copy=po_doclist)
|
||||
po.insert()
|
||||
mr.obj.update_status('Stopped')
|
||||
self.assertRaises(webnotes.ValidationError, po.submit)
|
||||
self.assertRaises(webnotes.ValidationError, po.cancel)
|
||||
self.assertRaises(frappe.ValidationError, po.submit)
|
||||
self.assertRaises(frappe.ValidationError, po.cancel)
|
||||
|
||||
mr.obj.update_status('Submitted')
|
||||
po = webnotes.bean(copy=po_doclist)
|
||||
po = frappe.bean(copy=po_doclist)
|
||||
po.insert()
|
||||
po.submit()
|
||||
|
||||
@@ -156,11 +156,11 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
self._test_requested_qty(54.0, 3.0)
|
||||
|
||||
def test_completed_qty_for_transfer(self):
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
webnotes.conn.sql("""delete from `tabStock Ledger Entry`""")
|
||||
frappe.conn.sql("""delete from `tabBin`""")
|
||||
frappe.conn.sql("""delete from `tabStock Ledger Entry`""")
|
||||
|
||||
# submit material request of type Purchase
|
||||
mr = webnotes.bean(copy=test_records[0])
|
||||
mr = frappe.bean(copy=test_records[0])
|
||||
mr.doc.material_request_type = "Transfer"
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
@@ -196,14 +196,14 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
self._insert_stock_entry(27.0, 1.5)
|
||||
|
||||
# check for stopped status of Material Request
|
||||
se = webnotes.bean(copy=se_doclist)
|
||||
se = frappe.bean(copy=se_doclist)
|
||||
se.insert()
|
||||
mr.obj.update_status('Stopped')
|
||||
self.assertRaises(webnotes.ValidationError, se.submit)
|
||||
self.assertRaises(webnotes.ValidationError, se.cancel)
|
||||
self.assertRaises(frappe.ValidationError, se.submit)
|
||||
self.assertRaises(frappe.ValidationError, se.cancel)
|
||||
|
||||
mr.obj.update_status('Submitted')
|
||||
se = webnotes.bean(copy=se_doclist)
|
||||
se = frappe.bean(copy=se_doclist)
|
||||
se.insert()
|
||||
se.submit()
|
||||
|
||||
@@ -219,11 +219,11 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
self._test_requested_qty(54.0, 3.0)
|
||||
|
||||
def test_completed_qty_for_over_transfer(self):
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
webnotes.conn.sql("""delete from `tabStock Ledger Entry`""")
|
||||
frappe.conn.sql("""delete from `tabBin`""")
|
||||
frappe.conn.sql("""delete from `tabStock Ledger Entry`""")
|
||||
|
||||
# submit material request of type Purchase
|
||||
mr = webnotes.bean(copy=test_records[0])
|
||||
mr = frappe.bean(copy=test_records[0])
|
||||
mr.doc.material_request_type = "Transfer"
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
@@ -259,14 +259,14 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
self._insert_stock_entry(60.0, 3.0)
|
||||
|
||||
# check for stopped status of Material Request
|
||||
se = webnotes.bean(copy=se_doclist)
|
||||
se = frappe.bean(copy=se_doclist)
|
||||
se.insert()
|
||||
mr.obj.update_status('Stopped')
|
||||
self.assertRaises(webnotes.ValidationError, se.submit)
|
||||
self.assertRaises(webnotes.ValidationError, se.cancel)
|
||||
self.assertRaises(frappe.ValidationError, se.submit)
|
||||
self.assertRaises(frappe.ValidationError, se.cancel)
|
||||
|
||||
mr.obj.update_status('Submitted')
|
||||
se = webnotes.bean(copy=se_doclist)
|
||||
se = frappe.bean(copy=se_doclist)
|
||||
se.insert()
|
||||
se.submit()
|
||||
|
||||
@@ -283,7 +283,7 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
|
||||
def test_incorrect_mapping_of_stock_entry(self):
|
||||
# submit material request of type Purchase
|
||||
mr = webnotes.bean(copy=test_records[0])
|
||||
mr = frappe.bean(copy=test_records[0])
|
||||
mr.doc.material_request_type = "Transfer"
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
@@ -312,12 +312,12 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
})
|
||||
|
||||
# check for stopped status of Material Request
|
||||
se = webnotes.bean(copy=se_doclist)
|
||||
self.assertRaises(webnotes.MappingMismatchError, se.insert)
|
||||
se = frappe.bean(copy=se_doclist)
|
||||
self.assertRaises(frappe.MappingMismatchError, se.insert)
|
||||
|
||||
def test_warehouse_company_validation(self):
|
||||
from erpnext.stock.utils import InvalidWarehouseCompany
|
||||
mr = webnotes.bean(copy=test_records[0])
|
||||
mr = frappe.bean(copy=test_records[0])
|
||||
mr.doc.company = "_Test Company 1"
|
||||
self.assertRaises(InvalidWarehouseCompany, mr.insert)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -4,26 +4,26 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.bean import getlist
|
||||
import frappe
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe.model.doc import addchild
|
||||
from frappe.model.bean import getlist
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def get_sales_bom_items(item_code):
|
||||
return webnotes.conn.sql("""select t1.item_code, t1.qty, t1.uom
|
||||
return frappe.conn.sql("""select t1.item_code, t1.qty, t1.uom
|
||||
from `tabSales BOM Item` t1, `tabSales BOM` t2
|
||||
where t2.new_item_code=%s and t1.parent = t2.name""", item_code, as_dict=1)
|
||||
|
||||
def get_packing_item_details(item):
|
||||
return webnotes.conn.sql("""select item_name, description, stock_uom from `tabItem`
|
||||
return frappe.conn.sql("""select item_name, description, stock_uom from `tabItem`
|
||||
where name = %s""", item, as_dict = 1)[0]
|
||||
|
||||
def get_bin_qty(item, warehouse):
|
||||
det = webnotes.conn.sql("""select actual_qty, projected_qty from `tabBin`
|
||||
det = frappe.conn.sql("""select actual_qty, projected_qty from `tabBin`
|
||||
where item_code = %s and warehouse = %s""", (item, warehouse), as_dict = 1)
|
||||
return det and det[0] or ''
|
||||
|
||||
@@ -66,7 +66,7 @@ def make_packing_list(obj, item_table_fieldname):
|
||||
for d in obj.doclist.get({"parentfield": item_table_fieldname}):
|
||||
warehouse = (item_table_fieldname == "sales_order_details") \
|
||||
and d.warehouse or d.warehouse
|
||||
if webnotes.conn.get_value("Sales BOM", {"new_item_code": d.item_code}):
|
||||
if frappe.conn.get_value("Sales BOM", {"new_item_code": d.item_code}):
|
||||
for i in get_sales_bom_items(d.item_code):
|
||||
update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty),
|
||||
warehouse, d, packing_list_idx)
|
||||
@@ -90,7 +90,7 @@ def cleanup_packing_list(obj, parent_items):
|
||||
return obj.doclist
|
||||
|
||||
# delete from doclist
|
||||
obj.doclist = webnotes.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname]
|
||||
obj.doclist = frappe.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname]
|
||||
not in delete_list, obj.doclist))
|
||||
|
||||
return obj.doclist
|
||||
@@ -45,13 +45,13 @@ cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.validate_case_nos = function(doc) {
|
||||
doc = locals[doc.doctype][doc.name];
|
||||
if(cint(doc.from_case_no)==0) {
|
||||
msgprint(wn._("Case No. cannot be 0"))
|
||||
msgprint(frappe._("Case No. cannot be 0"))
|
||||
validated = false;
|
||||
} else if(!cint(doc.to_case_no)) {
|
||||
doc.to_case_no = doc.from_case_no;
|
||||
refresh_field('to_case_no');
|
||||
} else if(cint(doc.to_case_no) < cint(doc.from_case_no)) {
|
||||
msgprint(wn._("'To Case No.' cannot be less than 'From Case No.'"));
|
||||
msgprint(frappe._("'To Case No.' cannot be less than 'From Case No.'"));
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
@@ -72,14 +72,14 @@ cur_frm.cscript.validate_duplicate_items = function(doc, ps_detail) {
|
||||
for(var i=0; i<ps_detail.length; i++) {
|
||||
for(var j=0; j<ps_detail.length; j++) {
|
||||
if(i!=j && ps_detail[i].item_code && ps_detail[i].item_code==ps_detail[j].item_code) {
|
||||
msgprint(wn._("You have entered duplicate items. Please rectify and try again."));
|
||||
msgprint(frappe._("You have entered duplicate items. Please rectify and try again."));
|
||||
validated = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(flt(ps_detail[i].qty)<=0) {
|
||||
msgprint(wn._("Invalid quantity specified for item ") + ps_detail[i].item_code +
|
||||
"."+wn._(" Quantity should be greater than 0."));
|
||||
msgprint(frappe._("Invalid quantity specified for item ") + ps_detail[i].item_code +
|
||||
"."+frappe._(" Quantity should be greater than 0."));
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
@@ -95,9 +95,9 @@ cur_frm.cscript.calc_net_total_pkg = function(doc, ps_detail) {
|
||||
for(var i=0; i<ps_detail.length; i++) {
|
||||
var item = ps_detail[i];
|
||||
if(item.weight_uom != doc.net_weight_uom) {
|
||||
msgprint(wn._("Different UOM for items will lead to incorrect")+
|
||||
wn._("(Total) Net Weight value. Make sure that Net Weight of each item is")+
|
||||
wn._("in the same UOM."))
|
||||
msgprint(frappe._("Different UOM for items will lead to incorrect")+
|
||||
frappe._("(Total) Net Weight value. Make sure that Net Weight of each item is")+
|
||||
frappe._("in the same UOM."))
|
||||
validated = false;
|
||||
}
|
||||
net_weight_pkg += flt(item.net_weight) * flt(item.qty);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt, cint
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.model.doc import addchild
|
||||
import frappe
|
||||
from frappe.utils import flt, cint
|
||||
from frappe import msgprint, _
|
||||
from frappe.model.doc import addchild
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -32,28 +32,28 @@ class DocType:
|
||||
"""
|
||||
Validates if delivery note has status as draft
|
||||
"""
|
||||
if cint(webnotes.conn.get_value("Delivery Note", self.doc.delivery_note, "docstatus")) != 0:
|
||||
if cint(frappe.conn.get_value("Delivery Note", self.doc.delivery_note, "docstatus")) != 0:
|
||||
msgprint(_("""Invalid Delivery Note. Delivery Note should exist and should be in draft state. Please rectify and try again."""), raise_exception=1)
|
||||
|
||||
def validate_items_mandatory(self):
|
||||
rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})]
|
||||
if not rows:
|
||||
webnotes.msgprint(_("No Items to Pack"), raise_exception=1)
|
||||
frappe.msgprint(_("No Items to Pack"), raise_exception=1)
|
||||
|
||||
def validate_case_nos(self):
|
||||
"""
|
||||
Validate if case nos overlap. If they do, recommend next case no.
|
||||
"""
|
||||
if not cint(self.doc.from_case_no):
|
||||
webnotes.msgprint(_("Please specify a valid 'From Case No.'"), raise_exception=1)
|
||||
frappe.msgprint(_("Please specify a valid 'From Case No.'"), raise_exception=1)
|
||||
elif not self.doc.to_case_no:
|
||||
self.doc.to_case_no = self.doc.from_case_no
|
||||
elif self.doc.from_case_no > self.doc.to_case_no:
|
||||
webnotes.msgprint(_("'To Case No.' cannot be less than 'From Case No.'"),
|
||||
frappe.msgprint(_("'To Case No.' cannot be less than 'From Case No.'"),
|
||||
raise_exception=1)
|
||||
|
||||
|
||||
res = webnotes.conn.sql("""SELECT name FROM `tabPacking Slip`
|
||||
res = frappe.conn.sql("""SELECT name FROM `tabPacking Slip`
|
||||
WHERE delivery_note = %(delivery_note)s AND docstatus = 1 AND
|
||||
(from_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s
|
||||
OR to_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s
|
||||
@@ -61,7 +61,7 @@ class DocType:
|
||||
""", self.doc.fields)
|
||||
|
||||
if res:
|
||||
webnotes.msgprint(_("""Case No(s) already in use. Please rectify and try again.
|
||||
frappe.msgprint(_("""Case No(s) already in use. Please rectify and try again.
|
||||
Recommended <b>From Case No. = %s</b>""") % self.get_recommended_case_no(),
|
||||
raise_exception=1)
|
||||
|
||||
@@ -94,7 +94,7 @@ class DocType:
|
||||
condition = " and item_code in (%s)" % (", ".join(["%s"]*len(rows)))
|
||||
|
||||
# gets item code, qty per item code, latest packed qty per item code and stock uom
|
||||
res = webnotes.conn.sql("""select item_code, ifnull(sum(qty), 0) as qty,
|
||||
res = frappe.conn.sql("""select item_code, ifnull(sum(qty), 0) as qty,
|
||||
(select sum(ifnull(psi.qty, 0) * (abs(ps.to_case_no - ps.from_case_no) + 1))
|
||||
from `tabPacking Slip` ps, `tabPacking Slip Item` psi
|
||||
where ps.name = psi.parent and ps.docstatus = 1
|
||||
@@ -119,7 +119,7 @@ class DocType:
|
||||
item['specified_qty'] = flt(ps_item_qty[item['item_code']])
|
||||
if not item['packed_qty']: item['packed_qty'] = 0
|
||||
|
||||
webnotes.msgprint("""
|
||||
frappe.msgprint("""
|
||||
Invalid Quantity specified (%(specified_qty)s %(stock_uom)s).
|
||||
%(packed_qty)s out of %(qty)s %(stock_uom)s already packed for %(item_code)s.
|
||||
<b>Recommended quantity for %(item_code)s = %(recommended_qty)s
|
||||
@@ -133,7 +133,7 @@ class DocType:
|
||||
self.doc.from_case_no = self.get_recommended_case_no()
|
||||
|
||||
for d in self.doclist.get({"parentfield": "item_details"}):
|
||||
res = webnotes.conn.get_value("Item", d.item_code,
|
||||
res = frappe.conn.get_value("Item", d.item_code,
|
||||
["net_weight", "weight_uom"], as_dict=True)
|
||||
|
||||
if res and len(res)>0:
|
||||
@@ -145,7 +145,7 @@ class DocType:
|
||||
Returns the next case no. for a new packing slip for a delivery
|
||||
note
|
||||
"""
|
||||
recommended_case_no = webnotes.conn.sql("""SELECT MAX(to_case_no) FROM `tabPacking Slip`
|
||||
recommended_case_no = frappe.conn.sql("""SELECT MAX(to_case_no) FROM `tabPacking Slip`
|
||||
WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields)
|
||||
|
||||
return cint(recommended_case_no[0][0]) + 1
|
||||
@@ -165,7 +165,7 @@ class DocType:
|
||||
|
||||
def item_details(doctype, txt, searchfield, start, page_len, filters):
|
||||
from erpnext.controllers.queries import get_match_cond
|
||||
return webnotes.conn.sql("""select name, item_name, description from `tabItem`
|
||||
return frappe.conn.sql("""select name, item_name, description from `tabItem`
|
||||
where name in ( select item_code FROM `tabDelivery Note Item`
|
||||
where parent= %s
|
||||
and ifnull(qty, 0) > ifnull(packed_qty, 0))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -8,10 +8,10 @@ $.extend(cur_frm.cscript, {
|
||||
|
||||
refresh: function() {
|
||||
cur_frm.add_custom_button("Add / Edit Prices", function() {
|
||||
wn.route_options = {
|
||||
frappe.route_options = {
|
||||
"price_list": cur_frm.doc.name
|
||||
};
|
||||
wn.set_route("Report", "Item Price");
|
||||
frappe.set_route("Report", "Item Price");
|
||||
}, "icon-money");
|
||||
}
|
||||
});
|
||||
@@ -2,11 +2,11 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _, throw
|
||||
from webnotes.utils import cint
|
||||
from webnotes.model.controller import DocListController
|
||||
import webnotes.defaults
|
||||
import frappe
|
||||
from frappe import msgprint, _, throw
|
||||
from frappe.utils import cint
|
||||
from frappe.model.controller import DocListController
|
||||
import frappe.defaults
|
||||
|
||||
class DocType(DocListController):
|
||||
def validate(self):
|
||||
@@ -15,11 +15,11 @@ class DocType(DocListController):
|
||||
|
||||
if not self.doclist.get({"parentfield": "valid_for_territories"}):
|
||||
# if no territory, set default territory
|
||||
if webnotes.defaults.get_user_default("territory"):
|
||||
if frappe.defaults.get_user_default("territory"):
|
||||
self.doclist.append({
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": webnotes.defaults.get_user_default("territory")
|
||||
"territory": frappe.defaults.get_user_default("territory")
|
||||
})
|
||||
else:
|
||||
# at least one territory
|
||||
@@ -31,14 +31,14 @@ class DocType(DocListController):
|
||||
|
||||
def set_default_if_missing(self):
|
||||
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)
|
||||
if not frappe.conn.get_value("Selling Settings", None, "selling_price_list"):
|
||||
frappe.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.doc.name)
|
||||
|
||||
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)
|
||||
if not frappe.conn.get_value("Buying Settings", None, "buying_price_list"):
|
||||
frappe.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,
|
||||
frappe.conn.sql("""update `tabItem Price` set currency=%s,
|
||||
buying=%s, selling=%s, modified=NOW() where price_list=%s""",
|
||||
(self.doc.currency, cint(self.doc.buying), cint(self.doc.selling), self.doc.name))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
# test_ignore = ["Item"]
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ cur_frm.cscript.other_fname = "other_charges";
|
||||
{% include 'utilities/doctype/sms_control/sms_control.js' %}
|
||||
{% include 'accounts/doctype/sales_invoice/pos.js' %}
|
||||
|
||||
wn.provide("erpnext.stock");
|
||||
frappe.provide("erpnext.stock");
|
||||
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function() {
|
||||
this._super();
|
||||
|
||||
if(this.frm.doc.docstatus == 1) {
|
||||
if(!this.frm.doc.__billing_complete) {
|
||||
cur_frm.add_custom_button(wn._('Make Purchase Invoice'),
|
||||
cur_frm.add_custom_button(frappe._('Make Purchase Invoice'),
|
||||
this.make_purchase_invoice);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||
@@ -25,9 +25,9 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
} else {
|
||||
cur_frm.add_custom_button(wn._(wn._('From Purchase Order')),
|
||||
cur_frm.add_custom_button(frappe._(frappe._('From Purchase Order')),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||
source_doctype: "Purchase Order",
|
||||
get_query_filters: {
|
||||
@@ -41,30 +41,30 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
});
|
||||
}
|
||||
|
||||
if(wn.boot.control_panel.country == 'India') {
|
||||
if(frappe.boot.control_panel.country == 'India') {
|
||||
unhide_field(['challan_no', 'challan_date']);
|
||||
}
|
||||
},
|
||||
|
||||
received_qty: function(doc, cdt, cdn) {
|
||||
var item = wn.model.get_doc(cdt, cdn);
|
||||
wn.model.round_floats_in(item, ["qty", "received_qty"]);
|
||||
var item = frappe.model.get_doc(cdt, cdn);
|
||||
frappe.model.round_floats_in(item, ["qty", "received_qty"]);
|
||||
|
||||
item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
|
||||
this.qty(doc, cdt, cdn);
|
||||
},
|
||||
|
||||
qty: function(doc, cdt, cdn) {
|
||||
var item = wn.model.get_doc(cdt, cdn);
|
||||
wn.model.round_floats_in(item, ["qty", "received_qty"]);
|
||||
var item = frappe.model.get_doc(cdt, cdn);
|
||||
frappe.model.round_floats_in(item, ["qty", "received_qty"]);
|
||||
|
||||
if(!(item.received_qty || item.rejected_qty) && item.qty) {
|
||||
item.received_qty = item.qty;
|
||||
}
|
||||
|
||||
if(item.qty > item.received_qty) {
|
||||
msgprint(wn._("Error") + ": " + wn._(wn.meta.get_label(item.doctype, "qty", item.name))
|
||||
+ " > " + wn._(wn.meta.get_label(item.doctype, "received_qty", item.name)));
|
||||
msgprint(frappe._("Error") + ": " + frappe._(frappe.meta.get_label(item.doctype, "qty", item.name))
|
||||
+ " > " + frappe._(frappe.meta.get_label(item.doctype, "received_qty", item.name)));
|
||||
item.qty = item.rejected_qty = 0.0;
|
||||
} else {
|
||||
item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
|
||||
@@ -74,13 +74,13 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
},
|
||||
|
||||
rejected_qty: function(doc, cdt, cdn) {
|
||||
var item = wn.model.get_doc(cdt, cdn);
|
||||
wn.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
|
||||
var item = frappe.model.get_doc(cdt, cdn);
|
||||
frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
|
||||
|
||||
if(item.rejected_qty > item.received_qty) {
|
||||
msgprint(wn._("Error") + ": " +
|
||||
wn._(wn.meta.get_label(item.doctype, "rejected_qty", item.name))
|
||||
+ " > " + wn._(wn.meta.get_label(item.doctype, "received_qty", item.name)));
|
||||
msgprint(frappe._("Error") + ": " +
|
||||
frappe._(frappe.meta.get_label(item.doctype, "rejected_qty", item.name))
|
||||
+ " > " + frappe._(frappe.meta.get_label(item.doctype, "received_qty", item.name)));
|
||||
item.qty = item.rejected_qty = 0.0;
|
||||
} else {
|
||||
item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
|
||||
@@ -90,7 +90,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
},
|
||||
|
||||
make_purchase_invoice: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
@@ -118,7 +118,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.new_contact = function() {
|
||||
tn = wn.model.make_new_doc_and_get_name('Contact');
|
||||
tn = frappe.model.make_new_doc_and_get_name('Contact');
|
||||
locals['Contact'][tn].is_supplier = 1;
|
||||
if(doc.supplier)
|
||||
locals['Contact'][tn].supplier = doc.supplier;
|
||||
@@ -141,7 +141,7 @@ cur_frm.fields_dict['purchase_receipt_details'].grid.get_field('batch_no').get_q
|
||||
}
|
||||
}
|
||||
else
|
||||
msgprint(wn._("Please enter Item Code."));
|
||||
msgprint(frappe._("Please enter Item Code."));
|
||||
}
|
||||
|
||||
cur_frm.cscript.select_print_heading = function(doc, cdt, cdn) {
|
||||
@@ -168,6 +168,6 @@ cur_frm.fields_dict.purchase_receipt_details.grid.get_field("qa_no").get_query =
|
||||
}
|
||||
|
||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
if(cint(wn.boot.notification_settings.purchase_receipt))
|
||||
cur_frm.email_doc(wn.boot.notification_settings.purchase_receipt_message);
|
||||
if(cint(frappe.boot.notification_settings.purchase_receipt))
|
||||
cur_frm.email_doc(frappe.boot.notification_settings.purchase_receipt_message);
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cstr, flt, cint
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
import webnotes.defaults
|
||||
from frappe.utils import cstr, flt, cint
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
import frappe.defaults
|
||||
from erpnext.stock.utils import update_bin
|
||||
|
||||
from erpnext.controllers.buying_controller import BuyingController
|
||||
@@ -32,7 +32,7 @@ class DocType(BuyingController):
|
||||
}]
|
||||
|
||||
def onload(self):
|
||||
billed_qty = webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item`
|
||||
billed_qty = frappe.conn.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item`
|
||||
where purchase_receipt=%s""", self.doc.name)
|
||||
if billed_qty:
|
||||
total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "purchase_receipt_details"})))
|
||||
@@ -72,7 +72,7 @@ class DocType(BuyingController):
|
||||
if flt(d.rejected_qty) and not d.rejected_warehouse:
|
||||
d.rejected_warehouse = self.doc.rejected_warehouse
|
||||
if not d.rejected_warehouse:
|
||||
webnotes.throw(_("Rejected Warehouse is mandatory against regected item"))
|
||||
frappe.throw(_("Rejected Warehouse is mandatory against regected item"))
|
||||
|
||||
# validate accepted and rejected qty
|
||||
def validate_accepted_rejected_qty(self):
|
||||
@@ -96,12 +96,12 @@ class DocType(BuyingController):
|
||||
def validate_challan_no(self):
|
||||
"Validate if same challan no exists for same supplier in a submitted purchase receipt"
|
||||
if self.doc.challan_no:
|
||||
exists = webnotes.conn.sql("""
|
||||
exists = frappe.conn.sql("""
|
||||
SELECT name FROM `tabPurchase Receipt`
|
||||
WHERE name!=%s AND supplier=%s AND challan_no=%s
|
||||
AND docstatus=1""", (self.doc.name, self.doc.supplier, self.doc.challan_no))
|
||||
if exists:
|
||||
webnotes.msgprint("Another Purchase Receipt using the same Challan No. already exists.\
|
||||
frappe.msgprint("Another Purchase Receipt using the same Challan No. already exists.\
|
||||
Please enter a valid Challan No.", raise_exception=1)
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
@@ -117,7 +117,7 @@ class DocType(BuyingController):
|
||||
}
|
||||
})
|
||||
|
||||
if cint(webnotes.defaults.get_global_default('maintain_same_rate')):
|
||||
if cint(frappe.defaults.get_global_default('maintain_same_rate')):
|
||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||
"Purchase Order Item": {
|
||||
"ref_dn_field": "prevdoc_detail_docname",
|
||||
@@ -128,7 +128,7 @@ class DocType(BuyingController):
|
||||
|
||||
|
||||
def po_required(self):
|
||||
if webnotes.conn.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
if frappe.conn.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
for d in getlist(self.doclist,'purchase_receipt_details'):
|
||||
if not d.prevdoc_docname:
|
||||
msgprint("Purchse Order No. required against item %s"%d.item_code)
|
||||
@@ -171,7 +171,7 @@ class DocType(BuyingController):
|
||||
po_qty, ordered_warehouse = self.get_po_qty_and_warehouse(d.prevdoc_detail_docname)
|
||||
|
||||
if not ordered_warehouse:
|
||||
webnotes.throw(_("Warehouse is missing in Purchase Order"))
|
||||
frappe.throw(_("Warehouse is missing in Purchase Order"))
|
||||
|
||||
if already_received_qty + d.qty > po_qty:
|
||||
ordered_qty = - (po_qty - already_received_qty) * flt(d.conversion_factor)
|
||||
@@ -186,14 +186,14 @@ class DocType(BuyingController):
|
||||
})
|
||||
|
||||
def get_already_received_qty(self, po, po_detail):
|
||||
qty = webnotes.conn.sql("""select sum(qty) from `tabPurchase Receipt Item`
|
||||
qty = frappe.conn.sql("""select sum(qty) from `tabPurchase Receipt Item`
|
||||
where prevdoc_detail_docname = %s and docstatus = 1
|
||||
and prevdoc_doctype='Purchase Order' and prevdoc_docname=%s
|
||||
and parent != %s""", (po_detail, po, self.doc.name))
|
||||
return qty and flt(qty[0][0]) or 0.0
|
||||
|
||||
def get_po_qty_and_warehouse(self, po_detail):
|
||||
po_qty, po_warehouse = webnotes.conn.get_value("Purchase Order Item", po_detail,
|
||||
po_qty, po_warehouse = frappe.conn.get_value("Purchase Order Item", po_detail,
|
||||
["qty", "warehouse"])
|
||||
return po_qty, po_warehouse
|
||||
|
||||
@@ -210,7 +210,7 @@ class DocType(BuyingController):
|
||||
|
||||
def validate_inspection(self):
|
||||
for d in getlist(self.doclist, 'purchase_receipt_details'): #Enter inspection date for all items that require inspection
|
||||
ins_reqd = webnotes.conn.sql("select inspection_required from `tabItem` where name = %s",
|
||||
ins_reqd = frappe.conn.sql("select inspection_required from `tabItem` where name = %s",
|
||||
(d.item_code,), as_dict = 1)
|
||||
ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No'
|
||||
if ins_reqd == 'Yes' and not d.qa_no:
|
||||
@@ -226,13 +226,13 @@ class DocType(BuyingController):
|
||||
|
||||
# on submit
|
||||
def on_submit(self):
|
||||
purchase_controller = webnotes.get_obj("Purchase Common")
|
||||
purchase_controller = frappe.get_obj("Purchase Common")
|
||||
|
||||
# Check for Approving Authority
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total)
|
||||
|
||||
# Set status as Submitted
|
||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
||||
frappe.conn.set(self.doc, 'status', 'Submitted')
|
||||
|
||||
self.update_prevdoc_status()
|
||||
|
||||
@@ -248,7 +248,7 @@ class DocType(BuyingController):
|
||||
self.make_gl_entries()
|
||||
|
||||
def check_next_docstatus(self):
|
||||
submit_rv = webnotes.conn.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_receipt = '%s' and t1.docstatus = 1" % (self.doc.name))
|
||||
submit_rv = frappe.conn.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_receipt = '%s' and t1.docstatus = 1" % (self.doc.name))
|
||||
if submit_rv:
|
||||
msgprint("Purchase Invoice : " + cstr(self.submit_rv[0][0]) + " has already been submitted !")
|
||||
raise Exception , "Validation Error."
|
||||
@@ -261,13 +261,13 @@ class DocType(BuyingController):
|
||||
# Check if Purchase Invoice has been submitted against current Purchase Order
|
||||
# pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Invoice', docname = self.doc.name, detail_doctype = 'Purchase Invoice Item')
|
||||
|
||||
submitted = webnotes.conn.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_receipt = '%s' and t1.docstatus = 1" % self.doc.name)
|
||||
submitted = frappe.conn.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_receipt = '%s' and t1.docstatus = 1" % self.doc.name)
|
||||
if submitted:
|
||||
msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
|
||||
raise Exception
|
||||
|
||||
|
||||
webnotes.conn.set(self.doc,'status','Cancelled')
|
||||
frappe.conn.set(self.doc,'status','Cancelled')
|
||||
|
||||
self.update_ordered_qty()
|
||||
|
||||
@@ -281,7 +281,7 @@ class DocType(BuyingController):
|
||||
def get_current_stock(self):
|
||||
for d in getlist(self.doclist, 'pr_raw_material_details'):
|
||||
if self.doc.supplier_warehouse:
|
||||
bin = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1)
|
||||
bin = frappe.conn.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1)
|
||||
d.current_stock = bin and flt(bin[0]['actual_qty']) or 0
|
||||
|
||||
def get_rate(self,arg):
|
||||
@@ -294,12 +294,12 @@ class DocType(BuyingController):
|
||||
return gl_entries
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_purchase_invoice(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = webnotes.bean(target)
|
||||
bean = frappe.bean(target)
|
||||
bean.run_method("set_missing_values")
|
||||
|
||||
doclist = get_mapped_doclist("Purchase Receipt", source_name, {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import webnotes
|
||||
import webnotes.defaults
|
||||
from webnotes.utils import cint
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint
|
||||
|
||||
class TestPurchaseReceipt(unittest.TestCase):
|
||||
def test_make_purchase_invoice(self):
|
||||
@@ -14,12 +14,12 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
set_perpetual_inventory(0)
|
||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||
|
||||
pr = webnotes.bean(copy=test_records[0]).insert()
|
||||
pr = frappe.bean(copy=test_records[0]).insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_purchase_invoice,
|
||||
self.assertRaises(frappe.ValidationError, make_purchase_invoice,
|
||||
pr.doc.name)
|
||||
|
||||
pr = webnotes.bean("Purchase Receipt", pr.doc.name)
|
||||
pr = frappe.bean("Purchase Receipt", pr.doc.name)
|
||||
pr.submit()
|
||||
pi = make_purchase_invoice(pr.doc.name)
|
||||
|
||||
@@ -28,23 +28,23 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
|
||||
# modify rate
|
||||
pi[1].rate = 200
|
||||
self.assertRaises(webnotes.ValidationError, webnotes.bean(pi).submit)
|
||||
self.assertRaises(frappe.ValidationError, frappe.bean(pi).submit)
|
||||
|
||||
def test_purchase_receipt_no_gl_entry(self):
|
||||
self._clear_stock_account_balance()
|
||||
set_perpetual_inventory(0)
|
||||
pr = webnotes.bean(copy=test_records[0])
|
||||
pr = frappe.bean(copy=test_records[0])
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
|
||||
stock_value, stock_value_difference = webnotes.conn.get_value("Stock Ledger Entry",
|
||||
stock_value, stock_value_difference = frappe.conn.get_value("Stock Ledger Entry",
|
||||
{"voucher_type": "Purchase Receipt", "voucher_no": pr.doc.name,
|
||||
"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"},
|
||||
["stock_value", "stock_value_difference"])
|
||||
self.assertEqual(stock_value, 375)
|
||||
self.assertEqual(stock_value_difference, 375)
|
||||
|
||||
bin_stock_value = webnotes.conn.get_value("Bin", {"item_code": "_Test Item",
|
||||
bin_stock_value = frappe.conn.get_value("Bin", {"item_code": "_Test Item",
|
||||
"warehouse": "_Test Warehouse - _TC"}, "stock_value")
|
||||
self.assertEqual(bin_stock_value, 375)
|
||||
|
||||
@@ -54,9 +54,9 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
self._clear_stock_account_balance()
|
||||
|
||||
set_perpetual_inventory()
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pr = webnotes.bean(copy=test_records[0])
|
||||
pr = frappe.bean(copy=test_records[0])
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
|
||||
@@ -64,9 +64,9 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
|
||||
self.assertTrue(gl_entries)
|
||||
|
||||
stock_in_hand_account = webnotes.conn.get_value("Account",
|
||||
stock_in_hand_account = frappe.conn.get_value("Account",
|
||||
{"master_name": pr.doclist[1].warehouse})
|
||||
fixed_asset_account = webnotes.conn.get_value("Account",
|
||||
fixed_asset_account = frappe.conn.get_value("Account",
|
||||
{"master_name": pr.doclist[2].warehouse})
|
||||
|
||||
expected_values = {
|
||||
@@ -85,12 +85,12 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
def _clear_stock_account_balance(self):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
||||
frappe.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
frappe.conn.sql("""delete from `tabBin`""")
|
||||
frappe.conn.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
def test_subcontracting(self):
|
||||
pr = webnotes.bean(copy=test_records[1])
|
||||
pr = frappe.bean(copy=test_records[1])
|
||||
pr.run_method("calculate_taxes_and_totals")
|
||||
pr.insert()
|
||||
|
||||
@@ -98,14 +98,14 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
self.assertEquals(len(pr.doclist.get({"parentfield": "pr_raw_material_details"})), 2)
|
||||
|
||||
def test_serial_no_supplier(self):
|
||||
pr = webnotes.bean(copy=test_records[0])
|
||||
pr = frappe.bean(copy=test_records[0])
|
||||
pr.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
pr.doclist[1].qty = 1
|
||||
pr.doclist[1].received_qty = 1
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", pr.doclist[1].serial_no,
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", pr.doclist[1].serial_no,
|
||||
"supplier"), pr.doc.supplier)
|
||||
|
||||
return pr
|
||||
@@ -114,16 +114,16 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
pr = self.test_serial_no_supplier()
|
||||
pr.cancel()
|
||||
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", pr.doclist[1].serial_no,
|
||||
self.assertFalse(frappe.conn.get_value("Serial No", pr.doclist[1].serial_no,
|
||||
"warehouse"))
|
||||
|
||||
def get_gl_entries(voucher_type, voucher_no):
|
||||
return webnotes.conn.sql("""select account, debit, credit
|
||||
return frappe.conn.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type=%s and voucher_no=%s
|
||||
order by account desc""", (voucher_type, voucher_no), as_dict=1)
|
||||
|
||||
def set_perpetual_inventory(enable=1):
|
||||
accounts_settings = webnotes.bean("Accounts Settings")
|
||||
accounts_settings = frappe.bean("Accounts Settings")
|
||||
accounts_settings.doc.auto_accounting_for_stock = enable
|
||||
accounts_settings.save()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cint, getdate, cstr, flt, add_days
|
||||
from frappe.utils import cint, getdate, cstr, flt, add_days
|
||||
import datetime
|
||||
from webnotes import _, ValidationError
|
||||
from frappe import _, ValidationError
|
||||
|
||||
from erpnext.controllers.stock_controller import StockController
|
||||
|
||||
@@ -29,7 +29,7 @@ class DocType(StockController):
|
||||
|
||||
def validate(self):
|
||||
if self.doc.fields.get("__islocal") and self.doc.warehouse:
|
||||
webnotes.throw(_("New Serial No cannot have Warehouse. Warehouse must be \
|
||||
frappe.throw(_("New Serial No cannot have Warehouse. Warehouse must be \
|
||||
set by Stock Entry or Purchase Receipt"), SerialNoCannotCreateDirectError)
|
||||
|
||||
self.validate_warranty_status()
|
||||
@@ -40,33 +40,33 @@ class DocType(StockController):
|
||||
|
||||
def validate_amc_status(self):
|
||||
if (self.doc.maintenance_status == 'Out of AMC' and self.doc.amc_expiry_date and getdate(self.doc.amc_expiry_date) >= datetime.date.today()) or (self.doc.maintenance_status == 'Under AMC' and (not self.doc.amc_expiry_date or getdate(self.doc.amc_expiry_date) < datetime.date.today())):
|
||||
webnotes.throw(self.doc.name + ": " +
|
||||
frappe.throw(self.doc.name + ": " +
|
||||
_("AMC expiry date and maintenance status mismatched"))
|
||||
|
||||
def validate_warranty_status(self):
|
||||
if (self.doc.maintenance_status == 'Out of Warranty' and self.doc.warranty_expiry_date and getdate(self.doc.warranty_expiry_date) >= datetime.date.today()) or (self.doc.maintenance_status == 'Under Warranty' and (not self.doc.warranty_expiry_date or getdate(self.doc.warranty_expiry_date) < datetime.date.today())):
|
||||
webnotes.throw(self.doc.name + ": " +
|
||||
frappe.throw(self.doc.name + ": " +
|
||||
_("Warranty expiry date and maintenance status mismatched"))
|
||||
|
||||
|
||||
def validate_warehouse(self):
|
||||
if not self.doc.fields.get("__islocal"):
|
||||
item_code, warehouse = webnotes.conn.get_value("Serial No",
|
||||
item_code, warehouse = frappe.conn.get_value("Serial No",
|
||||
self.doc.name, ["item_code", "warehouse"])
|
||||
if item_code != self.doc.item_code:
|
||||
webnotes.throw(_("Item Code cannot be changed for Serial No."),
|
||||
frappe.throw(_("Item Code cannot be changed for Serial No."),
|
||||
SerialNoCannotCannotChangeError)
|
||||
if not self.via_stock_ledger and warehouse != self.doc.warehouse:
|
||||
webnotes.throw(_("Warehouse cannot be changed for Serial No."),
|
||||
frappe.throw(_("Warehouse cannot be changed for Serial No."),
|
||||
SerialNoCannotCannotChangeError)
|
||||
|
||||
def validate_item(self):
|
||||
"""
|
||||
Validate whether serial no is required for this item
|
||||
"""
|
||||
item = webnotes.doc("Item", self.doc.item_code)
|
||||
item = frappe.doc("Item", self.doc.item_code)
|
||||
if item.has_serial_no!="Yes":
|
||||
webnotes.throw(_("Item must have 'Has Serial No' as 'Yes'") + ": " + self.doc.item_code)
|
||||
frappe.throw(_("Item must have 'Has Serial No' as 'Yes'") + ": " + self.doc.item_code)
|
||||
|
||||
self.doc.item_group = item.item_group
|
||||
self.doc.description = item.description
|
||||
@@ -77,7 +77,7 @@ class DocType(StockController):
|
||||
def set_status(self, last_sle):
|
||||
if last_sle:
|
||||
if last_sle.voucher_type == "Stock Entry":
|
||||
document_type = webnotes.conn.get_value("Stock Entry", last_sle.voucher_no,
|
||||
document_type = frappe.conn.get_value("Stock Entry", last_sle.voucher_no,
|
||||
"purpose")
|
||||
else:
|
||||
document_type = last_sle.voucher_type
|
||||
@@ -106,7 +106,7 @@ class DocType(StockController):
|
||||
self.doc.purchase_rate = purchase_sle.incoming_rate
|
||||
if purchase_sle.voucher_type == "Purchase Receipt":
|
||||
self.doc.supplier, self.doc.supplier_name = \
|
||||
webnotes.conn.get_value("Purchase Receipt", purchase_sle.voucher_no,
|
||||
frappe.conn.get_value("Purchase Receipt", purchase_sle.voucher_no,
|
||||
["supplier", "supplier_name"])
|
||||
else:
|
||||
for fieldname in ("purchase_document_type", "purchase_document_no",
|
||||
@@ -120,7 +120,7 @@ class DocType(StockController):
|
||||
self.doc.delivery_date = delivery_sle.posting_date
|
||||
self.doc.delivery_time = delivery_sle.posting_time
|
||||
self.doc.customer, self.doc.customer_name = \
|
||||
webnotes.conn.get_value(delivery_sle.voucher_type, delivery_sle.voucher_no,
|
||||
frappe.conn.get_value(delivery_sle.voucher_type, delivery_sle.voucher_no,
|
||||
["customer", "customer_name"])
|
||||
if self.doc.warranty_period:
|
||||
self.doc.warranty_expiry_date = add_days(cstr(delivery_sle.posting_date),
|
||||
@@ -148,7 +148,7 @@ class DocType(StockController):
|
||||
|
||||
def get_stock_ledger_entries(self):
|
||||
sle_dict = {}
|
||||
for sle in webnotes.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
for sle in frappe.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
where serial_no like %s and item_code=%s and ifnull(is_cancelled, 'No')='No'
|
||||
order by posting_date desc, posting_time desc, name desc""",
|
||||
("%%%s%%" % self.doc.name, self.doc.item_code), as_dict=1):
|
||||
@@ -162,25 +162,25 @@ class DocType(StockController):
|
||||
|
||||
def on_trash(self):
|
||||
if self.doc.status == 'Delivered':
|
||||
webnotes.throw(_("Delivered Serial No ") + self.doc.name + _(" can not be deleted"))
|
||||
frappe.throw(_("Delivered Serial No ") + self.doc.name + _(" can not be deleted"))
|
||||
if self.doc.warehouse:
|
||||
webnotes.throw(_("Cannot delete Serial No in warehouse. \
|
||||
frappe.throw(_("Cannot delete Serial No in warehouse. \
|
||||
First remove from warehouse, then delete.") + ": " + self.doc.name)
|
||||
|
||||
def before_rename(self, old, new, merge=False):
|
||||
if merge:
|
||||
webnotes.throw(_("Sorry, Serial Nos cannot be merged"))
|
||||
frappe.throw(_("Sorry, Serial Nos cannot be merged"))
|
||||
|
||||
def after_rename(self, old, new, merge=False):
|
||||
"""rename serial_no text fields"""
|
||||
for dt in webnotes.conn.sql("""select parent from tabDocField
|
||||
for dt in frappe.conn.sql("""select parent from tabDocField
|
||||
where fieldname='serial_no' and fieldtype='Text'"""):
|
||||
|
||||
for item in webnotes.conn.sql("""select name, serial_no from `tab%s`
|
||||
for item in frappe.conn.sql("""select name, serial_no from `tab%s`
|
||||
where serial_no like '%%%s%%'""" % (dt[0], old)):
|
||||
|
||||
serial_nos = map(lambda i: i==old and new or i, item[1].split('\n'))
|
||||
webnotes.conn.sql("""update `tab%s` set serial_no = %s
|
||||
frappe.conn.sql("""update `tab%s` set serial_no = %s
|
||||
where name=%s""" % (dt[0], '%s', '%s'),
|
||||
('\n'.join(serial_nos), item[0]))
|
||||
|
||||
@@ -202,65 +202,65 @@ def process_serial_no(sle):
|
||||
def validate_serial_no(sle, item_det):
|
||||
if item_det.has_serial_no=="No":
|
||||
if sle.serial_no:
|
||||
webnotes.throw(_("Serial Number should be blank for Non Serialized Item" + ": "
|
||||
frappe.throw(_("Serial Number should be blank for Non Serialized Item" + ": "
|
||||
+ sle.item_code), SerialNoNotRequiredError)
|
||||
else:
|
||||
if sle.serial_no:
|
||||
serial_nos = get_serial_nos(sle.serial_no)
|
||||
if cint(sle.actual_qty) != flt(sle.actual_qty):
|
||||
webnotes.throw(_("Serial No qty cannot be a fraction") + \
|
||||
frappe.throw(_("Serial No qty cannot be a fraction") + \
|
||||
(": %s (%s)" % (sle.item_code, sle.actual_qty)))
|
||||
if len(serial_nos) and len(serial_nos) != abs(cint(sle.actual_qty)):
|
||||
webnotes.throw(_("Serial Nos do not match with qty") + \
|
||||
frappe.throw(_("Serial Nos do not match with qty") + \
|
||||
(": %s (%s)" % (sle.item_code, sle.actual_qty)), SerialNoQtyError)
|
||||
|
||||
if len(serial_nos) != len(set(serial_nos)):
|
||||
webnotes.throw(_("Duplicate Serial No entered against item") +
|
||||
frappe.throw(_("Duplicate Serial No entered against item") +
|
||||
(": %s" % sle.item_code), SerialNoDuplicateError)
|
||||
|
||||
for serial_no in serial_nos:
|
||||
if webnotes.conn.exists("Serial No", serial_no):
|
||||
sr = webnotes.bean("Serial No", serial_no)
|
||||
if frappe.conn.exists("Serial No", serial_no):
|
||||
sr = frappe.bean("Serial No", serial_no)
|
||||
|
||||
if sr.doc.item_code!=sle.item_code:
|
||||
webnotes.throw(_("Serial No does not belong to Item") +
|
||||
frappe.throw(_("Serial No does not belong to Item") +
|
||||
(": %s (%s)" % (sle.item_code, serial_no)), SerialNoItemError)
|
||||
|
||||
if sr.doc.warehouse and sle.actual_qty > 0:
|
||||
webnotes.throw(_("Same Serial No") + ": " + sr.doc.name +
|
||||
frappe.throw(_("Same Serial No") + ": " + sr.doc.name +
|
||||
_(" can not be received twice"), SerialNoDuplicateError)
|
||||
|
||||
if sle.actual_qty < 0:
|
||||
if sr.doc.warehouse!=sle.warehouse:
|
||||
webnotes.throw(_("Serial No") + ": " + serial_no +
|
||||
frappe.throw(_("Serial No") + ": " + serial_no +
|
||||
_(" does not belong to Warehouse") + ": " + sle.warehouse,
|
||||
SerialNoWarehouseError)
|
||||
|
||||
if sle.voucher_type in ("Delivery Note", "Sales Invoice") \
|
||||
and sr.doc.status != "Available":
|
||||
webnotes.throw(_("Serial No status must be 'Available' to Deliver")
|
||||
frappe.throw(_("Serial No status must be 'Available' to Deliver")
|
||||
+ ": " + serial_no, SerialNoStatusError)
|
||||
elif sle.actual_qty < 0:
|
||||
# transfer out
|
||||
webnotes.throw(_("Serial No must exist to transfer out.") + \
|
||||
frappe.throw(_("Serial No must exist to transfer out.") + \
|
||||
": " + serial_no, SerialNoNotExistsError)
|
||||
elif sle.actual_qty < 0 or not item_det.serial_no_series:
|
||||
webnotes.throw(_("Serial Number Required for Serialized Item" + ": "
|
||||
frappe.throw(_("Serial Number Required for Serialized Item" + ": "
|
||||
+ sle.item_code), SerialNoRequiredError)
|
||||
|
||||
def update_serial_nos(sle, item_det):
|
||||
if sle.is_cancelled == "No" and not sle.serial_no and sle.actual_qty > 0 and item_det.serial_no_series:
|
||||
from webnotes.model.doc import make_autoname
|
||||
from frappe.model.doc import make_autoname
|
||||
serial_nos = []
|
||||
for i in xrange(cint(sle.actual_qty)):
|
||||
serial_nos.append(make_autoname(item_det.serial_no_series))
|
||||
webnotes.conn.set(sle, "serial_no", "\n".join(serial_nos))
|
||||
frappe.conn.set(sle, "serial_no", "\n".join(serial_nos))
|
||||
|
||||
if sle.serial_no:
|
||||
serial_nos = get_serial_nos(sle.serial_no)
|
||||
for serial_no in serial_nos:
|
||||
if webnotes.conn.exists("Serial No", serial_no):
|
||||
sr = webnotes.bean("Serial No", serial_no)
|
||||
if frappe.conn.exists("Serial No", serial_no):
|
||||
sr = frappe.bean("Serial No", serial_no)
|
||||
sr.make_controller().via_stock_ledger = True
|
||||
sr.doc.warehouse = sle.warehouse if sle.actual_qty > 0 else None
|
||||
sr.save()
|
||||
@@ -268,7 +268,7 @@ def update_serial_nos(sle, item_det):
|
||||
make_serial_no(serial_no, sle)
|
||||
|
||||
def get_item_details(item_code):
|
||||
return webnotes.conn.sql("""select name, has_batch_no, docstatus,
|
||||
return frappe.conn.sql("""select name, has_batch_no, docstatus,
|
||||
is_stock_item, has_serial_no, serial_no_series
|
||||
from tabItem where name=%s""", item_code, as_dict=True)[0]
|
||||
|
||||
@@ -277,7 +277,7 @@ def get_serial_nos(serial_no):
|
||||
if s.strip()]
|
||||
|
||||
def make_serial_no(serial_no, sle):
|
||||
sr = webnotes.new_bean("Serial No")
|
||||
sr = frappe.new_bean("Serial No")
|
||||
sr.doc.serial_no = serial_no
|
||||
sr.doc.item_code = sle.item_code
|
||||
sr.make_controller().via_stock_ledger = True
|
||||
@@ -285,11 +285,11 @@ def make_serial_no(serial_no, sle):
|
||||
sr.doc.warehouse = sle.warehouse
|
||||
sr.doc.status = "Available"
|
||||
sr.save()
|
||||
webnotes.msgprint(_("Serial No created") + ": " + sr.doc.name)
|
||||
frappe.msgprint(_("Serial No created") + ": " + sr.doc.name)
|
||||
return sr.doc.name
|
||||
|
||||
def update_serial_nos_after_submit(controller, parentfield):
|
||||
stock_ledger_entries = webnotes.conn.sql("""select voucher_detail_no, serial_no
|
||||
stock_ledger_entries = frappe.conn.sql("""select voucher_detail_no, serial_no
|
||||
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
|
||||
(controller.doc.doctype, controller.doc.name), as_dict=True)
|
||||
|
||||
@@ -304,4 +304,4 @@ def update_serial_nos_after_submit(controller, parentfield):
|
||||
|
||||
if d.serial_no != serial_no:
|
||||
d.serial_no = serial_no
|
||||
webnotes.conn.set_value(d.doctype, d.name, "serial_no", serial_no)
|
||||
frappe.conn.set_value(d.doctype, d.name, "serial_no", serial_no)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes, unittest
|
||||
import frappe, unittest
|
||||
|
||||
test_dependencies = ["Item"]
|
||||
test_records = []
|
||||
@@ -14,7 +14,7 @@ from erpnext.stock.doctype.serial_no.serial_no import *
|
||||
|
||||
class TestSerialNo(unittest.TestCase):
|
||||
def test_cannot_create_direct(self):
|
||||
sr = webnotes.new_bean("Serial No")
|
||||
sr = frappe.new_bean("Serial No")
|
||||
sr.doc.item_code = "_Test Serialized Item"
|
||||
sr.doc.warehouse = "_Test Warehouse - _TC"
|
||||
sr.doc.serial_no = "_TCSER0001"
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
cur_frm.cscript.tname = "Stock Entry Detail";
|
||||
cur_frm.cscript.fname = "mtn_details";
|
||||
|
||||
wn.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
wn.provide("erpnext.stock");
|
||||
frappe.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
frappe.provide("erpnext.stock");
|
||||
|
||||
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
setup: function() {
|
||||
@@ -41,7 +41,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
}
|
||||
};
|
||||
|
||||
if(cint(wn.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
if(cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
|
||||
this.frm.fields_dict.mtn_details.grid.get_field('expense_account').get_query =
|
||||
function() {
|
||||
@@ -68,12 +68,12 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
this.show_general_ledger();
|
||||
|
||||
if(this.frm.doc.docstatus === 1 &&
|
||||
wn.boot.profile.can_create.indexOf("Journal Voucher")!==-1) {
|
||||
frappe.boot.profile.can_create.indexOf("Journal Voucher")!==-1) {
|
||||
if(this.frm.doc.purpose === "Sales Return") {
|
||||
this.frm.add_custom_button(wn._("Make Credit Note"), function() { me.make_return_jv(); });
|
||||
this.frm.add_custom_button(frappe._("Make Credit Note"), function() { me.make_return_jv(); });
|
||||
this.add_excise_button();
|
||||
} else if(this.frm.doc.purpose === "Purchase Return") {
|
||||
this.frm.add_custom_button(wn._("Make Debit Note"), function() { me.make_return_jv(); });
|
||||
this.frm.add_custom_button(frappe._("Make Debit Note"), function() { me.make_return_jv(); });
|
||||
this.add_excise_button();
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
set_default_account: function() {
|
||||
var me = this;
|
||||
|
||||
if(cint(wn.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
if(cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
var account_for = "stock_adjustment_account";
|
||||
|
||||
if (this.frm.doc.purpose == "Purchase Return")
|
||||
@@ -118,7 +118,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
// Clear Production Order record from locals, because it is updated via Stock Entry
|
||||
if(this.frm.doc.production_order &&
|
||||
this.frm.doc.purpose == "Manufacture/Repack") {
|
||||
wn.model.remove_from_locals("Production Order",
|
||||
frappe.model.remove_from_locals("Production Order",
|
||||
this.frm.doc.production_order);
|
||||
}
|
||||
},
|
||||
@@ -166,11 +166,11 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
if(this.frm.doc.purpose === "Sales Return") {
|
||||
if(this.frm.doc.delivery_note_no && this.frm.doc.sales_invoice_no) {
|
||||
// both specified
|
||||
msgprint(wn._("You can not enter both Delivery Note No and Sales Invoice No. Please enter any one."));
|
||||
msgprint(frappe._("You can not enter both Delivery Note No and Sales Invoice No. Please enter any one."));
|
||||
|
||||
} else if(!(this.frm.doc.delivery_note_no || this.frm.doc.sales_invoice_no)) {
|
||||
// none specified
|
||||
msgprint(wn._("Please enter Delivery Note No or Sales Invoice No to proceed"));
|
||||
msgprint(frappe._("Please enter Delivery Note No or Sales Invoice No to proceed"));
|
||||
|
||||
} else if(this.frm.doc.delivery_note_no) {
|
||||
return {doctype: "Delivery Note", docname: this.frm.doc.delivery_note_no};
|
||||
@@ -185,16 +185,16 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
|
||||
} else {
|
||||
// not specified
|
||||
msgprint(wn._("Please enter Purchase Receipt No to proceed"));
|
||||
msgprint(frappe._("Please enter Purchase Receipt No to proceed"));
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
add_excise_button: function() {
|
||||
if(wn.boot.control_panel.country === "India")
|
||||
this.frm.add_custom_button(wn._("Make Excise Invoice"), function() {
|
||||
var excise = wn.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
if(frappe.boot.control_panel.country === "India")
|
||||
this.frm.add_custom_button(frappe._("Make Excise Invoice"), function() {
|
||||
var excise = frappe.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
excise = locals['Journal Voucher'][excise];
|
||||
excise.voucher_type = 'Excise Voucher';
|
||||
loaddoc('Journal Voucher', excise.name);
|
||||
@@ -210,11 +210,11 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
var jv_name = wn.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
var jv_name = frappe.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
var jv = locals["Journal Voucher"][jv_name];
|
||||
$.extend(jv, r.message[0]);
|
||||
$.each(r.message.slice(1), function(i, jvd) {
|
||||
var child = wn.model.add_child(jv, "Journal Voucher Detail", "entries");
|
||||
var child = frappe.model.add_child(jv, "Journal Voucher Detail", "entries");
|
||||
$.extend(child, jvd);
|
||||
});
|
||||
loaddoc("Journal Voucher", jv_name);
|
||||
@@ -225,7 +225,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
},
|
||||
|
||||
mtn_details_add: function(doc, cdt, cdn) {
|
||||
var row = wn.model.get_doc(cdt, cdn);
|
||||
var row = frappe.model.get_doc(cdt, cdn);
|
||||
this.frm.script_manager.copy_from_first_row("mtn_details", row,
|
||||
["expense_account", "cost_center"]);
|
||||
|
||||
@@ -333,7 +333,7 @@ cur_frm.fields_dict['mtn_details'].grid.get_field('batch_no').get_query = functi
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msgprint(wn._("Please enter Item Code to get batch no"));
|
||||
msgprint(frappe._("Please enter Item Code to get batch no"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.validate_items = function(doc) {
|
||||
cl = getchildren('Stock Entry Detail', doc.name, 'mtn_details');
|
||||
if (!cl.length) {
|
||||
msgprint(wn._("Item table can not be blank"));
|
||||
msgprint(frappe._("Item table can not be blank"));
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import webnotes.defaults
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
|
||||
from webnotes.utils import cstr, cint, flt, comma_or, nowdate
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
from frappe.utils import cstr, cint, flt, comma_or, nowdate
|
||||
from frappe.model.doc import addchild
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
from erpnext.stock.utils import get_incoming_rate
|
||||
from erpnext.stock.stock_ledger import get_previous_sle
|
||||
from erpnext.controllers.queries import get_match_cond
|
||||
import json
|
||||
|
||||
|
||||
class NotUpdateStockError(webnotes.ValidationError): pass
|
||||
class StockOverReturnError(webnotes.ValidationError): pass
|
||||
class IncorrectValuationRateError(webnotes.ValidationError): pass
|
||||
class DuplicateEntryForProductionOrderError(webnotes.ValidationError): pass
|
||||
class StockOverProductionError(webnotes.ValidationError): pass
|
||||
class NotUpdateStockError(frappe.ValidationError): pass
|
||||
class StockOverReturnError(frappe.ValidationError): pass
|
||||
class IncorrectValuationRateError(frappe.ValidationError): pass
|
||||
class DuplicateEntryForProductionOrderError(frappe.ValidationError): pass
|
||||
class StockOverProductionError(frappe.ValidationError): pass
|
||||
|
||||
from erpnext.controllers.stock_controller import StockController
|
||||
|
||||
@@ -154,7 +154,7 @@ class DocType(StockController):
|
||||
self.doc.production_order = None
|
||||
|
||||
def check_duplicate_entry_for_production_order(self):
|
||||
other_ste = [t[0] for t in webnotes.conn.get_values("Stock Entry", {
|
||||
other_ste = [t[0] for t in frappe.conn.get_values("Stock Entry", {
|
||||
"production_order": self.doc.production_order,
|
||||
"purpose": self.doc.purpose,
|
||||
"docstatus": ["!=", 2],
|
||||
@@ -162,17 +162,17 @@ class DocType(StockController):
|
||||
}, "name")]
|
||||
|
||||
if other_ste:
|
||||
production_item, qty = webnotes.conn.get_value("Production Order",
|
||||
production_item, qty = frappe.conn.get_value("Production Order",
|
||||
self.doc.production_order, ["production_item", "qty"])
|
||||
args = other_ste + [production_item]
|
||||
fg_qty_already_entered = webnotes.conn.sql("""select sum(actual_qty)
|
||||
fg_qty_already_entered = frappe.conn.sql("""select sum(actual_qty)
|
||||
from `tabStock Entry Detail`
|
||||
where parent in (%s)
|
||||
and item_code = %s
|
||||
and ifnull(s_warehouse,'')='' """ % (", ".join(["%s" * len(other_ste)]), "%s"), args)[0][0]
|
||||
|
||||
if fg_qty_already_entered >= qty:
|
||||
webnotes.throw(_("Stock Entries already created for Production Order ")
|
||||
frappe.throw(_("Stock Entries already created for Production Order ")
|
||||
+ self.doc.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError)
|
||||
|
||||
def set_total_amount(self):
|
||||
@@ -181,7 +181,7 @@ class DocType(StockController):
|
||||
def get_stock_and_rate(self):
|
||||
"""get stock and incoming rate on posting date"""
|
||||
for d in getlist(self.doclist, 'mtn_details'):
|
||||
args = webnotes._dict({
|
||||
args = frappe._dict({
|
||||
"item_code": d.item_code,
|
||||
"warehouse": d.s_warehouse or d.t_warehouse,
|
||||
"posting_date": self.doc.posting_date,
|
||||
@@ -203,7 +203,7 @@ class DocType(StockController):
|
||||
incoming_rate = 0
|
||||
if self.doc.purpose == "Sales Return" and \
|
||||
(self.doc.delivery_note_no or self.doc.sales_invoice_no):
|
||||
sle = webnotes.conn.sql("""select name, posting_date, posting_time,
|
||||
sle = frappe.conn.sql("""select name, posting_date, posting_time,
|
||||
actual_qty, stock_value, warehouse from `tabStock Ledger Entry`
|
||||
where voucher_type = %s and voucher_no = %s and
|
||||
item_code = %s limit 1""",
|
||||
@@ -231,7 +231,7 @@ class DocType(StockController):
|
||||
|
||||
def validate_bom(self):
|
||||
for d in getlist(self.doclist, 'mtn_details'):
|
||||
if d.bom_no and not webnotes.conn.sql("""select name from `tabBOM`
|
||||
if d.bom_no and not frappe.conn.sql("""select name from `tabBOM`
|
||||
where item = %s and name = %s and docstatus = 1 and is_active = 1""",
|
||||
(d.item_code, d.bom_no)):
|
||||
msgprint(_("Item") + " %s: " % cstr(d.item_code)
|
||||
@@ -252,12 +252,12 @@ class DocType(StockController):
|
||||
if ref.doclist:
|
||||
# validate docstatus
|
||||
if ref.doclist[0].docstatus != 1:
|
||||
webnotes.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": '
|
||||
+ _("Status should be Submitted"), raise_exception=webnotes.InvalidStatusError)
|
||||
frappe.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": '
|
||||
+ _("Status should be Submitted"), raise_exception=frappe.InvalidStatusError)
|
||||
|
||||
# update stock check
|
||||
if ref.doclist[0].doctype == "Sales Invoice" and cint(ref.doclist[0].update_stock) != 1:
|
||||
webnotes.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": '
|
||||
frappe.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": '
|
||||
+ _("Update Stock should be checked."),
|
||||
raise_exception=NotUpdateStockError)
|
||||
|
||||
@@ -267,8 +267,8 @@ class DocType(StockController):
|
||||
this_posting_datetime = "%s %s" % (cstr(self.doc.posting_date),
|
||||
cstr(self.doc.posting_time))
|
||||
if this_posting_datetime < ref_posting_datetime:
|
||||
from webnotes.utils.dateutils import datetime_in_user_format
|
||||
webnotes.msgprint(_("Posting Date Time cannot be before")
|
||||
from frappe.utils.dateutils import datetime_in_user_format
|
||||
frappe.msgprint(_("Posting Date Time cannot be before")
|
||||
+ ": " + datetime_in_user_format(ref_posting_datetime),
|
||||
raise_exception=True)
|
||||
|
||||
@@ -280,23 +280,23 @@ class DocType(StockController):
|
||||
if item.item_code not in stock_items:
|
||||
msgprint(_("Item") + ': "' + item.item_code + _("\" does not exist in ") +
|
||||
ref.doclist[0].doctype + ": " + ref.doclist[0].name,
|
||||
raise_exception=webnotes.DoesNotExistError)
|
||||
raise_exception=frappe.DoesNotExistError)
|
||||
|
||||
# validate quantity <= ref item's qty - qty already returned
|
||||
ref_item = ref.doclist.getone({"item_code": item.item_code})
|
||||
returnable_qty = ref_item.qty - flt(already_returned_item_qty.get(item.item_code))
|
||||
if not returnable_qty:
|
||||
webnotes.throw("{item}: {item_code} {returned}".format(
|
||||
frappe.throw("{item}: {item_code} {returned}".format(
|
||||
item=_("Item"), item_code=item.item_code,
|
||||
returned=_("already returned though some other documents")),
|
||||
StockOverReturnError)
|
||||
elif item.transfer_qty > returnable_qty:
|
||||
webnotes.throw("{item}: {item_code}, {returned}: {qty}".format(
|
||||
frappe.throw("{item}: {item_code}, {returned}: {qty}".format(
|
||||
item=_("Item"), item_code=item.item_code,
|
||||
returned=_("Max Returnable Qty"), qty=returnable_qty), StockOverReturnError)
|
||||
|
||||
def get_already_returned_item_qty(self, ref_fieldname):
|
||||
return dict(webnotes.conn.sql("""select item_code, sum(transfer_qty) as qty
|
||||
return dict(frappe.conn.sql("""select item_code, sum(transfer_qty) as qty
|
||||
from `tabStock Entry Detail` where parent in (
|
||||
select name from `tabStock Entry` where `%s`=%s and docstatus=1)
|
||||
group by item_code""" % (ref_fieldname, "%s"), (self.doc.fields.get(ref_fieldname),)))
|
||||
@@ -333,7 +333,7 @@ class DocType(StockController):
|
||||
def update_production_order(self):
|
||||
def _validate_production_order(pro_bean):
|
||||
if flt(pro_bean.doc.docstatus) != 1:
|
||||
webnotes.throw(_("Production Order must be submitted") + ": " +
|
||||
frappe.throw(_("Production Order must be submitted") + ": " +
|
||||
self.doc.production_order)
|
||||
|
||||
if pro_bean.doc.status == 'Stopped':
|
||||
@@ -341,7 +341,7 @@ class DocType(StockController):
|
||||
self.doc.production_order)
|
||||
|
||||
if self.doc.production_order:
|
||||
pro_bean = webnotes.bean("Production Order", self.doc.production_order)
|
||||
pro_bean = frappe.bean("Production Order", self.doc.production_order)
|
||||
_validate_production_order(pro_bean)
|
||||
self.update_produced_qty(pro_bean)
|
||||
if self.doc.purpose == "Manufacture/Repack":
|
||||
@@ -353,12 +353,12 @@ class DocType(StockController):
|
||||
(self.doc.docstatus==1 and 1 or -1 ) * flt(self.doc.fg_completed_qty)
|
||||
|
||||
if produced_qty > flt(pro_bean.doc.qty):
|
||||
webnotes.throw(_("Production Order") + ": " + self.doc.production_order + "\n" +
|
||||
frappe.throw(_("Production Order") + ": " + self.doc.production_order + "\n" +
|
||||
_("Total Manufactured Qty can not be greater than Planned qty to manufacture")
|
||||
+ "(%s/%s)" % (produced_qty, flt(pro_bean.doc.qty)), StockOverProductionError)
|
||||
|
||||
status = 'Completed' if flt(produced_qty) >= flt(pro_bean.doc.qty) else 'In Process'
|
||||
webnotes.conn.sql("""update `tabProduction Order` set status=%s, produced_qty=%s
|
||||
frappe.conn.sql("""update `tabProduction Order` set status=%s, produced_qty=%s
|
||||
where name=%s""", (status, produced_qty, self.doc.production_order))
|
||||
|
||||
def update_planned_qty(self, pro_bean):
|
||||
@@ -372,7 +372,7 @@ class DocType(StockController):
|
||||
|
||||
def get_item_details(self, arg):
|
||||
arg = json.loads(arg)
|
||||
item = webnotes.conn.sql("""select stock_uom, description, item_name,
|
||||
item = frappe.conn.sql("""select stock_uom, description, item_name,
|
||||
expense_account, buying_cost_center from `tabItem`
|
||||
where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00'
|
||||
or end_of_life > now())""", (arg.get('item_code')), as_dict = 1)
|
||||
@@ -385,7 +385,7 @@ class DocType(StockController):
|
||||
'description' : item and item[0]['description'] or '',
|
||||
'item_name' : item and item[0]['item_name'] or '',
|
||||
'expense_account' : item and item[0]['expense_account'] or arg.get("expense_account") \
|
||||
or webnotes.conn.get_value("Company", arg.get("company"), "default_expense_account"),
|
||||
or frappe.conn.get_value("Company", arg.get("company"), "default_expense_account"),
|
||||
'cost_center' : item and item[0]['buying_cost_center'] or arg.get("cost_center"),
|
||||
'qty' : 0,
|
||||
'transfer_qty' : 0,
|
||||
@@ -400,7 +400,7 @@ class DocType(StockController):
|
||||
|
||||
def get_uom_details(self, arg = ''):
|
||||
arg, ret = eval(arg), {}
|
||||
uom = webnotes.conn.sql("""select conversion_factor from `tabUOM Conversion Detail`
|
||||
uom = frappe.conn.sql("""select conversion_factor from `tabUOM Conversion Detail`
|
||||
where parent = %s and uom = %s""", (arg['item_code'], arg['uom']), as_dict = 1)
|
||||
if not uom or not flt(uom[0].conversion_factor):
|
||||
msgprint("There is no Conversion Factor for UOM '%s' in Item '%s'" % (arg['uom'],
|
||||
@@ -421,7 +421,7 @@ class DocType(StockController):
|
||||
"posting_date": self.doc.posting_date,
|
||||
"posting_time": self.doc.posting_time,
|
||||
})
|
||||
args = webnotes._dict(args)
|
||||
args = frappe._dict(args)
|
||||
|
||||
ret = {
|
||||
"actual_qty" : get_previous_sle(args).get("qty_after_transaction") or 0,
|
||||
@@ -451,7 +451,7 @@ class DocType(StockController):
|
||||
item_dict = self.get_pending_raw_materials(pro_obj)
|
||||
else:
|
||||
if not self.doc.fg_completed_qty:
|
||||
webnotes.throw(_("Manufacturing Quantity is mandatory"))
|
||||
frappe.throw(_("Manufacturing Quantity is mandatory"))
|
||||
item_dict = self.get_bom_raw_materials(self.doc.fg_completed_qty)
|
||||
for item in item_dict.values():
|
||||
if pro_obj:
|
||||
@@ -463,7 +463,7 @@ class DocType(StockController):
|
||||
|
||||
# add finished good item to Stock Entry Detail table -- along with bom_no
|
||||
if self.doc.production_order and self.doc.purpose == "Manufacture/Repack":
|
||||
item = webnotes.conn.get_value("Item", pro_obj.doc.production_item, ["item_name",
|
||||
item = frappe.conn.get_value("Item", pro_obj.doc.production_item, ["item_name",
|
||||
"description", "stock_uom", "expense_account", "buying_cost_center"], as_dict=1)
|
||||
self.add_to_stock_entry_detail({
|
||||
cstr(pro_obj.doc.production_item): {
|
||||
@@ -482,7 +482,7 @@ class DocType(StockController):
|
||||
if self.doc.purpose=="Material Receipt":
|
||||
self.doc.from_warehouse = ""
|
||||
|
||||
item = webnotes.conn.sql("""select name, item_name, description,
|
||||
item = frappe.conn.sql("""select name, item_name, description,
|
||||
stock_uom, expense_account, buying_cost_center from `tabItem`
|
||||
where name=(select item from tabBOM where name=%s)""",
|
||||
self.doc.bom_no, as_dict=1)
|
||||
@@ -539,18 +539,18 @@ class DocType(StockController):
|
||||
|
||||
# show some message
|
||||
if not len(item_dict):
|
||||
webnotes.msgprint(_("""All items have already been transferred \
|
||||
frappe.msgprint(_("""All items have already been transferred \
|
||||
for this Production Order."""))
|
||||
|
||||
elif only_pending_fetched:
|
||||
webnotes.msgprint(_("""Only quantities pending to be transferred \
|
||||
frappe.msgprint(_("""Only quantities pending to be transferred \
|
||||
were fetched for the following items:\n""" + "\n".join(only_pending_fetched)))
|
||||
|
||||
return item_dict
|
||||
|
||||
def get_issued_qty(self):
|
||||
issued_item_qty = {}
|
||||
result = webnotes.conn.sql("""select t1.item_code, sum(t1.qty)
|
||||
result = frappe.conn.sql("""select t1.item_code, sum(t1.qty)
|
||||
from `tabStock Entry Detail` t1, `tabStock Entry` t2
|
||||
where t1.parent = t2.name and t2.production_order = %s and t2.docstatus = 1
|
||||
and t2.purpose = 'Material Transfer'
|
||||
@@ -562,7 +562,7 @@ class DocType(StockController):
|
||||
|
||||
def add_to_stock_entry_detail(self, item_dict, bom_no=None, idx=None):
|
||||
if not idx: idx = 1
|
||||
expense_account, cost_center = webnotes.conn.get_values("Company", self.doc.company, \
|
||||
expense_account, cost_center = frappe.conn.get_values("Company", self.doc.company, \
|
||||
["default_expense_account", "cost_center"])[0]
|
||||
|
||||
for d in item_dict:
|
||||
@@ -594,28 +594,28 @@ class DocType(StockController):
|
||||
def validate_with_material_request(self):
|
||||
for item in self.doclist.get({"parentfield": "mtn_details"}):
|
||||
if item.material_request:
|
||||
mreq_item = webnotes.conn.get_value("Material Request Item",
|
||||
mreq_item = frappe.conn.get_value("Material Request Item",
|
||||
{"name": item.material_request_item, "parent": item.material_request},
|
||||
["item_code", "warehouse", "idx"], as_dict=True)
|
||||
if mreq_item.item_code != item.item_code or mreq_item.warehouse != item.t_warehouse:
|
||||
msgprint(_("Row #") + (" %d: " % item.idx) + _("does not match")
|
||||
+ " " + _("Row #") + (" %d %s " % (mreq_item.idx, _("of")))
|
||||
+ _("Material Request") + (" - %s" % item.material_request),
|
||||
raise_exception=webnotes.MappingMismatchError)
|
||||
raise_exception=frappe.MappingMismatchError)
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_party_details(ref_dt, ref_dn):
|
||||
if ref_dt in ["Delivery Note", "Sales Invoice"]:
|
||||
res = webnotes.conn.get_value(ref_dt, ref_dn,
|
||||
res = frappe.conn.get_value(ref_dt, ref_dn,
|
||||
["customer", "customer_name", "address_display as customer_address"], as_dict=1)
|
||||
else:
|
||||
res = webnotes.conn.get_value(ref_dt, ref_dn,
|
||||
res = frappe.conn.get_value(ref_dt, ref_dn,
|
||||
["supplier", "supplier_name", "address_display as supplier_address"], as_dict=1)
|
||||
return res or {}
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_production_order_details(production_order):
|
||||
result = webnotes.conn.sql("""select bom_no,
|
||||
result = frappe.conn.sql("""select bom_no,
|
||||
ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom,
|
||||
wip_warehouse from `tabProduction Order` where name = %s""", production_order, as_dict=1)
|
||||
return result and result[0] or {}
|
||||
@@ -625,7 +625,7 @@ def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters):
|
||||
if doctype == "Sales Invoice":
|
||||
conditions = "and update_stock=1"
|
||||
|
||||
return webnotes.conn.sql("""select name, customer, customer_name
|
||||
return frappe.conn.sql("""select name, customer, customer_name
|
||||
from `tab%s` where docstatus = 1
|
||||
and (`%s` like %%(txt)s
|
||||
or `customer` like %%(txt)s) %s %s
|
||||
@@ -636,7 +636,7 @@ def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters):
|
||||
as_list=True)
|
||||
|
||||
def query_purchase_return_doc(doctype, txt, searchfield, start, page_len, filters):
|
||||
return webnotes.conn.sql("""select name, supplier, supplier_name
|
||||
return frappe.conn.sql("""select name, supplier, supplier_name
|
||||
from `tab%s` where docstatus = 1
|
||||
and (`%s` like %%(txt)s
|
||||
or `supplier` like %%(txt)s) %s
|
||||
@@ -685,7 +685,7 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
||||
}
|
||||
|
||||
if filters.get("s_warehouse"):
|
||||
batch_nos = webnotes.conn.sql("""select batch_no
|
||||
batch_nos = frappe.conn.sql("""select batch_no
|
||||
from `tabStock Ledger Entry` sle
|
||||
where item_code = '%(item_code)s'
|
||||
and warehouse = '%(s_warehouse)s'
|
||||
@@ -704,7 +704,7 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
||||
if batch_nos:
|
||||
return batch_nos
|
||||
else:
|
||||
return webnotes.conn.sql("""select name from `tabBatch`
|
||||
return frappe.conn.sql("""select name from `tabBatch`
|
||||
where item = '%(item_code)s'
|
||||
and docstatus < 2
|
||||
and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s
|
||||
@@ -721,21 +721,21 @@ def get_stock_items_for_return(ref_doclist, parentfields):
|
||||
|
||||
all_items = list(set([d.item_code for d in
|
||||
ref_doclist.get({"parentfield": ["in", parentfields]})]))
|
||||
stock_items = webnotes.conn.sql_list("""select name from `tabItem`
|
||||
stock_items = frappe.conn.sql_list("""select name from `tabItem`
|
||||
where is_stock_item='Yes' and name in (%s)""" % (", ".join(["%s"] * len(all_items))),
|
||||
tuple(all_items))
|
||||
|
||||
return stock_items
|
||||
|
||||
def get_return_doclist_and_details(args):
|
||||
ref = webnotes._dict()
|
||||
ref = frappe._dict()
|
||||
|
||||
# get ref_doclist
|
||||
if args["purpose"] in return_map:
|
||||
for fieldname, val in return_map[args["purpose"]].items():
|
||||
if args.get(fieldname):
|
||||
ref.fieldname = fieldname
|
||||
ref.doclist = webnotes.get_doclist(val[0], args[fieldname])
|
||||
ref.doclist = frappe.get_doclist(val[0], args[fieldname])
|
||||
ref.parentfields = val[1]
|
||||
break
|
||||
|
||||
@@ -752,9 +752,9 @@ return_map = {
|
||||
}
|
||||
}
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_return_jv(stock_entry):
|
||||
se = webnotes.bean("Stock Entry", stock_entry)
|
||||
se = frappe.bean("Stock Entry", stock_entry)
|
||||
if not se.doc.purpose in ["Sales Return", "Purchase Return"]:
|
||||
return
|
||||
|
||||
@@ -845,7 +845,7 @@ def make_return_jv_from_delivery_note(se, ref):
|
||||
|
||||
for se_item in se.doclist.get({"parentfield": "mtn_details"}):
|
||||
for sales_invoice in invoices_against_delivery:
|
||||
si = webnotes.bean("Sales Invoice", sales_invoice)
|
||||
si = frappe.bean("Sales Invoice", sales_invoice)
|
||||
|
||||
if se_item.item_code in packing_item_parent_map:
|
||||
ref_item = si.doclist.get({"item_code": packing_item_parent_map[se_item.item_code]})
|
||||
@@ -878,7 +878,7 @@ def get_invoice_list(doctype, link_field, value):
|
||||
if isinstance(value, basestring):
|
||||
value = [value]
|
||||
|
||||
return webnotes.conn.sql_list("""select distinct parent from `tab%s`
|
||||
return frappe.conn.sql_list("""select distinct parent from `tab%s`
|
||||
where docstatus = 1 and `%s` in (%s)""" % (doctype, link_field,
|
||||
", ".join(["%s"]*len(value))), tuple(value))
|
||||
|
||||
@@ -902,7 +902,7 @@ def make_return_jv_from_purchase_receipt(se, ref):
|
||||
|
||||
for se_item in se.doclist.get({"parentfield": "mtn_details"}):
|
||||
for purchase_invoice in invoice_against_receipt:
|
||||
pi = webnotes.bean("Purchase Invoice", purchase_invoice)
|
||||
pi = frappe.bean("Purchase Invoice", purchase_invoice)
|
||||
ref_item = pi.doclist.get({"item_code": se_item.item_code})
|
||||
|
||||
if not ref_item:
|
||||
|
||||
@@ -2,31 +2,31 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes, unittest
|
||||
from webnotes.utils import flt
|
||||
import frappe, unittest
|
||||
from frappe.utils import flt
|
||||
from erpnext.stock.doctype.serial_no.serial_no import *
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||
from erpnext.stock.doctype.stock_ledger_entry.stock_ledger_entry import StockFreezeError
|
||||
|
||||
class TestStockEntry(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
webnotes.set_user("Administrator")
|
||||
frappe.set_user("Administrator")
|
||||
set_perpetual_inventory(0)
|
||||
if hasattr(self, "old_default_company"):
|
||||
webnotes.conn.set_default("company", self.old_default_company)
|
||||
frappe.conn.set_default("company", self.old_default_company)
|
||||
|
||||
def test_auto_material_request(self):
|
||||
webnotes.conn.sql("""delete from `tabMaterial Request Item`""")
|
||||
webnotes.conn.sql("""delete from `tabMaterial Request`""")
|
||||
frappe.conn.sql("""delete from `tabMaterial Request Item`""")
|
||||
frappe.conn.sql("""delete from `tabMaterial Request`""")
|
||||
self._clear_stock_account_balance()
|
||||
|
||||
webnotes.conn.set_value("Stock Settings", None, "auto_indent", True)
|
||||
frappe.conn.set_value("Stock Settings", None, "auto_indent", True)
|
||||
|
||||
st1 = webnotes.bean(copy=test_records[0])
|
||||
st1 = frappe.bean(copy=test_records[0])
|
||||
st1.insert()
|
||||
st1.submit()
|
||||
|
||||
st2 = webnotes.bean(copy=test_records[1])
|
||||
st2 = frappe.bean(copy=test_records[1])
|
||||
st2.insert()
|
||||
st2.submit()
|
||||
|
||||
@@ -34,22 +34,22 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
reorder_item()
|
||||
|
||||
mr_name = webnotes.conn.sql("""select parent from `tabMaterial Request Item`
|
||||
mr_name = frappe.conn.sql("""select parent from `tabMaterial Request Item`
|
||||
where item_code='_Test Item'""")
|
||||
|
||||
self.assertTrue(mr_name)
|
||||
|
||||
webnotes.conn.set_default("company", self.old_default_company)
|
||||
frappe.conn.set_default("company", self.old_default_company)
|
||||
|
||||
def test_material_receipt_gl_entry(self):
|
||||
self._clear_stock_account_balance()
|
||||
set_perpetual_inventory()
|
||||
|
||||
mr = webnotes.bean(copy=test_records[0])
|
||||
mr = frappe.bean(copy=test_records[0])
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
|
||||
stock_in_hand_account = webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
stock_in_hand_account = frappe.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
"master_name": mr.doclist[1].t_warehouse})
|
||||
|
||||
self.check_stock_ledger_entries("Stock Entry", mr.doc.name,
|
||||
@@ -64,10 +64,10 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
mr.cancel()
|
||||
|
||||
self.assertFalse(webnotes.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
self.assertFalse(frappe.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
where voucher_type='Stock Entry' and voucher_no=%s""", mr.doc.name))
|
||||
|
||||
self.assertFalse(webnotes.conn.sql("""select * from `tabGL Entry`
|
||||
self.assertFalse(frappe.conn.sql("""select * from `tabGL Entry`
|
||||
where voucher_type='Stock Entry' and voucher_no=%s""", mr.doc.name))
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
self._insert_material_receipt()
|
||||
|
||||
mi = webnotes.bean(copy=test_records[1])
|
||||
mi = frappe.bean(copy=test_records[1])
|
||||
mi.insert()
|
||||
mi.submit()
|
||||
|
||||
self.check_stock_ledger_entries("Stock Entry", mi.doc.name,
|
||||
[["_Test Item", "_Test Warehouse - _TC", -40.0]])
|
||||
|
||||
stock_in_hand_account = webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
stock_in_hand_account = frappe.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
"master_name": mi.doclist[1].s_warehouse})
|
||||
|
||||
self.check_gl_entries("Stock Entry", mi.doc.name,
|
||||
@@ -95,16 +95,16 @@ class TestStockEntry(unittest.TestCase):
|
||||
)
|
||||
|
||||
mi.cancel()
|
||||
self.assertFalse(webnotes.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
self.assertFalse(frappe.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
where voucher_type='Stock Entry' and voucher_no=%s""", mi.doc.name))
|
||||
|
||||
self.assertFalse(webnotes.conn.sql("""select * from `tabGL Entry`
|
||||
self.assertFalse(frappe.conn.sql("""select * from `tabGL Entry`
|
||||
where voucher_type='Stock Entry' and voucher_no=%s""", mi.doc.name))
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Bin", {"warehouse": mi.doclist[1].s_warehouse,
|
||||
self.assertEquals(frappe.conn.get_value("Bin", {"warehouse": mi.doclist[1].s_warehouse,
|
||||
"item_code": mi.doclist[1].item_code}, "actual_qty"), 50)
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Bin", {"warehouse": mi.doclist[1].s_warehouse,
|
||||
self.assertEquals(frappe.conn.get_value("Bin", {"warehouse": mi.doclist[1].s_warehouse,
|
||||
"item_code": mi.doclist[1].item_code}, "stock_value"), 5000)
|
||||
|
||||
def test_material_transfer_gl_entry(self):
|
||||
@@ -113,17 +113,17 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
self._insert_material_receipt()
|
||||
|
||||
mtn = webnotes.bean(copy=test_records[2])
|
||||
mtn = frappe.bean(copy=test_records[2])
|
||||
mtn.insert()
|
||||
mtn.submit()
|
||||
|
||||
self.check_stock_ledger_entries("Stock Entry", mtn.doc.name,
|
||||
[["_Test Item", "_Test Warehouse - _TC", -45.0], ["_Test Item", "_Test Warehouse 1 - _TC", 45.0]])
|
||||
|
||||
stock_in_hand_account = webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
stock_in_hand_account = frappe.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
"master_name": mtn.doclist[1].s_warehouse})
|
||||
|
||||
fixed_asset_account = webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
fixed_asset_account = frappe.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
"master_name": mtn.doclist[1].t_warehouse})
|
||||
|
||||
|
||||
@@ -136,10 +136,10 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
|
||||
mtn.cancel()
|
||||
self.assertFalse(webnotes.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
self.assertFalse(frappe.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
where voucher_type='Stock Entry' and voucher_no=%s""", mtn.doc.name))
|
||||
|
||||
self.assertFalse(webnotes.conn.sql("""select * from `tabGL Entry`
|
||||
self.assertFalse(frappe.conn.sql("""select * from `tabGL Entry`
|
||||
where voucher_type='Stock Entry' and voucher_no=%s""", mtn.doc.name))
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
self._insert_material_receipt()
|
||||
|
||||
repack = webnotes.bean(copy=test_records[3])
|
||||
repack = frappe.bean(copy=test_records[3])
|
||||
repack.insert()
|
||||
repack.submit()
|
||||
|
||||
@@ -157,7 +157,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
[["_Test Item", "_Test Warehouse - _TC", -50.0],
|
||||
["_Test Item Home Desktop 100", "_Test Warehouse - _TC", 1]])
|
||||
|
||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Stock Entry' and voucher_no=%s
|
||||
order by account desc""", repack.doc.name, as_dict=1)
|
||||
self.assertFalse(gl_entries)
|
||||
@@ -170,12 +170,12 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
self._insert_material_receipt()
|
||||
|
||||
repack = webnotes.bean(copy=test_records[3])
|
||||
repack = frappe.bean(copy=test_records[3])
|
||||
repack.doclist[2].incoming_rate = 6000
|
||||
repack.insert()
|
||||
repack.submit()
|
||||
|
||||
stock_in_hand_account = webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
stock_in_hand_account = frappe.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
"master_name": repack.doclist[2].t_warehouse})
|
||||
|
||||
self.check_gl_entries("Stock Entry", repack.doc.name,
|
||||
@@ -190,7 +190,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
expected_sle.sort(key=lambda x: x[0])
|
||||
|
||||
# check stock ledger entries
|
||||
sle = webnotes.conn.sql("""select item_code, warehouse, actual_qty
|
||||
sle = frappe.conn.sql("""select item_code, warehouse, actual_qty
|
||||
from `tabStock Ledger Entry` where voucher_type = %s
|
||||
and voucher_no = %s order by item_code, warehouse, actual_qty""",
|
||||
(voucher_type, voucher_no), as_list=1)
|
||||
@@ -205,7 +205,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
def check_gl_entries(self, voucher_type, voucher_no, expected_gl_entries):
|
||||
expected_gl_entries.sort(key=lambda x: x[0])
|
||||
|
||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type=%s and voucher_no=%s
|
||||
order by account asc, debit asc""", (voucher_type, voucher_no), as_list=1)
|
||||
self.assertTrue(gl_entries)
|
||||
@@ -218,19 +218,19 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
def _insert_material_receipt(self):
|
||||
self._clear_stock_account_balance()
|
||||
se1 = webnotes.bean(copy=test_records[0])
|
||||
se1 = frappe.bean(copy=test_records[0])
|
||||
se1.insert()
|
||||
se1.submit()
|
||||
|
||||
se2 = webnotes.bean(copy=test_records[0])
|
||||
se2 = frappe.bean(copy=test_records[0])
|
||||
se2.doclist[1].item_code = "_Test Item Home Desktop 100"
|
||||
se2.insert()
|
||||
se2.submit()
|
||||
|
||||
webnotes.conn.set_default("company", self.old_default_company)
|
||||
frappe.conn.set_default("company", self.old_default_company)
|
||||
|
||||
def _get_actual_qty(self):
|
||||
return flt(webnotes.conn.get_value("Bin", {"item_code": "_Test Item",
|
||||
return flt(frappe.conn.get_value("Bin", {"item_code": "_Test Item",
|
||||
"warehouse": "_Test Warehouse - _TC"}, "actual_qty"))
|
||||
|
||||
def _test_sales_invoice_return(self, item_code, delivered_qty, returned_qty):
|
||||
@@ -240,11 +240,11 @@ class TestStockEntry(unittest.TestCase):
|
||||
import test_records as sales_invoice_test_records
|
||||
|
||||
# invalid sales invoice as update stock not checked
|
||||
si = webnotes.bean(copy=sales_invoice_test_records[1])
|
||||
si = frappe.bean(copy=sales_invoice_test_records[1])
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Sales Return"
|
||||
se.doc.sales_invoice_no = si.doc.name
|
||||
se.doclist[1].qty = returned_qty
|
||||
@@ -257,7 +257,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
actual_qty_0 = self._get_actual_qty()
|
||||
|
||||
# insert a pos invoice with update stock
|
||||
si = webnotes.bean(copy=sales_invoice_test_records[1])
|
||||
si = frappe.bean(copy=sales_invoice_test_records[1])
|
||||
si.doc.is_pos = si.doc.update_stock = 1
|
||||
si.doclist[1].warehouse = "_Test Warehouse - _TC"
|
||||
si.doclist[1].item_code = item_code
|
||||
@@ -271,7 +271,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
self.assertEquals(actual_qty_0 - delivered_qty, actual_qty_1)
|
||||
|
||||
# check if item is validated
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Sales Return"
|
||||
se.doc.sales_invoice_no = si.doc.name
|
||||
se.doc.posting_date = "2013-03-10"
|
||||
@@ -281,10 +281,10 @@ class TestStockEntry(unittest.TestCase):
|
||||
se.doclist[1].transfer_qty = returned_qty
|
||||
|
||||
# check if stock entry gets submitted
|
||||
self.assertRaises(webnotes.DoesNotExistError, se.insert)
|
||||
self.assertRaises(frappe.DoesNotExistError, se.insert)
|
||||
|
||||
# try again
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Sales Return"
|
||||
se.doc.posting_date = "2013-03-10"
|
||||
se.doc.fiscal_year = "_Test Fiscal Year 2013"
|
||||
@@ -321,7 +321,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
actual_qty_0 = self._get_actual_qty()
|
||||
# make a delivery note based on this invoice
|
||||
dn = webnotes.bean(copy=delivery_note_test_records[0])
|
||||
dn = frappe.bean(copy=delivery_note_test_records[0])
|
||||
dn.doclist[1].item_code = item_code
|
||||
dn.insert()
|
||||
dn.submit()
|
||||
@@ -332,7 +332,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
si_doclist = make_sales_invoice(dn.doc.name)
|
||||
|
||||
si = webnotes.bean(si_doclist)
|
||||
si = frappe.bean(si_doclist)
|
||||
si.doc.posting_date = dn.doc.posting_date
|
||||
si.doc.debit_to = "_Test Customer - _TC"
|
||||
for d in si.doclist.get({"parentfield": "entries"}):
|
||||
@@ -342,7 +342,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
si.submit()
|
||||
|
||||
# insert and submit stock entry for sales return
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Sales Return"
|
||||
se.doc.delivery_note_no = dn.doc.name
|
||||
se.doc.posting_date = "2013-03-10"
|
||||
@@ -410,7 +410,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
actual_qty_0 = self._get_actual_qty()
|
||||
|
||||
so = webnotes.bean(copy=sales_order_test_records[0])
|
||||
so = frappe.bean(copy=sales_order_test_records[0])
|
||||
so.doclist[1].item_code = item_code
|
||||
so.doclist[1].qty = 5.0
|
||||
so.insert()
|
||||
@@ -418,7 +418,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
dn_doclist = make_delivery_note(so.doc.name)
|
||||
|
||||
dn = webnotes.bean(dn_doclist)
|
||||
dn = frappe.bean(dn_doclist)
|
||||
dn.doc.status = "Draft"
|
||||
dn.doc.posting_date = so.doc.delivery_date
|
||||
dn.insert()
|
||||
@@ -430,7 +430,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
si_doclist = make_sales_invoice(so.doc.name)
|
||||
|
||||
si = webnotes.bean(si_doclist)
|
||||
si = frappe.bean(si_doclist)
|
||||
si.doc.posting_date = dn.doc.posting_date
|
||||
si.doc.debit_to = "_Test Customer - _TC"
|
||||
for d in si.doclist.get({"parentfield": "entries"}):
|
||||
@@ -440,7 +440,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
si.submit()
|
||||
|
||||
# insert and submit stock entry for sales return
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Sales Return"
|
||||
se.doc.delivery_note_no = dn.doc.name
|
||||
se.doc.posting_date = "2013-03-10"
|
||||
@@ -466,7 +466,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||
|
||||
# submit purchase receipt
|
||||
pr = webnotes.bean(copy=purchase_receipt_test_records[0])
|
||||
pr = frappe.bean(copy=purchase_receipt_test_records[0])
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
|
||||
@@ -476,7 +476,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
pi_doclist = make_purchase_invoice(pr.doc.name)
|
||||
|
||||
pi = webnotes.bean(pi_doclist)
|
||||
pi = frappe.bean(pi_doclist)
|
||||
pi.doc.posting_date = pr.doc.posting_date
|
||||
pi.doc.credit_to = "_Test Supplier - _TC"
|
||||
for d in pi.doclist.get({"parentfield": "entries"}):
|
||||
@@ -492,7 +492,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
pi.submit()
|
||||
|
||||
# submit purchase return
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Purchase Return"
|
||||
se.doc.purchase_receipt_no = pr.doc.name
|
||||
se.doc.posting_date = "2013-03-01"
|
||||
@@ -506,7 +506,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
self.assertEquals(actual_qty_1 - 5, actual_qty_2)
|
||||
|
||||
webnotes.conn.set_default("company", self.old_default_company)
|
||||
frappe.conn.set_default("company", self.old_default_company)
|
||||
|
||||
return se, pr.doc.name
|
||||
|
||||
@@ -518,7 +518,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
prev_se, pr_docname = self.test_purchase_receipt_return()
|
||||
|
||||
# submit purchase return - return another 6 qtys so that exception is raised
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Purchase Return"
|
||||
se.doc.purchase_receipt_no = pr_docname
|
||||
se.doc.posting_date = "2013-03-01"
|
||||
@@ -559,7 +559,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
make_purchase_receipt, make_purchase_invoice
|
||||
|
||||
# submit purchase receipt
|
||||
po = webnotes.bean(copy=purchase_order_test_records[0])
|
||||
po = frappe.bean(copy=purchase_order_test_records[0])
|
||||
po.doc.is_subcontracted = None
|
||||
po.doclist[1].item_code = "_Test Item"
|
||||
po.doclist[1].rate = 50
|
||||
@@ -568,7 +568,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
pr_doclist = make_purchase_receipt(po.doc.name)
|
||||
|
||||
pr = webnotes.bean(pr_doclist)
|
||||
pr = frappe.bean(pr_doclist)
|
||||
pr.doc.posting_date = po.doc.transaction_date
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
@@ -579,7 +579,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
pi_doclist = make_purchase_invoice(po.doc.name)
|
||||
|
||||
pi = webnotes.bean(pi_doclist)
|
||||
pi = frappe.bean(pi_doclist)
|
||||
pi.doc.posting_date = pr.doc.posting_date
|
||||
pi.doc.credit_to = "_Test Supplier - _TC"
|
||||
for d in pi.doclist.get({"parentfield": "entries"}):
|
||||
@@ -594,7 +594,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
pi.submit()
|
||||
|
||||
# submit purchase return
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Purchase Return"
|
||||
se.doc.purchase_receipt_no = pr.doc.name
|
||||
se.doc.posting_date = "2013-03-01"
|
||||
@@ -608,26 +608,26 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
self.assertEquals(actual_qty_1 - 5, actual_qty_2)
|
||||
|
||||
webnotes.conn.set_default("company", self.old_default_company)
|
||||
frappe.conn.set_default("company", self.old_default_company)
|
||||
|
||||
return se, pr.doc.name
|
||||
|
||||
def _clear_stock_account_balance(self):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
||||
frappe.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
frappe.conn.sql("""delete from `tabBin`""")
|
||||
frappe.conn.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
self.old_default_company = webnotes.conn.get_default("company")
|
||||
webnotes.conn.set_default("company", "_Test Company")
|
||||
self.old_default_company = frappe.conn.get_default("company")
|
||||
frappe.conn.set_default("company", "_Test Company")
|
||||
|
||||
def test_serial_no_not_reqd(self):
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doclist[1].serial_no = "ABCD"
|
||||
se.insert()
|
||||
self.assertRaises(SerialNoNotRequiredError, se.submit)
|
||||
|
||||
def test_serial_no_reqd(self):
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doclist[1].item_code = "_Test Serialized Item"
|
||||
se.doclist[1].qty = 2
|
||||
se.doclist[1].transfer_qty = 2
|
||||
@@ -635,7 +635,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
self.assertRaises(SerialNoRequiredError, se.submit)
|
||||
|
||||
def test_serial_no_qty_more(self):
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doclist[1].item_code = "_Test Serialized Item"
|
||||
se.doclist[1].qty = 2
|
||||
se.doclist[1].serial_no = "ABCD\nEFGH\nXYZ"
|
||||
@@ -644,7 +644,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
self.assertRaises(SerialNoQtyError, se.submit)
|
||||
|
||||
def test_serial_no_qty_less(self):
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doclist[1].item_code = "_Test Serialized Item"
|
||||
se.doclist[1].qty = 2
|
||||
se.doclist[1].serial_no = "ABCD"
|
||||
@@ -654,7 +654,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
def test_serial_no_transfer_in(self):
|
||||
self._clear_stock_account_balance()
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doclist[1].item_code = "_Test Serialized Item"
|
||||
se.doclist[1].qty = 2
|
||||
se.doclist[1].serial_no = "ABCD\nEFGH"
|
||||
@@ -662,15 +662,15 @@ class TestStockEntry(unittest.TestCase):
|
||||
se.insert()
|
||||
se.submit()
|
||||
|
||||
self.assertTrue(webnotes.conn.exists("Serial No", "ABCD"))
|
||||
self.assertTrue(webnotes.conn.exists("Serial No", "EFGH"))
|
||||
self.assertTrue(frappe.conn.exists("Serial No", "ABCD"))
|
||||
self.assertTrue(frappe.conn.exists("Serial No", "EFGH"))
|
||||
|
||||
se.cancel()
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", "ABCD", "warehouse"))
|
||||
self.assertFalse(frappe.conn.get_value("Serial No", "ABCD", "warehouse"))
|
||||
|
||||
def test_serial_no_not_exists(self):
|
||||
self._clear_stock_account_balance()
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Material Issue"
|
||||
se.doclist[1].item_code = "_Test Serialized Item"
|
||||
se.doclist[1].qty = 2
|
||||
@@ -685,7 +685,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
self._clear_stock_account_balance()
|
||||
self.test_serial_by_series()
|
||||
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
se.doclist[1].qty = 1
|
||||
se.doclist[1].serial_no = "ABCD00001"
|
||||
@@ -699,8 +699,8 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||
|
||||
self.assertTrue(webnotes.conn.exists("Serial No", serial_nos[0]))
|
||||
self.assertTrue(webnotes.conn.exists("Serial No", serial_nos[1]))
|
||||
self.assertTrue(frappe.conn.exists("Serial No", serial_nos[0]))
|
||||
self.assertTrue(frappe.conn.exists("Serial No", serial_nos[1]))
|
||||
|
||||
return se
|
||||
|
||||
@@ -708,7 +708,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
self._clear_stock_account_balance()
|
||||
self.test_serial_by_series()
|
||||
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Material Transfer"
|
||||
se.doclist[1].item_code = "_Test Serialized Item"
|
||||
se.doclist[1].qty = 1
|
||||
@@ -724,7 +724,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
se = make_serialized_item()
|
||||
serial_no = get_serial_nos(se.doclist[1].serial_no)[0]
|
||||
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Material Transfer"
|
||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
se.doclist[1].qty = 1
|
||||
@@ -734,16 +734,16 @@ class TestStockEntry(unittest.TestCase):
|
||||
se.doclist[1].t_warehouse = "_Test Warehouse 1 - _TC"
|
||||
se.insert()
|
||||
se.submit()
|
||||
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse 1 - _TC")
|
||||
self.assertTrue(frappe.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse 1 - _TC")
|
||||
|
||||
se.cancel()
|
||||
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse - _TC")
|
||||
self.assertTrue(frappe.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse - _TC")
|
||||
|
||||
def test_serial_warehouse_error(self):
|
||||
self._clear_stock_account_balance()
|
||||
make_serialized_item()
|
||||
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doc.purpose = "Material Transfer"
|
||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
se.doclist[1].qty = 1
|
||||
@@ -760,69 +760,69 @@ class TestStockEntry(unittest.TestCase):
|
||||
se.cancel()
|
||||
|
||||
serial_no = get_serial_nos(se.doclist[1].serial_no)[0]
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_no, "warehouse"))
|
||||
self.assertFalse(frappe.conn.get_value("Serial No", serial_no, "warehouse"))
|
||||
|
||||
def test_warehouse_company_validation(self):
|
||||
set_perpetual_inventory(0)
|
||||
self._clear_stock_account_balance()
|
||||
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
||||
frappe.bean("Profile", "test2@example.com").get_controller()\
|
||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||
webnotes.set_user("test2@example.com")
|
||||
frappe.set_user("test2@example.com")
|
||||
|
||||
from erpnext.stock.utils import InvalidWarehouseCompany
|
||||
st1 = webnotes.bean(copy=test_records[0])
|
||||
st1 = frappe.bean(copy=test_records[0])
|
||||
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
||||
st1.insert()
|
||||
self.assertRaises(InvalidWarehouseCompany, st1.submit)
|
||||
|
||||
# permission tests
|
||||
def test_warehouse_user(self):
|
||||
import webnotes.defaults
|
||||
from webnotes.model.bean import BeanPermissionError
|
||||
import frappe.defaults
|
||||
from frappe.model.bean import BeanPermissionError
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
webnotes.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction")
|
||||
webnotes.defaults.add_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", "Restriction")
|
||||
webnotes.bean("Profile", "test@example.com").get_controller()\
|
||||
frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction")
|
||||
frappe.defaults.add_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", "Restriction")
|
||||
frappe.bean("Profile", "test@example.com").get_controller()\
|
||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
||||
frappe.bean("Profile", "test2@example.com").get_controller()\
|
||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||
|
||||
webnotes.set_user("test@example.com")
|
||||
st1 = webnotes.bean(copy=test_records[0])
|
||||
frappe.set_user("test@example.com")
|
||||
st1 = frappe.bean(copy=test_records[0])
|
||||
st1.doc.company = "_Test Company 1"
|
||||
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
||||
self.assertRaises(BeanPermissionError, st1.insert)
|
||||
|
||||
webnotes.set_user("test2@example.com")
|
||||
st1 = webnotes.bean(copy=test_records[0])
|
||||
frappe.set_user("test2@example.com")
|
||||
st1 = frappe.bean(copy=test_records[0])
|
||||
st1.doc.company = "_Test Company 1"
|
||||
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
||||
st1.insert()
|
||||
st1.submit()
|
||||
|
||||
webnotes.defaults.clear_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", parenttype="Restriction")
|
||||
webnotes.defaults.clear_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", parenttype="Restriction")
|
||||
frappe.defaults.clear_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", parenttype="Restriction")
|
||||
frappe.defaults.clear_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", parenttype="Restriction")
|
||||
|
||||
def test_freeze_stocks (self):
|
||||
self._clear_stock_account_balance()
|
||||
webnotes.conn.set_value('Stock Settings', None,'stock_auth_role', '')
|
||||
frappe.conn.set_value('Stock Settings', None,'stock_auth_role', '')
|
||||
|
||||
# test freeze_stocks_upto
|
||||
date_newer_than_test_records = add_days(getdate(test_records[0][0]['posting_date']), 5)
|
||||
webnotes.conn.set_value("Stock Settings", None, "stock_frozen_upto", date_newer_than_test_records)
|
||||
se = webnotes.bean(copy=test_records[0]).insert()
|
||||
frappe.conn.set_value("Stock Settings", None, "stock_frozen_upto", date_newer_than_test_records)
|
||||
se = frappe.bean(copy=test_records[0]).insert()
|
||||
self.assertRaises (StockFreezeError, se.submit)
|
||||
webnotes.conn.set_value("Stock Settings", None, "stock_frozen_upto", '')
|
||||
frappe.conn.set_value("Stock Settings", None, "stock_frozen_upto", '')
|
||||
|
||||
# test freeze_stocks_upto_days
|
||||
webnotes.conn.set_value("Stock Settings", None, "stock_frozen_upto_days", 7)
|
||||
se = webnotes.bean(copy=test_records[0]).insert()
|
||||
frappe.conn.set_value("Stock Settings", None, "stock_frozen_upto_days", 7)
|
||||
se = frappe.bean(copy=test_records[0]).insert()
|
||||
self.assertRaises (StockFreezeError, se.submit)
|
||||
webnotes.conn.set_value("Stock Settings", None, "stock_frozen_upto_days", 0)
|
||||
frappe.conn.set_value("Stock Settings", None, "stock_frozen_upto_days", 0)
|
||||
|
||||
def make_serialized_item():
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
se = frappe.bean(copy=test_records[0])
|
||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
se.doclist[1].qty = 2
|
||||
se.doclist[1].transfer_qty = 2
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import add_days, cstr, flt, nowdate, cint, now
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, msgprint
|
||||
from frappe.utils import add_days, cstr, flt, nowdate, cint, now
|
||||
from frappe.model.doc import Document
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import session, msgprint
|
||||
from erpnext.stock.utils import get_valid_serial_nos
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ class DocType:
|
||||
if v.get('is_cancelled') == 'Yes':
|
||||
v['actual_qty'] = -flt(v['actual_qty'])
|
||||
# cancel matching entry
|
||||
webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
|
||||
frappe.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
|
||||
modified=%s, modified_by=%s
|
||||
where voucher_no=%s and voucher_type=%s""",
|
||||
(now(), webnotes.session.user, v['voucher_no'], v['voucher_type']))
|
||||
(now(), frappe.session.user, v['voucher_no'], v['voucher_type']))
|
||||
|
||||
if v.get("actual_qty"):
|
||||
sle_id = self.make_entry(v)
|
||||
@@ -44,7 +44,7 @@ class DocType:
|
||||
|
||||
def make_entry(self, args):
|
||||
args.update({"doctype": "Stock Ledger Entry"})
|
||||
sle = webnotes.bean([args])
|
||||
sle = frappe.bean([args])
|
||||
sle.ignore_permissions = 1
|
||||
sle.insert()
|
||||
return sle.doc.name
|
||||
@@ -53,5 +53,5 @@ class DocType:
|
||||
"""
|
||||
Repost everything!
|
||||
"""
|
||||
for wh in webnotes.conn.sql("select name from tabWarehouse"):
|
||||
for wh in frappe.conn.sql("select name from tabWarehouse"):
|
||||
get_obj('Warehouse', wh[0]).repost_stock()
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint
|
||||
from webnotes.utils import flt, getdate, add_days
|
||||
from webnotes.model.controller import DocListController
|
||||
import frappe
|
||||
from frappe import msgprint
|
||||
from frappe.utils import flt, getdate, add_days
|
||||
from frappe.model.controller import DocListController
|
||||
from datetime import date
|
||||
|
||||
class StockFreezeError(webnotes.ValidationError): pass
|
||||
class StockFreezeError(frappe.ValidationError): pass
|
||||
|
||||
class DocType(DocListController):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -37,7 +37,7 @@ class DocType(DocListController):
|
||||
#check for item quantity available in stock
|
||||
def actual_amt_check(self):
|
||||
if self.doc.batch_no:
|
||||
batch_bal_after_transaction = flt(webnotes.conn.sql("""select sum(actual_qty)
|
||||
batch_bal_after_transaction = flt(frappe.conn.sql("""select sum(actual_qty)
|
||||
from `tabStock Ledger Entry`
|
||||
where warehouse=%s and item_code=%s and batch_no=%s""",
|
||||
(self.doc.warehouse, self.doc.item_code, self.doc.batch_no))[0][0])
|
||||
@@ -47,7 +47,7 @@ class DocType(DocListController):
|
||||
'batch_bal': batch_bal_after_transaction - self.doc.actual_qty
|
||||
})
|
||||
|
||||
webnotes.throw("""Not enough quantity (requested: %(actual_qty)s, \
|
||||
frappe.throw("""Not enough quantity (requested: %(actual_qty)s, \
|
||||
current: %(batch_bal)s in Batch <b>%(batch_no)s</b> for Item \
|
||||
<b>%(item_code)s</b> at Warehouse <b>%(warehouse)s</b> \
|
||||
as on %(posting_date)s %(posting_time)s""" % self.doc.fields)
|
||||
@@ -60,43 +60,43 @@ class DocType(DocListController):
|
||||
if not self.doc.fields.get(k):
|
||||
msgprint("Stock Ledger Entry: '%s' is mandatory" % k, raise_exception = 1)
|
||||
elif k == 'warehouse':
|
||||
if not webnotes.conn.sql("select name from tabWarehouse where name = '%s'" % self.doc.fields.get(k)):
|
||||
if not frappe.conn.sql("select name from tabWarehouse where name = '%s'" % self.doc.fields.get(k)):
|
||||
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
|
||||
|
||||
def validate_item(self):
|
||||
item_det = webnotes.conn.sql("""select name, has_batch_no, docstatus,
|
||||
item_det = frappe.conn.sql("""select name, has_batch_no, docstatus,
|
||||
is_stock_item, has_serial_no, serial_no_series
|
||||
from tabItem where name=%s""",
|
||||
self.doc.item_code, as_dict=True)[0]
|
||||
|
||||
if item_det.is_stock_item != 'Yes':
|
||||
webnotes.throw("""Item: "%s" is not a Stock Item.""" % self.doc.item_code)
|
||||
frappe.throw("""Item: "%s" is not a Stock Item.""" % self.doc.item_code)
|
||||
|
||||
# check if batch number is required
|
||||
if item_det.has_batch_no =='Yes' and self.doc.voucher_type != 'Stock Reconciliation':
|
||||
if not self.doc.batch_no:
|
||||
webnotes.throw("Batch number is mandatory for Item '%s'" % self.doc.item_code)
|
||||
frappe.throw("Batch number is mandatory for Item '%s'" % self.doc.item_code)
|
||||
|
||||
# check if batch belongs to item
|
||||
if not webnotes.conn.sql("""select name from `tabBatch`
|
||||
if not frappe.conn.sql("""select name from `tabBatch`
|
||||
where item='%s' and name ='%s' and docstatus != 2""" % (self.doc.item_code, self.doc.batch_no)):
|
||||
webnotes.throw("'%s' is not a valid Batch Number for Item '%s'" % (self.doc.batch_no, self.doc.item_code))
|
||||
frappe.throw("'%s' is not a valid Batch Number for Item '%s'" % (self.doc.batch_no, self.doc.item_code))
|
||||
|
||||
if not self.doc.stock_uom:
|
||||
self.doc.stock_uom = item_det.stock_uom
|
||||
|
||||
def check_stock_frozen_date(self):
|
||||
stock_frozen_upto = webnotes.conn.get_value('Stock Settings', None, 'stock_frozen_upto') or ''
|
||||
stock_frozen_upto = frappe.conn.get_value('Stock Settings', None, 'stock_frozen_upto') or ''
|
||||
if stock_frozen_upto:
|
||||
stock_auth_role = webnotes.conn.get_value('Stock Settings', None,'stock_auth_role')
|
||||
if getdate(self.doc.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in webnotes.user.get_roles():
|
||||
stock_auth_role = frappe.conn.get_value('Stock Settings', None,'stock_auth_role')
|
||||
if getdate(self.doc.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in frappe.user.get_roles():
|
||||
msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=StockFreezeError)
|
||||
|
||||
stock_frozen_upto_days = int(webnotes.conn.get_value('Stock Settings', None, 'stock_frozen_upto_days') or 0)
|
||||
stock_frozen_upto_days = int(frappe.conn.get_value('Stock Settings', None, 'stock_frozen_upto_days') or 0)
|
||||
if stock_frozen_upto_days:
|
||||
stock_auth_role = webnotes.conn.get_value('Stock Settings', None,'stock_auth_role')
|
||||
stock_auth_role = frappe.conn.get_value('Stock Settings', None,'stock_auth_role')
|
||||
older_than_x_days_ago = (add_days(getdate(self.doc.posting_date), stock_frozen_upto_days) <= date.today())
|
||||
if older_than_x_days_ago and not stock_auth_role in webnotes.user.get_roles():
|
||||
if older_than_x_days_ago and not stock_auth_role in frappe.user.get_roles():
|
||||
msgprint("You are not authorized to do / modify back dated stock entries older than %d days ago" %stock_frozen_upto_days, raise_exception=StockFreezeError)
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ class DocType(DocListController):
|
||||
self.doc.posting_time = '00:00'
|
||||
|
||||
def on_doctype_update():
|
||||
if not webnotes.conn.sql("""show index from `tabStock Ledger Entry`
|
||||
if not frappe.conn.sql("""show index from `tabStock Ledger Entry`
|
||||
where Key_name="posting_sort_index" """):
|
||||
webnotes.conn.commit()
|
||||
webnotes.conn.sql("""alter table `tabStock Ledger Entry`
|
||||
frappe.conn.commit()
|
||||
frappe.conn.sql("""alter table `tabStock Ledger Entry`
|
||||
add index posting_sort_index(posting_date, posting_time, name)""")
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
wn.provide("erpnext.stock");
|
||||
frappe.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
frappe.provide("erpnext.stock");
|
||||
|
||||
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
onload: function() {
|
||||
@@ -56,12 +56,12 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
this.show_download_template();
|
||||
this.show_upload();
|
||||
if(this.frm.doc.reconciliation_json) {
|
||||
this.frm.set_intro(wn._("You can submit this Stock Reconciliation."));
|
||||
this.frm.set_intro(frappe._("You can submit this Stock Reconciliation."));
|
||||
} else {
|
||||
this.frm.set_intro(wn._("Download the Template, fill appropriate data and attach the modified file."));
|
||||
this.frm.set_intro(frappe._("Download the Template, fill appropriate data and attach the modified file."));
|
||||
}
|
||||
} else if(this.frm.doc.docstatus == 1) {
|
||||
this.frm.set_intro(wn._("Cancelling this Stock Reconciliation will nullify its effect."));
|
||||
this.frm.set_intro(frappe._("Cancelling this Stock Reconciliation will nullify its effect."));
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
} else {
|
||||
@@ -73,20 +73,20 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
|
||||
show_download_template: function() {
|
||||
var me = this;
|
||||
this.frm.add_custom_button(wn._("Download Template"), function() {
|
||||
this.title = wn._("Stock Reconcilation Template");
|
||||
wn.tools.downloadify([[wn._("Stock Reconciliation")],
|
||||
this.frm.add_custom_button(frappe._("Download Template"), function() {
|
||||
this.title = frappe._("Stock Reconcilation Template");
|
||||
frappe.tools.downloadify([[frappe._("Stock Reconciliation")],
|
||||
["----"],
|
||||
[wn._("Stock Reconciliation can be used to update the stock on a particular date, ")
|
||||
+ wn._("usually as per physical inventory.")],
|
||||
[wn._("When submitted, the system creates difference entries ")
|
||||
+ wn._("to set the given stock and valuation on this date.")],
|
||||
[wn._("It can also be used to create opening stock entries and to fix stock value.")],
|
||||
[frappe._("Stock Reconciliation can be used to update the stock on a particular date, ")
|
||||
+ frappe._("usually as per physical inventory.")],
|
||||
[frappe._("When submitted, the system creates difference entries ")
|
||||
+ frappe._("to set the given stock and valuation on this date.")],
|
||||
[frappe._("It can also be used to create opening stock entries and to fix stock value.")],
|
||||
["----"],
|
||||
[wn._("Notes:")],
|
||||
[wn._("Item Code and Warehouse should already exist.")],
|
||||
[wn._("You can update either Quantity or Valuation Rate or both.")],
|
||||
[wn._("If no change in either Quantity or Valuation Rate, leave the cell blank.")],
|
||||
[frappe._("Notes:")],
|
||||
[frappe._("Item Code and Warehouse should already exist.")],
|
||||
[frappe._("You can update either Quantity or Valuation Rate or both.")],
|
||||
[frappe._("If no change in either Quantity or Valuation Rate, leave the cell blank.")],
|
||||
["----"],
|
||||
["Item Code", "Warehouse", "Quantity", "Valuation Rate"]], null, this);
|
||||
return false;
|
||||
@@ -98,7 +98,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
|
||||
|
||||
// upload
|
||||
wn.upload.make({
|
||||
frappe.upload.make({
|
||||
parent: $wrapper,
|
||||
args: {
|
||||
method: 'erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.upload'
|
||||
@@ -120,9 +120,9 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
show_download_reconciliation_data: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.reconciliation_json) {
|
||||
this.frm.add_custom_button(wn._("Download Reconcilation Data"), function() {
|
||||
this.title = wn._("Stock Reconcilation Data");
|
||||
wn.tools.downloadify(JSON.parse(me.frm.doc.reconciliation_json), null, this);
|
||||
this.frm.add_custom_button(frappe._("Download Reconcilation Data"), function() {
|
||||
this.title = frappe._("Stock Reconcilation Data");
|
||||
frappe.tools.downloadify(JSON.parse(me.frm.doc.reconciliation_json), null, this);
|
||||
return false;
|
||||
}, "icon-download");
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import webnotes.defaults
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
import json
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import cstr, flt, cint
|
||||
from frappe import msgprint, _
|
||||
from frappe.utils import cstr, flt, cint
|
||||
from erpnext.stock.stock_ledger import update_entries_after
|
||||
from erpnext.controllers.stock_controller import StockController
|
||||
from erpnext.stock.utils import update_bin
|
||||
@@ -87,7 +87,7 @@ class DocType(StockController):
|
||||
for msg in self.validation_messages:
|
||||
msgprint(msg)
|
||||
|
||||
raise webnotes.ValidationError
|
||||
raise frappe.ValidationError
|
||||
|
||||
def validate_item(self, item_code, row_num):
|
||||
from erpnext.stock.doctype.item.item import validate_end_of_life, \
|
||||
@@ -96,7 +96,7 @@ class DocType(StockController):
|
||||
# using try except to catch all validation msgs and display together
|
||||
|
||||
try:
|
||||
item = webnotes.doc("Item", item_code)
|
||||
item = frappe.doc("Item", item_code)
|
||||
|
||||
# end of life and stock item
|
||||
validate_end_of_life(item_code, item.end_of_life, verbose=0)
|
||||
@@ -104,7 +104,7 @@ class DocType(StockController):
|
||||
|
||||
# item should not be serialized
|
||||
if item.has_serial_no == "Yes":
|
||||
raise webnotes.ValidationError, (_("Serialized Item: '") + item_code +
|
||||
raise frappe.ValidationError, (_("Serialized Item: '") + item_code +
|
||||
_("""' can not be managed using Stock Reconciliation.\
|
||||
You can add/delete Serial No directly, \
|
||||
to modify stock of this item."""))
|
||||
@@ -128,7 +128,7 @@ class DocType(StockController):
|
||||
|
||||
data = json.loads(self.doc.reconciliation_json)
|
||||
for row_num, row in enumerate(data[data.index(self.head_row)+1:]):
|
||||
row = webnotes._dict(zip(row_template, row))
|
||||
row = frappe._dict(zip(row_template, row))
|
||||
row["row_num"] = row_num
|
||||
previous_sle = get_previous_sle({
|
||||
"item_code": row.item_code,
|
||||
@@ -140,7 +140,7 @@ class DocType(StockController):
|
||||
# check valuation rate mandatory
|
||||
if row.qty != "" and not row.valuation_rate and \
|
||||
flt(previous_sle.get("qty_after_transaction")) <= 0:
|
||||
webnotes.throw(_("As existing qty for item: ") + row.item_code +
|
||||
frappe.throw(_("As existing qty for item: ") + row.item_code +
|
||||
_(" at warehouse: ") + row.warehouse +
|
||||
_(" is less than equals to zero in the system, valuation rate is mandatory for this item"))
|
||||
|
||||
@@ -233,7 +233,7 @@ class DocType(StockController):
|
||||
|
||||
def insert_entries(self, opts, row):
|
||||
"""Insert Stock Ledger Entries"""
|
||||
args = webnotes._dict({
|
||||
args = frappe._dict({
|
||||
"doctype": "Stock Ledger Entry",
|
||||
"item_code": row.item_code,
|
||||
"warehouse": row.warehouse,
|
||||
@@ -242,7 +242,7 @@ class DocType(StockController):
|
||||
"voucher_type": self.doc.doctype,
|
||||
"voucher_no": self.doc.name,
|
||||
"company": self.doc.company,
|
||||
"stock_uom": webnotes.conn.get_value("Item", row.item_code, "stock_uom"),
|
||||
"stock_uom": frappe.conn.get_value("Item", row.item_code, "stock_uom"),
|
||||
"voucher_detail_no": row.voucher_detail_no,
|
||||
"fiscal_year": self.doc.fiscal_year,
|
||||
"is_cancelled": "No"
|
||||
@@ -257,12 +257,12 @@ class DocType(StockController):
|
||||
""" Delete Stock Ledger Entries related to this voucher
|
||||
and repost future Stock Ledger Entries"""
|
||||
|
||||
existing_entries = webnotes.conn.sql("""select distinct item_code, warehouse
|
||||
existing_entries = frappe.conn.sql("""select distinct item_code, warehouse
|
||||
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
|
||||
(self.doc.doctype, self.doc.name), as_dict=1)
|
||||
|
||||
# delete entries
|
||||
webnotes.conn.sql("""delete from `tabStock Ledger Entry`
|
||||
frappe.conn.sql("""delete from `tabStock Ledger Entry`
|
||||
where voucher_type=%s and voucher_no=%s""", (self.doc.doctype, self.doc.name))
|
||||
|
||||
# repost future entries for selected item_code, warehouse
|
||||
@@ -283,20 +283,20 @@ class DocType(StockController):
|
||||
|
||||
|
||||
def validate_expense_account(self):
|
||||
if not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
|
||||
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||
return
|
||||
|
||||
if not self.doc.expense_account:
|
||||
msgprint(_("Please enter Expense Account"), raise_exception=1)
|
||||
elif not webnotes.conn.sql("""select * from `tabStock Ledger Entry`"""):
|
||||
if webnotes.conn.get_value("Account", self.doc.expense_account,
|
||||
elif not frappe.conn.sql("""select * from `tabStock Ledger Entry`"""):
|
||||
if frappe.conn.get_value("Account", self.doc.expense_account,
|
||||
"is_pl_account") == "Yes":
|
||||
msgprint(_("""Expense Account can not be a PL Account, as this stock \
|
||||
reconciliation is an opening entry. \
|
||||
Please select 'Temporary Account (Liabilities)' or relevant account"""),
|
||||
raise_exception=1)
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def upload():
|
||||
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
|
||||
from frappe.utils.datautils import read_csv_content_from_uploaded_file
|
||||
return read_csv_content_from_uploaded_file()
|
||||
@@ -5,15 +5,15 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes, unittest
|
||||
from webnotes.utils import flt
|
||||
import frappe, unittest
|
||||
from frappe.utils import flt
|
||||
import json
|
||||
from erpnext.accounts.utils import get_fiscal_year, get_stock_and_account_difference, get_balance_on
|
||||
|
||||
|
||||
class TestStockReconciliation(unittest.TestCase):
|
||||
def test_reco_for_fifo(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
frappe.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
# [[qty, valuation_rate, posting_date,
|
||||
# posting_time, expected_stock_value, bin_qty, bin_valuation]]
|
||||
input_data = [
|
||||
@@ -37,27 +37,27 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
stock_reco = self.submit_stock_reconciliation(d[0], d[1], d[2], d[3])
|
||||
|
||||
# check stock value
|
||||
res = webnotes.conn.sql("""select stock_value from `tabStock Ledger Entry`
|
||||
res = frappe.conn.sql("""select stock_value from `tabStock Ledger Entry`
|
||||
where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC'
|
||||
and posting_date = %s and posting_time = %s order by name desc limit 1""",
|
||||
(d[2], d[3]))
|
||||
self.assertEqual(res and flt(res[0][0]) or 0, d[4])
|
||||
|
||||
# check bin qty and stock value
|
||||
bin = webnotes.conn.sql("""select actual_qty, stock_value from `tabBin`
|
||||
bin = frappe.conn.sql("""select actual_qty, stock_value from `tabBin`
|
||||
where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC'""")
|
||||
|
||||
self.assertEqual(bin and [flt(bin[0][0]), flt(bin[0][1])] or [], [d[5], d[6]])
|
||||
|
||||
# no gl entries
|
||||
gl_entries = webnotes.conn.sql("""select name from `tabGL Entry`
|
||||
gl_entries = frappe.conn.sql("""select name from `tabGL Entry`
|
||||
where voucher_type = 'Stock Reconciliation' and voucher_no = %s""",
|
||||
stock_reco.doc.name)
|
||||
self.assertFalse(gl_entries)
|
||||
|
||||
|
||||
def test_reco_for_moving_average(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
frappe.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
# [[qty, valuation_rate, posting_date,
|
||||
# posting_time, expected_stock_value, bin_qty, bin_valuation]]
|
||||
input_data = [
|
||||
@@ -82,7 +82,7 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
stock_reco = self.submit_stock_reconciliation(d[0], d[1], d[2], d[3])
|
||||
|
||||
# check stock value in sle
|
||||
res = webnotes.conn.sql("""select stock_value from `tabStock Ledger Entry`
|
||||
res = frappe.conn.sql("""select stock_value from `tabStock Ledger Entry`
|
||||
where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC'
|
||||
and posting_date = %s and posting_time = %s order by name desc limit 1""",
|
||||
(d[2], d[3]))
|
||||
@@ -90,20 +90,20 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
self.assertEqual(res and flt(res[0][0], 4) or 0, d[4])
|
||||
|
||||
# bin qty and stock value
|
||||
bin = webnotes.conn.sql("""select actual_qty, stock_value from `tabBin`
|
||||
bin = frappe.conn.sql("""select actual_qty, stock_value from `tabBin`
|
||||
where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC'""")
|
||||
|
||||
self.assertEqual(bin and [flt(bin[0][0]), flt(bin[0][1], 4)] or [],
|
||||
[flt(d[5]), flt(d[6])])
|
||||
|
||||
# no gl entries
|
||||
gl_entries = webnotes.conn.sql("""select name from `tabGL Entry`
|
||||
gl_entries = frappe.conn.sql("""select name from `tabGL Entry`
|
||||
where voucher_type = 'Stock Reconciliation' and voucher_no = %s""",
|
||||
stock_reco.doc.name)
|
||||
self.assertFalse(gl_entries)
|
||||
|
||||
def test_reco_fifo_gl_entries(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
frappe.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
|
||||
# [[qty, valuation_rate, posting_date, posting_time, stock_in_hand_debit]]
|
||||
input_data = [
|
||||
@@ -133,10 +133,10 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
stock_reco.cancel()
|
||||
self.assertFalse(get_stock_and_account_difference(["_Test Account Stock In Hand - _TC"]))
|
||||
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
frappe.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
|
||||
def test_reco_moving_average_gl_entries(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
frappe.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
|
||||
# [[qty, valuation_rate, posting_date,
|
||||
# posting_time, stock_in_hand_debit]]
|
||||
@@ -166,16 +166,16 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
stock_reco.cancel()
|
||||
self.assertFalse(get_stock_and_account_difference(["_Test Warehouse - _TC"]))
|
||||
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
frappe.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
|
||||
|
||||
def cleanup_data(self):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.conn.sql("delete from tabBin")
|
||||
webnotes.conn.sql("delete from `tabGL Entry`")
|
||||
frappe.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
frappe.conn.sql("delete from tabBin")
|
||||
frappe.conn.sql("delete from `tabGL Entry`")
|
||||
|
||||
def submit_stock_reconciliation(self, qty, rate, posting_date, posting_time):
|
||||
stock_reco = webnotes.bean([{
|
||||
stock_reco = frappe.bean([{
|
||||
"doctype": "Stock Reconciliation",
|
||||
"posting_date": posting_date,
|
||||
"posting_time": posting_time,
|
||||
@@ -193,8 +193,8 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
return stock_reco
|
||||
|
||||
def insert_existing_sle(self, valuation_method):
|
||||
webnotes.conn.set_value("Item", "_Test Item", "valuation_method", valuation_method)
|
||||
webnotes.conn.set_default("allow_negative_stock", 1)
|
||||
frappe.conn.set_value("Item", "_Test Item", "valuation_method", valuation_method)
|
||||
frappe.conn.set_default("allow_negative_stock", 1)
|
||||
|
||||
stock_entry = [
|
||||
{
|
||||
@@ -221,11 +221,11 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
},
|
||||
]
|
||||
|
||||
pr = webnotes.bean(copy=stock_entry)
|
||||
pr = frappe.bean(copy=stock_entry)
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
|
||||
pr1 = webnotes.bean(copy=stock_entry)
|
||||
pr1 = frappe.bean(copy=stock_entry)
|
||||
pr1.doc.posting_date = "2012-12-15"
|
||||
pr1.doc.posting_time = "02:00"
|
||||
pr1.doclist[1].qty = 10
|
||||
@@ -234,7 +234,7 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
pr1.insert()
|
||||
pr1.submit()
|
||||
|
||||
pr2 = webnotes.bean(copy=stock_entry)
|
||||
pr2 = frappe.bean(copy=stock_entry)
|
||||
pr2.doc.posting_date = "2012-12-25"
|
||||
pr2.doc.posting_time = "03:00"
|
||||
pr2.doc.purpose = "Material Issue"
|
||||
@@ -246,7 +246,7 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
pr2.insert()
|
||||
pr2.submit()
|
||||
|
||||
pr3 = webnotes.bean(copy=stock_entry)
|
||||
pr3 = frappe.bean(copy=stock_entry)
|
||||
pr3.doc.posting_date = "2012-12-31"
|
||||
pr3.doc.posting_time = "08:00"
|
||||
pr3.doc.purpose = "Material Issue"
|
||||
@@ -259,7 +259,7 @@ class TestStockReconciliation(unittest.TestCase):
|
||||
pr3.submit()
|
||||
|
||||
|
||||
pr4 = webnotes.bean(copy=stock_entry)
|
||||
pr4 = frappe.bean(copy=stock_entry)
|
||||
pr4.doc.posting_date = "2013-01-05"
|
||||
pr4.doc.fiscal_year = "_Test Fiscal Year 2013"
|
||||
pr4.doc.posting_time = "07:00"
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -14,7 +14,7 @@ class DocType:
|
||||
def validate(self):
|
||||
for key in ["item_naming_by", "item_group", "stock_uom",
|
||||
"allow_negative_stock"]:
|
||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||
frappe.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||
|
||||
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||
set_by_naming_series("Item", "item_code",
|
||||
@@ -24,4 +24,4 @@ class DocType:
|
||||
submitted_stock_frozen = self.doc.stock_frozen_upto_days
|
||||
if submitted_stock_frozen > stock_frozen_limit:
|
||||
self.doc.stock_frozen_upto_days = stock_frozen_limit
|
||||
webnotes.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit)
|
||||
frappe.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit)
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cstr, flt, now, cint
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
from frappe.utils import cstr, flt, now, cint
|
||||
from frappe.model import db_exists
|
||||
from frappe.model.bean import copy_doclist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
|
||||
|
||||
class DocType:
|
||||
@@ -33,14 +33,14 @@ class DocType:
|
||||
msgprint("Please Enter Conversion Factor.")
|
||||
raise Exception
|
||||
|
||||
stock_uom = webnotes.conn.sql("select stock_uom from `tabItem` where name = '%s'" % self.doc.item_code)
|
||||
stock_uom = frappe.conn.sql("select stock_uom from `tabItem` where name = '%s'" % self.doc.item_code)
|
||||
stock_uom = stock_uom and stock_uom[0][0]
|
||||
if cstr(self.doc.new_stock_uom) == cstr(stock_uom):
|
||||
msgprint("Item Master is already updated with New Stock UOM " + cstr(self.doc.new_stock_uom))
|
||||
raise Exception
|
||||
|
||||
def update_item_master(self):
|
||||
item_bean = webnotes.bean("Item", self.doc.item_code)
|
||||
item_bean = frappe.bean("Item", self.doc.item_code)
|
||||
item_bean.doc.stock_uom = self.doc.new_stock_uom
|
||||
item_bean.save()
|
||||
|
||||
@@ -49,9 +49,9 @@ class DocType:
|
||||
def update_bin(self):
|
||||
# update bin
|
||||
if flt(self.doc.conversion_factor) != flt(1):
|
||||
webnotes.conn.sql("update `tabBin` set stock_uom = '%s' , indented_qty = ifnull(indented_qty,0) * %s, ordered_qty = ifnull(ordered_qty,0) * %s, reserved_qty = ifnull(reserved_qty,0) * %s, planned_qty = ifnull(planned_qty,0) * %s, projected_qty = actual_qty + ordered_qty + indented_qty + planned_qty - reserved_qty where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.item_code) )
|
||||
frappe.conn.sql("update `tabBin` set stock_uom = '%s' , indented_qty = ifnull(indented_qty,0) * %s, ordered_qty = ifnull(ordered_qty,0) * %s, reserved_qty = ifnull(reserved_qty,0) * %s, planned_qty = ifnull(planned_qty,0) * %s, projected_qty = actual_qty + ordered_qty + indented_qty + planned_qty - reserved_qty where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.item_code) )
|
||||
else:
|
||||
webnotes.conn.sql("update `tabBin` set stock_uom = '%s' where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.item_code) )
|
||||
frappe.conn.sql("update `tabBin` set stock_uom = '%s' where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.item_code) )
|
||||
|
||||
# acknowledge user
|
||||
msgprint(" All Bins Updated Successfully.")
|
||||
@@ -61,16 +61,16 @@ class DocType:
|
||||
from erpnext.stock.stock_ledger import update_entries_after
|
||||
|
||||
if flt(self.doc.conversion_factor) != flt(1):
|
||||
webnotes.conn.sql("update `tabStock Ledger Entry` set stock_uom = '%s', actual_qty = ifnull(actual_qty,0) * '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.item_code))
|
||||
frappe.conn.sql("update `tabStock Ledger Entry` set stock_uom = '%s', actual_qty = ifnull(actual_qty,0) * '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.item_code))
|
||||
else:
|
||||
webnotes.conn.sql("update `tabStock Ledger Entry` set stock_uom = '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
||||
frappe.conn.sql("update `tabStock Ledger Entry` set stock_uom = '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
||||
|
||||
# acknowledge user
|
||||
msgprint("Stock Ledger Entries Updated Successfully.")
|
||||
|
||||
# update item valuation
|
||||
if flt(self.doc.conversion_factor) != flt(1):
|
||||
wh = webnotes.conn.sql("select name from `tabWarehouse`")
|
||||
wh = frappe.conn.sql("select name from `tabWarehouse`")
|
||||
for w in wh:
|
||||
update_entries_after({"item_code": self.doc.item_code, "warehouse": w[0]})
|
||||
|
||||
@@ -90,19 +90,19 @@ class DocType:
|
||||
|
||||
|
||||
def validate_uom_integer_type(self):
|
||||
current_is_integer = webnotes.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number")
|
||||
new_is_integer = webnotes.conn.get_value("UOM", self.doc.new_stock_uom, "must_be_whole_number")
|
||||
current_is_integer = frappe.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number")
|
||||
new_is_integer = frappe.conn.get_value("UOM", self.doc.new_stock_uom, "must_be_whole_number")
|
||||
|
||||
if current_is_integer and not new_is_integer:
|
||||
webnotes.msgprint("New UOM must be of type Whole Number", raise_exception=True)
|
||||
frappe.msgprint("New UOM must be of type Whole Number", raise_exception=True)
|
||||
|
||||
if not current_is_integer and new_is_integer:
|
||||
webnotes.msgprint("New UOM must NOT be of type Whole Number", raise_exception=True)
|
||||
frappe.msgprint("New UOM must NOT be of type Whole Number", raise_exception=True)
|
||||
|
||||
if current_is_integer and new_is_integer and cint(self.doc.conversion_factor)!=self.doc.conversion_factor:
|
||||
webnotes.msgprint("Conversion Factor cannot be fraction", raise_exception=True)
|
||||
frappe.msgprint("Conversion Factor cannot be fraction", raise_exception=True)
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_stock_uom(item_code):
|
||||
return { 'current_stock_uom': cstr(webnotes.conn.get_value('Item', item_code, 'stock_uom')) }
|
||||
return { 'current_stock_uom': cstr(frappe.conn.get_value('Item', item_code, 'stock_uom')) }
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint, validate_email_add
|
||||
from webnotes import throw, msgprint, _
|
||||
import frappe
|
||||
from frappe.utils import cint, validate_email_add
|
||||
from frappe import throw, msgprint, _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -12,7 +12,7 @@ class DocType:
|
||||
self.doclist = doclist
|
||||
|
||||
def autoname(self):
|
||||
suffix = " - " + webnotes.conn.get_value("Company", self.doc.company, "abbr")
|
||||
suffix = " - " + frappe.conn.get_value("Company", self.doc.company, "abbr")
|
||||
if not self.doc.warehouse_name.endswith(suffix):
|
||||
self.doc.name = self.doc.warehouse_name + suffix
|
||||
|
||||
@@ -24,12 +24,12 @@ class DocType:
|
||||
|
||||
def update_parent_account(self):
|
||||
if not self.doc.__islocal and (self.doc.create_account_under !=
|
||||
webnotes.conn.get_value("Warehouse", self.doc.name, "create_account_under")):
|
||||
warehouse_account = webnotes.conn.get_value("Account",
|
||||
frappe.conn.get_value("Warehouse", self.doc.name, "create_account_under")):
|
||||
warehouse_account = frappe.conn.get_value("Account",
|
||||
{"account_type": "Warehouse", "company": self.doc.company,
|
||||
"master_name": self.doc.name}, ["name", "parent_account"])
|
||||
if warehouse_account and warehouse_account[1] != self.doc.create_account_under:
|
||||
acc_bean = webnotes.bean("Account", warehouse_account[0])
|
||||
acc_bean = frappe.bean("Account", warehouse_account[0])
|
||||
acc_bean.doc.parent_account = self.doc.create_account_under
|
||||
acc_bean.save()
|
||||
|
||||
@@ -37,14 +37,14 @@ class DocType:
|
||||
self.create_account_head()
|
||||
|
||||
def create_account_head(self):
|
||||
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
|
||||
if not webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
"master_name": self.doc.name}) and not webnotes.conn.get_value("Account",
|
||||
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||
if not frappe.conn.get_value("Account", {"account_type": "Warehouse",
|
||||
"master_name": self.doc.name}) and not frappe.conn.get_value("Account",
|
||||
{"account_name": self.doc.warehouse_name}):
|
||||
if self.doc.fields.get("__islocal") or not webnotes.conn.get_value(
|
||||
if self.doc.fields.get("__islocal") or not frappe.conn.get_value(
|
||||
"Stock Ledger Entry", {"warehouse": self.doc.name}):
|
||||
self.validate_parent_account()
|
||||
ac_bean = webnotes.bean({
|
||||
ac_bean = frappe.bean({
|
||||
"doctype": "Account",
|
||||
'account_name': self.doc.warehouse_name,
|
||||
'parent_account': self.doc.create_account_under,
|
||||
@@ -61,17 +61,17 @@ class DocType:
|
||||
|
||||
def validate_parent_account(self):
|
||||
if not self.doc.create_account_under:
|
||||
parent_account = webnotes.conn.get_value("Account",
|
||||
parent_account = frappe.conn.get_value("Account",
|
||||
{"account_name": "Stock Assets", "company": self.doc.company})
|
||||
if parent_account:
|
||||
self.doc.create_account_under = parent_account
|
||||
else:
|
||||
webnotes.throw(_("Please enter account group under which account \
|
||||
frappe.throw(_("Please enter account group under which account \
|
||||
for warehouse ") + self.doc.name +_(" will be created"))
|
||||
|
||||
def on_trash(self):
|
||||
# delete bin
|
||||
bins = webnotes.conn.sql("select * from `tabBin` where warehouse = %s",
|
||||
bins = frappe.conn.sql("select * from `tabBin` where warehouse = %s",
|
||||
self.doc.name, as_dict=1)
|
||||
for d in bins:
|
||||
if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \
|
||||
@@ -79,14 +79,14 @@ class DocType:
|
||||
throw("""Warehouse: %s can not be deleted as qty exists for item: %s"""
|
||||
% (self.doc.name, d['item_code']))
|
||||
else:
|
||||
webnotes.conn.sql("delete from `tabBin` where name = %s", d['name'])
|
||||
frappe.conn.sql("delete from `tabBin` where name = %s", d['name'])
|
||||
|
||||
warehouse_account = webnotes.conn.get_value("Account",
|
||||
warehouse_account = frappe.conn.get_value("Account",
|
||||
{"account_type": "Warehouse", "master_name": self.doc.name})
|
||||
if warehouse_account:
|
||||
webnotes.delete_doc("Account", warehouse_account)
|
||||
frappe.delete_doc("Account", warehouse_account)
|
||||
|
||||
if webnotes.conn.sql("""select name from `tabStock Ledger Entry`
|
||||
if frappe.conn.sql("""select name from `tabStock Ledger Entry`
|
||||
where warehouse = %s""", self.doc.name):
|
||||
throw(_("""Warehouse can not be deleted as stock ledger entry
|
||||
exists for this warehouse."""))
|
||||
@@ -97,13 +97,13 @@ class DocType:
|
||||
new_warehouse = get_name_with_abbr(newdn, self.doc.company)
|
||||
|
||||
if merge:
|
||||
if not webnotes.conn.exists("Warehouse", new_warehouse):
|
||||
webnotes.throw(_("Warehouse ") + new_warehouse +_(" does not exists"))
|
||||
if not frappe.conn.exists("Warehouse", new_warehouse):
|
||||
frappe.throw(_("Warehouse ") + new_warehouse +_(" does not exists"))
|
||||
|
||||
if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
|
||||
webnotes.throw(_("Both Warehouse must belong to same Company"))
|
||||
if self.doc.company != frappe.conn.get_value("Warehouse", new_warehouse, "company"):
|
||||
frappe.throw(_("Both Warehouse must belong to same Company"))
|
||||
|
||||
webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
|
||||
frappe.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
|
||||
|
||||
from erpnext.accounts.utils import rename_account_for
|
||||
rename_account_for("Warehouse", olddn, newdn, merge, self.doc.company)
|
||||
@@ -116,15 +116,15 @@ class DocType:
|
||||
|
||||
def recalculate_bin_qty(self, newdn):
|
||||
from erpnext.utilities.repost_stock import repost_stock
|
||||
webnotes.conn.auto_commit_on_many_writes = 1
|
||||
webnotes.conn.set_default("allow_negative_stock", 1)
|
||||
frappe.conn.auto_commit_on_many_writes = 1
|
||||
frappe.conn.set_default("allow_negative_stock", 1)
|
||||
|
||||
for item in webnotes.conn.sql("""select distinct item_code from (
|
||||
for item in frappe.conn.sql("""select distinct item_code from (
|
||||
select name as item_code from `tabItem` where ifnull(is_stock_item, 'Yes')='Yes'
|
||||
union
|
||||
select distinct item_code from tabBin) a"""):
|
||||
repost_stock(item[0], newdn)
|
||||
|
||||
webnotes.conn.set_default("allow_negative_stock",
|
||||
webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
|
||||
webnotes.conn.auto_commit_on_many_writes = 0
|
||||
frappe.conn.set_default("allow_negative_stock",
|
||||
frappe.conn.get_value("Stock Settings", None, "allow_negative_stock"))
|
||||
frappe.conn.auto_commit_on_many_writes = 0
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, throw
|
||||
from webnotes.utils import flt, cint, add_days
|
||||
import frappe
|
||||
from frappe import _, throw
|
||||
from frappe.utils import flt, cint, add_days
|
||||
import json
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_item_details(args):
|
||||
"""
|
||||
args = {
|
||||
@@ -31,7 +31,7 @@ def get_item_details(args):
|
||||
|
||||
if isinstance(args, basestring):
|
||||
args = json.loads(args)
|
||||
args = webnotes._dict(args)
|
||||
args = frappe._dict(args)
|
||||
|
||||
if not args.get("transaction_type"):
|
||||
args.transaction_type = "selling" if args.get("customer") else "buying"
|
||||
@@ -44,7 +44,7 @@ def get_item_details(args):
|
||||
elif not args.item_code and args.serial_no:
|
||||
args.item_code = get_item_code(serial_no=args.serial_no)
|
||||
|
||||
item_bean = webnotes.bean("Item", args.item_code)
|
||||
item_bean = frappe.bean("Item", args.item_code)
|
||||
item = item_bean.doc
|
||||
|
||||
validate_item_details(args, item)
|
||||
@@ -76,9 +76,9 @@ def get_item_details(args):
|
||||
|
||||
def get_item_code(barcode=None, serial_no=None):
|
||||
if barcode:
|
||||
item_code = webnotes.conn.get_value("Item", {"barcode": barcode})
|
||||
item_code = frappe.conn.get_value("Item", {"barcode": barcode})
|
||||
elif serial_no:
|
||||
item_code = webnotes.conn.get_value("Serial No", serial_no, "item_code")
|
||||
item_code = frappe.conn.get_value("Serial No", serial_no, "item_code")
|
||||
|
||||
if not item_code:
|
||||
throw(_("No Item found with ") + _("Barcode") if barcode else _("Serial No") +
|
||||
@@ -117,20 +117,20 @@ def validate_item_details(args, item):
|
||||
def get_basic_details(args, item_bean):
|
||||
item = item_bean.doc
|
||||
|
||||
from webnotes.defaults import get_user_default_as_list
|
||||
from frappe.defaults import get_user_default_as_list
|
||||
user_default_warehouse_list = get_user_default_as_list('warehouse')
|
||||
user_default_warehouse = user_default_warehouse_list[0] \
|
||||
if len(user_default_warehouse_list)==1 else ""
|
||||
|
||||
out = webnotes._dict({
|
||||
out = frappe._dict({
|
||||
"item_code": item.name,
|
||||
"item_name": item.item_name,
|
||||
"description": item.description_html or item.description,
|
||||
"warehouse": user_default_warehouse or args.warehouse or item.default_warehouse,
|
||||
"income_account": item.income_account or args.income_account \
|
||||
or webnotes.conn.get_value("Company", args.company, "default_income_account"),
|
||||
or frappe.conn.get_value("Company", args.company, "default_income_account"),
|
||||
"expense_account": item.expense_account or args.expense_account \
|
||||
or webnotes.conn.get_value("Company", args.company, "default_expense_account"),
|
||||
or frappe.conn.get_value("Company", args.company, "default_expense_account"),
|
||||
"cost_center": item.selling_cost_center \
|
||||
if args.transaction_type == "selling" else item.buying_cost_center,
|
||||
"batch_no": None,
|
||||
@@ -155,13 +155,13 @@ def get_basic_details(args, item_bean):
|
||||
return out
|
||||
|
||||
def get_price_list_rate(args, item_bean, out):
|
||||
meta = webnotes.get_doctype(args.doctype)
|
||||
meta = frappe.get_doctype(args.doctype)
|
||||
|
||||
if meta.get_field("currency"):
|
||||
validate_price_list(args)
|
||||
validate_conversion_rate(args, meta)
|
||||
|
||||
price_list_rate = webnotes.conn.get_value("Item Price",
|
||||
price_list_rate = frappe.conn.get_value("Item Price",
|
||||
{"price_list": args.price_list, "item_code": args.item_code}, "price_list_rate")
|
||||
|
||||
if not price_list_rate: return {}
|
||||
@@ -176,7 +176,7 @@ def get_price_list_rate(args, item_bean, out):
|
||||
|
||||
def validate_price_list(args):
|
||||
if args.get("price_list"):
|
||||
if not webnotes.conn.get_value("Price List",
|
||||
if not frappe.conn.get_value("Price List",
|
||||
{"name": args.price_list, args.transaction_type: 1, "enabled": 1}):
|
||||
throw(_("Price List is either disabled or for not ") + _(args.transaction_type))
|
||||
else:
|
||||
@@ -184,7 +184,7 @@ def validate_price_list(args):
|
||||
|
||||
def validate_conversion_rate(args, meta):
|
||||
from erpnext.setup.doctype.currency.currency import validate_conversion_rate
|
||||
from webnotes.model.meta import get_field_precision
|
||||
from frappe.model.meta import get_field_precision
|
||||
|
||||
# validate currency conversion rate
|
||||
validate_conversion_rate(args.currency, args.conversion_rate,
|
||||
@@ -192,7 +192,7 @@ def validate_conversion_rate(args, meta):
|
||||
|
||||
args.conversion_rate = flt(args.conversion_rate,
|
||||
get_field_precision(meta.get_field("conversion_rate"),
|
||||
webnotes._dict({"fields": args})))
|
||||
frappe._dict({"fields": args})))
|
||||
|
||||
# validate price list currency conversion rate
|
||||
if not args.get("price_list_currency"):
|
||||
@@ -203,10 +203,10 @@ def validate_conversion_rate(args, meta):
|
||||
|
||||
args.plc_conversion_rate = flt(args.plc_conversion_rate,
|
||||
get_field_precision(meta.get_field("plc_conversion_rate"),
|
||||
webnotes._dict({"fields": args})))
|
||||
frappe._dict({"fields": args})))
|
||||
|
||||
def get_item_discount(item_group, customer):
|
||||
parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name
|
||||
parent_item_groups = [x[0] for x in frappe.conn.sql("""SELECT parent.name
|
||||
FROM `tabItem Group` AS node, `tabItem Group` AS parent
|
||||
WHERE parent.lft <= node.lft and parent.rgt >= node.rgt and node.name = %s
|
||||
GROUP BY parent.name
|
||||
@@ -214,7 +214,7 @@ def get_item_discount(item_group, customer):
|
||||
|
||||
discount = 0
|
||||
for d in parent_item_groups:
|
||||
res = webnotes.conn.sql("""select discount, name from `tabCustomer Discount`
|
||||
res = frappe.conn.sql("""select discount, name from `tabCustomer Discount`
|
||||
where parent = %s and item_group = %s""", (customer, d))
|
||||
if res:
|
||||
discount = flt(res[0][0])
|
||||
@@ -234,7 +234,7 @@ def get_party_item_code(args, item_bean, out):
|
||||
|
||||
|
||||
def get_pos_settings_item_details(company, args, pos_settings=None):
|
||||
res = webnotes._dict()
|
||||
res = frappe._dict()
|
||||
|
||||
if not pos_settings:
|
||||
pos_settings = get_pos_settings(company)
|
||||
@@ -251,17 +251,17 @@ def get_pos_settings_item_details(company, args, pos_settings=None):
|
||||
return res
|
||||
|
||||
def get_pos_settings(company):
|
||||
pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting` where user = %s
|
||||
and company = %s""", (webnotes.session['user'], company), as_dict=1)
|
||||
pos_settings = frappe.conn.sql("""select * from `tabPOS Setting` where user = %s
|
||||
and company = %s""", (frappe.session['user'], company), as_dict=1)
|
||||
|
||||
if not pos_settings:
|
||||
pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting`
|
||||
pos_settings = frappe.conn.sql("""select * from `tabPOS Setting`
|
||||
where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
|
||||
|
||||
return pos_settings and pos_settings[0] or None
|
||||
|
||||
def get_serial_nos_by_fifo(args, item_bean):
|
||||
return "\n".join(webnotes.conn.sql_list("""select name from `tabSerial No`
|
||||
return "\n".join(frappe.conn.sql_list("""select name from `tabSerial No`
|
||||
where item_code=%(item_code)s and warehouse=%(warehouse)s and status='Available'
|
||||
order by timestamp(purchase_date, purchase_time) asc limit %(qty)s""", {
|
||||
"item_code": args.item_code,
|
||||
@@ -269,17 +269,17 @@ def get_serial_nos_by_fifo(args, item_bean):
|
||||
"qty": cint(args.qty)
|
||||
}))
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_conversion_factor(item_code, uom):
|
||||
return {"conversion_factor": webnotes.conn.get_value("UOM Conversion Detail",
|
||||
return {"conversion_factor": frappe.conn.get_value("UOM Conversion Detail",
|
||||
{"parent": item_code, "uom": uom}, "conversion_factor")}
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_projected_qty(item_code, warehouse):
|
||||
return {"projected_qty": webnotes.conn.get_value("Bin",
|
||||
return {"projected_qty": frappe.conn.get_value("Bin",
|
||||
{"item_code": item_code, "warehouse": warehouse}, "projected_qty")}
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_available_qty(item_code, warehouse):
|
||||
return webnotes.conn.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
|
||||
return frappe.conn.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
|
||||
["projected_qty", "actual_qty"], as_dict=True) or {}
|
||||
@@ -2,10 +2,10 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
wn.pages['stock-ageing'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
frappe.pages['stock-ageing'].onload = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: wn._('Stock Ageing'),
|
||||
title: frappe._('Stock Ageing'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
@@ -16,12 +16,12 @@ wn.pages['stock-ageing'].onload = function(wrapper) {
|
||||
|
||||
}
|
||||
|
||||
wn.require("assets/erpnext/js/stock_grid_report.js");
|
||||
frappe.require("assets/erpnext/js/stock_grid_report.js");
|
||||
|
||||
erpnext.StockAgeing = erpnext.StockGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: wn._("Stock Ageing"),
|
||||
title: frappe._("Stock Ageing"),
|
||||
page: wrapper,
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
appframe: wrapper.appframe,
|
||||
@@ -30,37 +30,37 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
|
||||
},
|
||||
setup_columns: function() {
|
||||
this.columns = [
|
||||
{id: "name", name: wn._("Item"), field: "name", width: 300,
|
||||
{id: "name", name: frappe._("Item"), field: "name", width: 300,
|
||||
link_formatter: {
|
||||
open_btn: true,
|
||||
doctype: '"Item"'
|
||||
}},
|
||||
{id: "item_name", name: wn._("Item Name"), field: "item_name",
|
||||
{id: "item_name", name: frappe._("Item Name"), field: "item_name",
|
||||
width: 100, formatter: this.text_formatter},
|
||||
{id: "description", name: wn._("Description"), field: "description",
|
||||
{id: "description", name: frappe._("Description"), field: "description",
|
||||
width: 200, formatter: this.text_formatter},
|
||||
{id: "brand", name: wn._("Brand"), field: "brand", width: 100},
|
||||
{id: "average_age", name: wn._("Average Age"), field: "average_age",
|
||||
{id: "brand", name: frappe._("Brand"), field: "brand", width: 100},
|
||||
{id: "average_age", name: frappe._("Average Age"), field: "average_age",
|
||||
formatter: this.currency_formatter},
|
||||
{id: "earliest", name: wn._("Earliest"), field: "earliest",
|
||||
{id: "earliest", name: frappe._("Earliest"), field: "earliest",
|
||||
formatter: this.currency_formatter},
|
||||
{id: "latest", name: wn._("Latest"), field: "latest",
|
||||
{id: "latest", name: frappe._("Latest"), field: "latest",
|
||||
formatter: this.currency_formatter},
|
||||
{id: "stock_uom", name: "UOM", field: "stock_uom", width: 100},
|
||||
];
|
||||
},
|
||||
filters: [
|
||||
{fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse",
|
||||
{fieldtype:"Select", label: frappe._("Warehouse"), link:"Warehouse",
|
||||
default_value: "Select Warehouse..."},
|
||||
{fieldtype:"Select", label: wn._("Brand"), link:"Brand",
|
||||
{fieldtype:"Select", label: frappe._("Brand"), link:"Brand",
|
||||
default_value: "Select Brand...", filter: function(val, item, opts) {
|
||||
return val == opts.default_value || item.brand == val;
|
||||
}, link_formatter: {filter_input: "brand"}},
|
||||
{fieldtype:"Select", label: wn._("Plot By"),
|
||||
{fieldtype:"Select", label: frappe._("Plot By"),
|
||||
options: ["Average Age", "Earliest", "Latest"]},
|
||||
{fieldtype:"Date", label: wn._("To Date")},
|
||||
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: wn._("Reset Filters")}
|
||||
{fieldtype:"Date", label: frappe._("To Date")},
|
||||
{fieldtype:"Button", label: frappe._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: frappe._("Reset Filters")}
|
||||
],
|
||||
setup_filters: function() {
|
||||
var me = this;
|
||||
@@ -76,7 +76,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
|
||||
var me = this;
|
||||
|
||||
if(!this.data) {
|
||||
me._data = wn.report_dump.data["Item"];
|
||||
me._data = frappe.report_dump.data["Item"];
|
||||
me.item_by_name = me.make_name_map(me._data);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
|
||||
prepare_balances: function() {
|
||||
var me = this;
|
||||
var to_date = dateutil.str_to_obj(this.to_date);
|
||||
var data = wn.report_dump.data["Stock Ledger Entry"];
|
||||
var data = frappe.report_dump.data["Stock Ledger Entry"];
|
||||
|
||||
this.item_warehouse = {};
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
wn.pages['stock-analytics'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
frappe.pages['stock-analytics'].onload = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: wn._('Stock Analytics'),
|
||||
title: frappe._('Stock Analytics'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
@@ -16,4 +16,4 @@ wn.pages['stock-analytics'].onload = function(wrapper) {
|
||||
|
||||
}
|
||||
|
||||
wn.require("assets/erpnext/js/stock_analytics.js");
|
||||
frappe.require("assets/erpnext/js/stock_analytics.js");
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.require("assets/erpnext/js/stock_analytics.js");
|
||||
frappe.require("assets/erpnext/js/stock_analytics.js");
|
||||
|
||||
wn.pages['stock-balance'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
frappe.pages['stock-balance'].onload = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: wn._('Stock Balance'),
|
||||
title: frappe._('Stock Balance'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
@@ -20,58 +20,58 @@ wn.pages['stock-balance'].onload = function(wrapper) {
|
||||
erpnext.StockBalance = erpnext.StockAnalytics.extend({
|
||||
init: function(wrapper) {
|
||||
this._super(wrapper, {
|
||||
title: wn._("Stock Balance"),
|
||||
title: frappe._("Stock Balance"),
|
||||
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand",
|
||||
"Stock Entry", "Project", "Serial No"],
|
||||
});
|
||||
},
|
||||
setup_columns: function() {
|
||||
this.columns = [
|
||||
{id: "name", name: wn._("Item"), field: "name", width: 300,
|
||||
{id: "name", name: frappe._("Item"), field: "name", width: 300,
|
||||
formatter: this.tree_formatter},
|
||||
{id: "item_name", name: wn._("Item Name"), field: "item_name", width: 100},
|
||||
{id: "description", name: wn._("Description"), field: "description", width: 200,
|
||||
{id: "item_name", name: frappe._("Item Name"), field: "item_name", width: 100},
|
||||
{id: "description", name: frappe._("Description"), field: "description", width: 200,
|
||||
formatter: this.text_formatter},
|
||||
{id: "brand", name: wn._("Brand"), field: "brand", width: 100},
|
||||
{id: "stock_uom", name: wn._("UOM"), field: "stock_uom", width: 100},
|
||||
{id: "opening_qty", name: wn._("Opening Qty"), field: "opening_qty", width: 100,
|
||||
{id: "brand", name: frappe._("Brand"), field: "brand", width: 100},
|
||||
{id: "stock_uom", name: frappe._("UOM"), field: "stock_uom", width: 100},
|
||||
{id: "opening_qty", name: frappe._("Opening Qty"), field: "opening_qty", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "inflow_qty", name: wn._("In Qty"), field: "inflow_qty", width: 100,
|
||||
{id: "inflow_qty", name: frappe._("In Qty"), field: "inflow_qty", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "outflow_qty", name: wn._("Out Qty"), field: "outflow_qty", width: 100,
|
||||
{id: "outflow_qty", name: frappe._("Out Qty"), field: "outflow_qty", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "closing_qty", name: wn._("Closing Qty"), field: "closing_qty", width: 100,
|
||||
{id: "closing_qty", name: frappe._("Closing Qty"), field: "closing_qty", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
|
||||
{id: "opening_value", name: wn._("Opening Value"), field: "opening_value", width: 100,
|
||||
{id: "opening_value", name: frappe._("Opening Value"), field: "opening_value", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "inflow_value", name: wn._("In Value"), field: "inflow_value", width: 100,
|
||||
{id: "inflow_value", name: frappe._("In Value"), field: "inflow_value", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "outflow_value", name: wn._("Out Value"), field: "outflow_value", width: 100,
|
||||
{id: "outflow_value", name: frappe._("Out Value"), field: "outflow_value", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "closing_value", name: wn._("Closing Value"), field: "closing_value", width: 100,
|
||||
{id: "closing_value", name: frappe._("Closing Value"), field: "closing_value", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
];
|
||||
},
|
||||
|
||||
filters: [
|
||||
{fieldtype:"Select", label: wn._("Brand"), link:"Brand",
|
||||
{fieldtype:"Select", label: frappe._("Brand"), link:"Brand",
|
||||
default_value: "Select Brand...", filter: function(val, item, opts) {
|
||||
return val == opts.default_value || item.brand == val || item._show;
|
||||
}, link_formatter: {filter_input: "brand"}},
|
||||
{fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse",
|
||||
{fieldtype:"Select", label: frappe._("Warehouse"), link:"Warehouse",
|
||||
default_value: "Select Warehouse...", filter: function(val, item, opts, me) {
|
||||
return me.apply_zero_filter(val, item, opts, me);
|
||||
}},
|
||||
{fieldtype:"Select", label: wn._("Project"), link:"Project",
|
||||
{fieldtype:"Select", label: frappe._("Project"), link:"Project",
|
||||
default_value: "Select Project...", filter: function(val, item, opts, me) {
|
||||
return me.apply_zero_filter(val, item, opts, me);
|
||||
}, link_formatter: {filter_input: "project"}},
|
||||
{fieldtype:"Date", label: wn._("From Date")},
|
||||
{fieldtype:"Label", label: wn._("To")},
|
||||
{fieldtype:"Date", label: wn._("To Date")},
|
||||
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: wn._("Reset Filters")}
|
||||
{fieldtype:"Date", label: frappe._("From Date")},
|
||||
{fieldtype:"Label", label: frappe._("To")},
|
||||
{fieldtype:"Date", label: frappe._("To Date")},
|
||||
{fieldtype:"Button", label: frappe._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: frappe._("Reset Filters")}
|
||||
],
|
||||
|
||||
setup_plot_check: function() {
|
||||
@@ -79,7 +79,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
|
||||
},
|
||||
|
||||
prepare_data: function() {
|
||||
this.stock_entry_map = this.make_name_map(wn.report_dump.data["Stock Entry"], "name");
|
||||
this.stock_entry_map = this.make_name_map(frappe.report_dump.data["Stock Entry"], "name");
|
||||
this._super();
|
||||
},
|
||||
|
||||
@@ -87,7 +87,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
|
||||
var me = this;
|
||||
var from_date = dateutil.str_to_obj(this.from_date);
|
||||
var to_date = dateutil.str_to_obj(this.to_date);
|
||||
var data = wn.report_dump.data["Stock Ledger Entry"];
|
||||
var data = frappe.report_dump.data["Stock Ledger Entry"];
|
||||
|
||||
this.item_warehouse = {};
|
||||
this.serialized_buying_rates = this.get_serialized_buying_rates();
|
||||
|
||||
@@ -1,250 +1,250 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt"
|
||||
|
||||
wn.module_page["Stock"] = [
|
||||
frappe.module_page["Stock"] = [
|
||||
{
|
||||
title: wn._("Documents"),
|
||||
title: frappe._("Documents"),
|
||||
top: true,
|
||||
icon: "icon-copy",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Item"),
|
||||
description: wn._("All Products or Services."),
|
||||
label: frappe._("Item"),
|
||||
description: frappe._("All Products or Services."),
|
||||
doctype: "Item"
|
||||
},
|
||||
{
|
||||
label: wn._("Material Request"),
|
||||
description: wn._("Requests for items."),
|
||||
label: frappe._("Material Request"),
|
||||
description: frappe._("Requests for items."),
|
||||
doctype: "Material Request"
|
||||
},
|
||||
{
|
||||
label: wn._("Stock Entry"),
|
||||
description: wn._("Record item movement."),
|
||||
label: frappe._("Stock Entry"),
|
||||
description: frappe._("Record item movement."),
|
||||
doctype: "Stock Entry"
|
||||
},
|
||||
{
|
||||
label: wn._("Delivery Note"),
|
||||
description: wn._("Shipments to customers."),
|
||||
label: frappe._("Delivery Note"),
|
||||
description: frappe._("Shipments to customers."),
|
||||
doctype: "Delivery Note"
|
||||
},
|
||||
{
|
||||
label: wn._("Purchase Receipt"),
|
||||
description: wn._("Goods received from Suppliers."),
|
||||
label: frappe._("Purchase Receipt"),
|
||||
description: frappe._("Goods received from Suppliers."),
|
||||
doctype: "Purchase Receipt"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Masters"),
|
||||
title: frappe._("Masters"),
|
||||
icon: "icon-book",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Serial No"),
|
||||
description: wn._("Single unit of an Item."),
|
||||
label: frappe._("Serial No"),
|
||||
description: frappe._("Single unit of an Item."),
|
||||
doctype: "Serial No"
|
||||
},
|
||||
{
|
||||
label: wn._("Batch"),
|
||||
description: wn._("Batch (lot) of an Item."),
|
||||
label: frappe._("Batch"),
|
||||
description: frappe._("Batch (lot) of an Item."),
|
||||
doctype: "Batch"
|
||||
},
|
||||
{
|
||||
label: wn._("Warehouse"),
|
||||
description: wn._("Where items are stored."),
|
||||
label: frappe._("Warehouse"),
|
||||
description: frappe._("Where items are stored."),
|
||||
doctype: "Warehouse"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Tools"),
|
||||
title: frappe._("Tools"),
|
||||
icon: "icon-wrench",
|
||||
items: [
|
||||
{
|
||||
doctype: "Stock Reconciliation",
|
||||
label: wn._("Stock Reconciliation"),
|
||||
description: wn._("Upload stock balance via csv.")
|
||||
label: frappe._("Stock Reconciliation"),
|
||||
description: frappe._("Upload stock balance via csv.")
|
||||
},
|
||||
{
|
||||
doctype: "Installation Note",
|
||||
label: wn._("Installation Note"),
|
||||
description: wn._("Installation record for a Serial No.")
|
||||
label: frappe._("Installation Note"),
|
||||
description: frappe._("Installation record for a Serial No.")
|
||||
},
|
||||
{
|
||||
label: wn._("Packing Slip"),
|
||||
label: frappe._("Packing Slip"),
|
||||
doctype: "Packing Slip",
|
||||
description: wn._("Split Delivery Note into packages.")
|
||||
description: frappe._("Split Delivery Note into packages.")
|
||||
},
|
||||
{
|
||||
doctype: "Price List",
|
||||
label: wn._("Price List"),
|
||||
description: wn._("Multiple Price list.")
|
||||
label: frappe._("Price List"),
|
||||
description: frappe._("Multiple Price list.")
|
||||
},
|
||||
{
|
||||
doctype: "Item Price",
|
||||
label: wn._("Item Price"),
|
||||
description: wn._("Multiple Item prices.")
|
||||
label: frappe._("Item Price"),
|
||||
description: frappe._("Multiple Item prices.")
|
||||
},
|
||||
{
|
||||
doctype: "Quality Inspection",
|
||||
label: wn._("Quality Inspection"),
|
||||
description: wn._("Incoming quality inspection.")
|
||||
label: frappe._("Quality Inspection"),
|
||||
description: frappe._("Incoming quality inspection.")
|
||||
},
|
||||
{
|
||||
route: "Form/Landed Cost Wizard/Landed Cost Wizard",
|
||||
label: wn._("Landed Cost Wizard"),
|
||||
description: wn._("Distribute transport overhead across items."),
|
||||
label: frappe._("Landed Cost Wizard"),
|
||||
description: frappe._("Distribute transport overhead across items."),
|
||||
doctype: "Landed Cost Wizard"
|
||||
},
|
||||
{
|
||||
route: "Form/Stock UOM Replace Utility/Stock UOM Replace Utility",
|
||||
label: wn._("UOM Replace Utility"),
|
||||
description: wn._("Change UOM for an Item."),
|
||||
label: frappe._("UOM Replace Utility"),
|
||||
description: frappe._("Change UOM for an Item."),
|
||||
doctype: "Stock UOM Replace Utility"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Setup"),
|
||||
title: frappe._("Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Stock Settings"),
|
||||
label: frappe._("Stock Settings"),
|
||||
route: "Form/Stock Settings",
|
||||
doctype: "Stock Settings",
|
||||
description: wn._("Settings for Stock Module")
|
||||
description: frappe._("Settings for Stock Module")
|
||||
},
|
||||
{
|
||||
route: "Sales Browser/Item Group",
|
||||
label: wn._("Item Group"),
|
||||
label: frappe._("Item Group"),
|
||||
doctype: "Item Group",
|
||||
description: wn._("Item classification.")
|
||||
description: frappe._("Item classification.")
|
||||
},
|
||||
{
|
||||
doctype: "UOM",
|
||||
label: wn._("Unit of Measure") + " (UOM)",
|
||||
description: wn._("e.g. Kg, Unit, Nos, m")
|
||||
label: frappe._("Unit of Measure") + " (UOM)",
|
||||
description: frappe._("e.g. Kg, Unit, Nos, m")
|
||||
},
|
||||
{
|
||||
doctype: "Brand",
|
||||
label: wn._("Brand"),
|
||||
description: wn._("Brand master.")
|
||||
label: frappe._("Brand"),
|
||||
description: frappe._("Brand master.")
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Main Reports"),
|
||||
title: frappe._("Main Reports"),
|
||||
right: true,
|
||||
icon: "icon-table",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Stock Ledger"),
|
||||
label: frappe._("Stock Ledger"),
|
||||
doctype: "Item",
|
||||
route: "query-report/Stock Ledger"
|
||||
},
|
||||
{
|
||||
label: wn._("Stock Balance"),
|
||||
label: frappe._("Stock Balance"),
|
||||
page: "stock-balance"
|
||||
},
|
||||
{
|
||||
label: wn._("Stock Projected Qty"),
|
||||
label: frappe._("Stock Projected Qty"),
|
||||
doctype: "Item",
|
||||
route: "query-report/Stock Projected Qty"
|
||||
},
|
||||
{
|
||||
label: wn._("Stock Ageing"),
|
||||
label: frappe._("Stock Ageing"),
|
||||
doctype: "Item",
|
||||
route: "query-report/Stock Ageing"
|
||||
},
|
||||
{
|
||||
label: wn._("Item-wise Price List Rate"),
|
||||
label: frappe._("Item-wise Price List Rate"),
|
||||
route: "Report/Item Price/Item-wise Price List Rate",
|
||||
doctype: "Item Price"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Analytics"),
|
||||
title: frappe._("Analytics"),
|
||||
right: true,
|
||||
icon: "icon-bar-chart",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Stock Analytics"),
|
||||
label: frappe._("Stock Analytics"),
|
||||
page: "stock-analytics"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Reports"),
|
||||
title: frappe._("Reports"),
|
||||
right: true,
|
||||
icon: "icon-list",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Ordered Items To Be Delivered"),
|
||||
label: frappe._("Ordered Items To Be Delivered"),
|
||||
route: "query-report/Ordered Items To Be Delivered",
|
||||
doctype: "Delivery Note"
|
||||
},
|
||||
{
|
||||
label: wn._("Purchase Order Items To Be Received"),
|
||||
label: frappe._("Purchase Order Items To Be Received"),
|
||||
route: "query-report/Purchase Order Items To Be Received",
|
||||
doctype: "Purchase Receipt"
|
||||
},
|
||||
{
|
||||
label: wn._("Item Shortage Report"),
|
||||
label: frappe._("Item Shortage Report"),
|
||||
route: "Report/Bin/Item Shortage Report",
|
||||
doctype: "Purchase Receipt"
|
||||
},
|
||||
{
|
||||
label: wn._("Serial No Service Contract Expiry"),
|
||||
label: frappe._("Serial No Service Contract Expiry"),
|
||||
route: "Report/Serial No/Serial No Service Contract Expiry",
|
||||
doctype: "Serial No"
|
||||
},
|
||||
{
|
||||
label: wn._("Serial No Status"),
|
||||
label: frappe._("Serial No Status"),
|
||||
route: "Report/Serial No/Serial No Status",
|
||||
doctype: "Serial No"
|
||||
},
|
||||
{
|
||||
label: wn._("Serial No Warranty Expiry"),
|
||||
label: frappe._("Serial No Warranty Expiry"),
|
||||
route: "Report/Serial No/Serial No Warranty Expiry",
|
||||
doctype: "Serial No"
|
||||
},
|
||||
{
|
||||
label: wn._("Purchase In Transit"),
|
||||
label: frappe._("Purchase In Transit"),
|
||||
route: "query-report/Purchase In Transit",
|
||||
doctype: "Purchase Order"
|
||||
},
|
||||
{
|
||||
label: wn._("Requested Items To Be Transferred"),
|
||||
label: frappe._("Requested Items To Be Transferred"),
|
||||
route: "query-report/Requested Items To Be Transferred",
|
||||
doctype: "Material Request"
|
||||
},
|
||||
{
|
||||
label: wn._("Batch-Wise Balance History"),
|
||||
label: frappe._("Batch-Wise Balance History"),
|
||||
route: "query-report/Batch-Wise Balance History",
|
||||
doctype: "Batch"
|
||||
},
|
||||
{
|
||||
label: wn._("Warehouse-Wise Stock Balance"),
|
||||
label: frappe._("Warehouse-Wise Stock Balance"),
|
||||
route: "query-report/Warehouse-Wise Stock Balance",
|
||||
doctype: "Warehouse"
|
||||
},
|
||||
{
|
||||
label: wn._("Item Prices"),
|
||||
label: frappe._("Item Prices"),
|
||||
route: "query-report/Item Prices",
|
||||
doctype: "Price List"
|
||||
},
|
||||
{
|
||||
label: wn._("Itemwise Recommended Reorder Level"),
|
||||
label: frappe._("Itemwise Recommended Reorder Level"),
|
||||
route: "query-report/Itemwise Recommended Reorder Level",
|
||||
doctype: "Item"
|
||||
},
|
||||
{
|
||||
label: wn._("Delivery Note Trends"),
|
||||
label: frappe._("Delivery Note Trends"),
|
||||
route: "query-report/Delivery Note Trends",
|
||||
doctype: "Delivery Note"
|
||||
},
|
||||
{
|
||||
label: wn._("Purchase Receipt Trends"),
|
||||
label: frappe._("Purchase Receipt Trends"),
|
||||
route: "query-report/Purchase Receipt Trends",
|
||||
doctype: "Purchase Receipt"
|
||||
},
|
||||
@@ -253,5 +253,5 @@ wn.module_page["Stock"] = [
|
||||
]
|
||||
|
||||
pscript['onload_stock-home'] = function(wrapper) {
|
||||
wn.views.moduleview.make(wrapper, "Stock");
|
||||
frappe.views.moduleview.make(wrapper, "Stock");
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.pages['stock-ledger'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
frappe.pages['stock-ledger'].onload = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: wn._('Stock Ledger'),
|
||||
title: frappe._('Stock Ledger'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
@@ -12,12 +12,12 @@ wn.pages['stock-ledger'].onload = function(wrapper) {
|
||||
wrapper.appframe.add_module_icon("Stock")
|
||||
}
|
||||
|
||||
wn.require("assets/erpnext/js/stock_grid_report.js");
|
||||
frappe.require("assets/erpnext/js/stock_grid_report.js");
|
||||
|
||||
erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: wn._("Stock Ledger"),
|
||||
title: frappe._("Stock Ledger"),
|
||||
page: wrapper,
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
appframe: wrapper.appframe,
|
||||
@@ -28,29 +28,29 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
setup_columns: function() {
|
||||
this.hide_balance = (this.is_default("item_code") || this.voucher_no) ? true : false;
|
||||
this.columns = [
|
||||
{id: "posting_datetime", name: wn._("Posting Date"), field: "posting_datetime", width: 120,
|
||||
{id: "posting_datetime", name: frappe._("Posting Date"), field: "posting_datetime", width: 120,
|
||||
formatter: this.date_formatter},
|
||||
{id: "item_code", name: wn._("Item Code"), field: "item_code", width: 160,
|
||||
{id: "item_code", name: frappe._("Item Code"), field: "item_code", width: 160,
|
||||
link_formatter: {
|
||||
filter_input: "item_code",
|
||||
open_btn: true,
|
||||
doctype: '"Item"',
|
||||
}},
|
||||
{id: "description", name: wn._("Description"), field: "description", width: 200,
|
||||
{id: "description", name: frappe._("Description"), field: "description", width: 200,
|
||||
formatter: this.text_formatter},
|
||||
{id: "warehouse", name: wn._("Warehouse"), field: "warehouse", width: 100,
|
||||
{id: "warehouse", name: frappe._("Warehouse"), field: "warehouse", width: 100,
|
||||
link_formatter: {filter_input: "warehouse"}},
|
||||
{id: "brand", name: wn._("Brand"), field: "brand", width: 100},
|
||||
{id: "stock_uom", name: wn._("UOM"), field: "stock_uom", width: 100},
|
||||
{id: "qty", name: wn._("Qty"), field: "qty", width: 100,
|
||||
{id: "brand", name: frappe._("Brand"), field: "brand", width: 100},
|
||||
{id: "stock_uom", name: frappe._("UOM"), field: "stock_uom", width: 100},
|
||||
{id: "qty", name: frappe._("Qty"), field: "qty", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "balance", name: wn._("Balance Qty"), field: "balance", width: 100,
|
||||
{id: "balance", name: frappe._("Balance Qty"), field: "balance", width: 100,
|
||||
formatter: this.currency_formatter,
|
||||
hidden: this.hide_balance},
|
||||
{id: "balance_value", name: wn._("Balance Value"), field: "balance_value", width: 100,
|
||||
{id: "balance_value", name: frappe._("Balance Value"), field: "balance_value", width: 100,
|
||||
formatter: this.currency_formatter, hidden: this.hide_balance},
|
||||
{id: "voucher_type", name: wn._("Voucher Type"), field: "voucher_type", width: 120},
|
||||
{id: "voucher_no", name: wn._("Voucher No"), field: "voucher_no", width: 160,
|
||||
{id: "voucher_type", name: frappe._("Voucher Type"), field: "voucher_type", width: 120},
|
||||
{id: "voucher_no", name: frappe._("Voucher No"), field: "voucher_no", width: 160,
|
||||
link_formatter: {
|
||||
filter_input: "voucher_no",
|
||||
open_btn: true,
|
||||
@@ -60,11 +60,11 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
|
||||
},
|
||||
filters: [
|
||||
{fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse",
|
||||
{fieldtype:"Select", label: frappe._("Warehouse"), link:"Warehouse",
|
||||
default_value: "Select Warehouse...", filter: function(val, item, opts) {
|
||||
return item.warehouse == val || val == opts.default_value;
|
||||
}},
|
||||
{fieldtype:"Link", label: wn._("Item Code"), link:"Item", default_value: "Select Item...",
|
||||
{fieldtype:"Link", label: frappe._("Item Code"), link:"Item", default_value: "Select Item...",
|
||||
filter: function(val, item, opts) {
|
||||
return item.item_code == val || !val;
|
||||
}},
|
||||
@@ -72,20 +72,20 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
default_value: "Select Brand...", filter: function(val, item, opts) {
|
||||
return val == opts.default_value || item.brand == val || item._show;
|
||||
}, link_formatter: {filter_input: "brand"}},
|
||||
{fieldtype:"Data", label: wn._("Voucher No"),
|
||||
{fieldtype:"Data", label: frappe._("Voucher No"),
|
||||
filter: function(val, item, opts) {
|
||||
if(!val) return true;
|
||||
return (item.voucher_no && item.voucher_no.indexOf(val)!=-1);
|
||||
}},
|
||||
{fieldtype:"Date", label: wn._("From Date"), filter: function(val, item) {
|
||||
{fieldtype:"Date", label: frappe._("From Date"), filter: function(val, item) {
|
||||
return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
|
||||
}},
|
||||
{fieldtype:"Label", label: wn._("To")},
|
||||
{fieldtype:"Date", label: wn._("To Date"), filter: function(val, item) {
|
||||
{fieldtype:"Label", label: frappe._("To")},
|
||||
{fieldtype:"Date", label: frappe._("To Date"), filter: function(val, item) {
|
||||
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
|
||||
}},
|
||||
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: wn._("Reset Filters")}
|
||||
{fieldtype:"Button", label: frappe._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: frappe._("Reset Filters")}
|
||||
],
|
||||
|
||||
setup_filters: function() {
|
||||
@@ -115,8 +115,8 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
prepare_data: function() {
|
||||
var me = this;
|
||||
if(!this.item_by_name)
|
||||
this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]);
|
||||
var data = wn.report_dump.data["Stock Ledger Entry"];
|
||||
this.item_by_name = this.make_name_map(frappe.report_dump.data["Item"]);
|
||||
var data = frappe.report_dump.data["Stock Ledger Entry"];
|
||||
var out = [];
|
||||
|
||||
var opening = {
|
||||
@@ -133,7 +133,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
}
|
||||
|
||||
// clear balance
|
||||
$.each(wn.report_dump.data["Item"], function(i, item) {
|
||||
$.each(frappe.report_dump.data["Item"], function(i, item) {
|
||||
item.balance = item.balance_value = 0.0;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.pages['stock-level'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
frappe.pages['stock-level'].onload = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: wn._('Stock Level'),
|
||||
title: frappe._('Stock Level'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
@@ -15,14 +15,14 @@ wn.pages['stock-level'].onload = function(wrapper) {
|
||||
;
|
||||
}
|
||||
|
||||
wn.require("assets/erpnext/js/stock_grid_report.js");
|
||||
frappe.require("assets/erpnext/js/stock_grid_report.js");
|
||||
|
||||
erpnext.StockLevel = erpnext.StockGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
var me = this;
|
||||
|
||||
this._super({
|
||||
title: wn._("Stock Level"),
|
||||
title: frappe._("Stock Level"),
|
||||
page: wrapper,
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
appframe: wrapper.appframe,
|
||||
@@ -31,18 +31,18 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
|
||||
});
|
||||
|
||||
this.wrapper.bind("make", function() {
|
||||
wn.utils.set_footnote(me, me.wrapper.get(0),
|
||||
frappe.utils.set_footnote(me, me.wrapper.get(0),
|
||||
"<ul> \
|
||||
<li style='font-weight: bold;'> \
|
||||
Projected Qty = Actual Qty + Planned Qty + Requested Qty \
|
||||
+ Ordered Qty - Reserved Qty </li> \
|
||||
<ul> \
|
||||
<li>"+wn._("Actual Qty: Quantity available in the warehouse.") +"</li>"+
|
||||
"<li>"+wn._("Planned Qty: Quantity, for which, Production Order has been raised,")+
|
||||
wn._("but is pending to be manufactured.")+ "</li> " +
|
||||
"<li>"+wn._("Requested Qty: Quantity requested for purchase, but not ordered.") + "</li>" +
|
||||
"<li>" + wn._("Ordered Qty: Quantity ordered for purchase, but not received.")+ "</li>" +
|
||||
"<li>" + wn._("Reserved Qty: Quantity ordered for sale, but not delivered.") + "</li>" +
|
||||
<li>"+frappe._("Actual Qty: Quantity available in the warehouse.") +"</li>"+
|
||||
"<li>"+frappe._("Planned Qty: Quantity, for which, Production Order has been raised,")+
|
||||
frappe._("but is pending to be manufactured.")+ "</li> " +
|
||||
"<li>"+frappe._("Requested Qty: Quantity requested for purchase, but not ordered.") + "</li>" +
|
||||
"<li>" + frappe._("Ordered Qty: Quantity ordered for purchase, but not received.")+ "</li>" +
|
||||
"<li>" + frappe._("Reserved Qty: Quantity ordered for sale, but not delivered.") + "</li>" +
|
||||
"</ul> \
|
||||
</ul>");
|
||||
});
|
||||
@@ -50,57 +50,57 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
|
||||
|
||||
setup_columns: function() {
|
||||
this.columns = [
|
||||
{id: "item_code", name: wn._("Item Code"), field: "item_code", width: 160,
|
||||
{id: "item_code", name: frappe._("Item Code"), field: "item_code", width: 160,
|
||||
link_formatter: {
|
||||
filter_input: "item_code",
|
||||
open_btn: true,
|
||||
doctype: '"Item"',
|
||||
}},
|
||||
{id: "item_name", name: wn._("Item Name"), field: "item_name", width: 100,
|
||||
{id: "item_name", name: frappe._("Item Name"), field: "item_name", width: 100,
|
||||
formatter: this.text_formatter},
|
||||
{id: "description", name: wn._("Description"), field: "description", width: 200,
|
||||
{id: "description", name: frappe._("Description"), field: "description", width: 200,
|
||||
formatter: this.text_formatter},
|
||||
{id: "brand", name: wn._("Brand"), field: "brand", width: 100,
|
||||
{id: "brand", name: frappe._("Brand"), field: "brand", width: 100,
|
||||
link_formatter: {filter_input: "brand"}},
|
||||
{id: "warehouse", name: wn._("Warehouse"), field: "warehouse", width: 100,
|
||||
{id: "warehouse", name: frappe._("Warehouse"), field: "warehouse", width: 100,
|
||||
link_formatter: {filter_input: "warehouse"}},
|
||||
{id: "uom", name: wn._("UOM"), field: "uom", width: 60},
|
||||
{id: "actual_qty", name: wn._("Actual Qty"),
|
||||
{id: "uom", name: frappe._("UOM"), field: "uom", width: 60},
|
||||
{id: "actual_qty", name: frappe._("Actual Qty"),
|
||||
field: "actual_qty", width: 80, formatter: this.currency_formatter},
|
||||
{id: "planned_qty", name: wn._("Planned Qty"),
|
||||
{id: "planned_qty", name: frappe._("Planned Qty"),
|
||||
field: "planned_qty", width: 80, formatter: this.currency_formatter},
|
||||
{id: "requested_qty", name: wn._("Requested Qty"),
|
||||
{id: "requested_qty", name: frappe._("Requested Qty"),
|
||||
field: "requested_qty", width: 80, formatter: this.currency_formatter},
|
||||
{id: "ordered_qty", name: wn._("Ordered Qty"),
|
||||
{id: "ordered_qty", name: frappe._("Ordered Qty"),
|
||||
field: "ordered_qty", width: 80, formatter: this.currency_formatter},
|
||||
{id: "reserved_qty", name: wn._("Reserved Qty"),
|
||||
{id: "reserved_qty", name: frappe._("Reserved Qty"),
|
||||
field: "reserved_qty", width: 80, formatter: this.currency_formatter},
|
||||
{id: "projected_qty", name: wn._("Projected Qty"),
|
||||
{id: "projected_qty", name: frappe._("Projected Qty"),
|
||||
field: "projected_qty", width: 80, formatter: this.currency_formatter},
|
||||
{id: "re_order_level", name: wn._("Re-Order Level"),
|
||||
{id: "re_order_level", name: frappe._("Re-Order Level"),
|
||||
field: "re_order_level", width: 80, formatter: this.currency_formatter},
|
||||
{id: "re_order_qty", name: wn._("Re-Order Qty"),
|
||||
{id: "re_order_qty", name: frappe._("Re-Order Qty"),
|
||||
field: "re_order_qty", width: 80, formatter: this.currency_formatter},
|
||||
];
|
||||
},
|
||||
|
||||
filters: [
|
||||
{fieldtype:"Link", label: wn._("Item Code"), link:"Item", default_value: "Select Item...",
|
||||
{fieldtype:"Link", label: frappe._("Item Code"), link:"Item", default_value: "Select Item...",
|
||||
filter: function(val, item, opts) {
|
||||
return item.item_code == val || !val;
|
||||
}},
|
||||
|
||||
{fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse",
|
||||
{fieldtype:"Select", label: frappe._("Warehouse"), link:"Warehouse",
|
||||
default_value: "Select Warehouse...", filter: function(val, item, opts) {
|
||||
return item.warehouse == val || val == opts.default_value;
|
||||
}},
|
||||
|
||||
{fieldtype:"Select", label: wn._("Brand"), link:"Brand",
|
||||
{fieldtype:"Select", label: frappe._("Brand"), link:"Brand",
|
||||
default_value: "Select Brand...", filter: function(val, item, opts) {
|
||||
return val == opts.default_value || item.brand == val;
|
||||
}},
|
||||
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: wn._("Reset Filters")}
|
||||
{fieldtype:"Button", label: frappe._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: frappe._("Reset Filters")}
|
||||
],
|
||||
|
||||
setup_filters: function() {
|
||||
@@ -134,7 +134,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
|
||||
if(!this._data) {
|
||||
this._data = [];
|
||||
this.item_warehouse_map = {};
|
||||
this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]);
|
||||
this.item_by_name = this.make_name_map(frappe.report_dump.data["Item"]);
|
||||
this.calculate_quantities();
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
|
||||
["Purchase Order Item", "ordered_qty"],
|
||||
["Sales Order Item", "reserved_qty"]],
|
||||
function(i, v) {
|
||||
$.each(wn.report_dump.data[v[0]], function(i, item) {
|
||||
$.each(frappe.report_dump.data[v[0]], function(i, item) {
|
||||
var row = me.get_row(item.item_code, item.warehouse);
|
||||
row[v[1]] += flt(item.qty);
|
||||
});
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Batch-Wise Balance History"] = {
|
||||
frappe.query_reports["Batch-Wise Balance History"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": wn._("From Date"),
|
||||
"label": frappe._("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"default": sys_defaults.year_start_date,
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": wn._("To Date"),
|
||||
"label": frappe._("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"default": wn.datetime.get_today()
|
||||
"default": frappe.datetime.get_today()
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@@ -37,19 +37,19 @@ def get_columns(filters):
|
||||
def get_conditions(filters):
|
||||
conditions = ""
|
||||
if not filters.get("from_date"):
|
||||
webnotes.msgprint("Please enter From Date", raise_exception=1)
|
||||
frappe.msgprint("Please enter From Date", raise_exception=1)
|
||||
|
||||
if filters.get("to_date"):
|
||||
conditions += " and posting_date <= '%s'" % filters["to_date"]
|
||||
else:
|
||||
webnotes.msgprint("Please enter To Date", raise_exception=1)
|
||||
frappe.msgprint("Please enter To Date", raise_exception=1)
|
||||
|
||||
return conditions
|
||||
|
||||
#get all details
|
||||
def get_stock_ledger_entries(filters):
|
||||
conditions = get_conditions(filters)
|
||||
return webnotes.conn.sql("""select item_code, batch_no, warehouse,
|
||||
return frappe.conn.sql("""select item_code, batch_no, warehouse,
|
||||
posting_date, actual_qty
|
||||
from `tabStock Ledger Entry`
|
||||
where docstatus < 2 %s order by item_code, warehouse""" %
|
||||
@@ -61,7 +61,7 @@ def get_item_warehouse_batch_map(filters):
|
||||
|
||||
for d in sle:
|
||||
iwb_map.setdefault(d.item_code, {}).setdefault(d.warehouse, {})\
|
||||
.setdefault(d.batch_no, webnotes._dict({
|
||||
.setdefault(d.batch_no, frappe._dict({
|
||||
"opening_qty": 0.0, "in_qty": 0.0, "out_qty": 0.0, "bal_qty": 0.0
|
||||
}))
|
||||
qty_dict = iwb_map[d.item_code][d.warehouse][d.batch_no]
|
||||
@@ -79,7 +79,7 @@ def get_item_warehouse_batch_map(filters):
|
||||
|
||||
def get_item_details(filters):
|
||||
item_map = {}
|
||||
for d in webnotes.conn.sql("select name, item_name, description from tabItem", as_dict=1):
|
||||
for d in frappe.conn.sql("select name, item_name, description from tabItem", as_dict=1):
|
||||
item_map.setdefault(d.name, d)
|
||||
|
||||
return item_map
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.require("assets/erpnext/js/sales_trends_filters.js");
|
||||
frappe.require("assets/erpnext/js/sales_trends_filters.js");
|
||||
|
||||
wn.query_reports["Delivery Note Trends"] = {
|
||||
frappe.query_reports["Delivery Note Trends"] = {
|
||||
filters: get_filters()
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
from erpnext.controllers.trends import get_columns,get_data
|
||||
|
||||
def execute(filters=None):
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@@ -45,7 +45,7 @@ def get_item_details():
|
||||
|
||||
item_map = {}
|
||||
|
||||
for i in webnotes.conn.sql("select name, item_name, description, \
|
||||
for i in frappe.conn.sql("select name, item_name, description, \
|
||||
stock_uom, standard_rate from tabItem \
|
||||
order by item_code", as_dict=1):
|
||||
item_map.setdefault(i.name, i)
|
||||
@@ -57,7 +57,7 @@ def get_price_list():
|
||||
|
||||
rate = {}
|
||||
|
||||
price_list = webnotes.conn.sql("""select ip.item_code, ip.buying, ip.selling,
|
||||
price_list = frappe.conn.sql("""select ip.item_code, ip.buying, ip.selling,
|
||||
concat(ip.price_list, " - ", ip.currency, " ", ip.price_list_rate) as price
|
||||
from `tabItem Price` ip, `tabPrice List` pl
|
||||
where ip.price_list=pl.name and pl.enabled=1""", as_dict=1)
|
||||
@@ -105,7 +105,7 @@ def get_last_purchase_rate():
|
||||
order by result.item_code asc, result.posting_date desc) result_wrapper
|
||||
group by item_code"""
|
||||
|
||||
for d in webnotes.conn.sql(query, as_dict=1):
|
||||
for d in frappe.conn.sql(query, as_dict=1):
|
||||
item_last_purchase_rate_map.setdefault(d.item_code, d.base_rate)
|
||||
|
||||
return item_last_purchase_rate_map
|
||||
@@ -115,7 +115,7 @@ def get_item_bom_rate():
|
||||
|
||||
item_bom_map = {}
|
||||
|
||||
for b in webnotes.conn.sql("""select item, (total_cost/quantity) as bom_rate
|
||||
for b in frappe.conn.sql("""select item, (total_cost/quantity) as bom_rate
|
||||
from `tabBOM` where is_active=1 and is_default=1""", as_dict=1):
|
||||
item_bom_map.setdefault(b.item, flt(b.bom_rate))
|
||||
|
||||
@@ -126,7 +126,7 @@ def get_valuation_rate():
|
||||
|
||||
item_val_rate_map = {}
|
||||
|
||||
for d in webnotes.conn.sql("""select item_code,
|
||||
for d in frappe.conn.sql("""select item_code,
|
||||
sum(actual_qty*valuation_rate)/sum(actual_qty) as val_rate
|
||||
from tabBin where actual_qty > 0 group by item_code""", as_dict=1):
|
||||
item_val_rate_map.setdefault(d.item_code, d.val_rate)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Itemwise Recommended Reorder Level"] = {
|
||||
frappe.query_reports["Itemwise Recommended Reorder Level"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": wn._("From Date"),
|
||||
"label": frappe._("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": sys_defaults.year_start_date
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": wn._("To Date"),
|
||||
"label": frappe._("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": get_today()
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
from webnotes.utils import getdate, flt
|
||||
import frappe
|
||||
from frappe.utils import getdate, flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
float_preceision = webnotes.conn.get_default("float_preceision")
|
||||
float_preceision = frappe.conn.get_default("float_preceision")
|
||||
|
||||
condition =get_condition(filters)
|
||||
|
||||
avg_daily_outgoing = 0
|
||||
diff = ((getdate(filters.get("to_date")) - getdate(filters.get("from_date"))).days)+1
|
||||
if diff <= 0:
|
||||
webnotes.msgprint("To Date should not be less than eual to From Date",raise_exception=1)
|
||||
frappe.msgprint("To Date should not be less than eual to From Date",raise_exception=1)
|
||||
|
||||
columns = get_columns()
|
||||
items = get_item_info()
|
||||
@@ -42,12 +42,12 @@ def get_columns():
|
||||
]
|
||||
|
||||
def get_item_info():
|
||||
return webnotes.conn.sql("""select name, item_name, description, min_order_qty,
|
||||
return frappe.conn.sql("""select name, item_name, description, min_order_qty,
|
||||
lead_time_days from tabItem""", as_dict=1)
|
||||
|
||||
def get_consumed_items(condition):
|
||||
|
||||
cn_items = webnotes.conn.sql("""select se_item.item_code,
|
||||
cn_items = frappe.conn.sql("""select se_item.item_code,
|
||||
sum(se_item.actual_qty) as 'consume_qty'
|
||||
from `tabStock Entry` se, `tabStock Entry Detail` se_item
|
||||
where se.name = se_item.parent and se.docstatus = 1
|
||||
@@ -62,12 +62,12 @@ def get_consumed_items(condition):
|
||||
|
||||
def get_delivered_items(condition):
|
||||
|
||||
dn_items = webnotes.conn.sql("""select dn_item.item_code, sum(dn_item.qty) as dn_qty
|
||||
dn_items = frappe.conn.sql("""select dn_item.item_code, sum(dn_item.qty) as dn_qty
|
||||
from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
|
||||
where dn.name = dn_item.parent and dn.docstatus = 1 %s
|
||||
group by dn_item.item_code""" % (condition), as_dict=1)
|
||||
|
||||
si_items = webnotes.conn.sql("""select si_item.item_name, sum(si_item.qty) as si_qty
|
||||
si_items = frappe.conn.sql("""select si_item.item_name, sum(si_item.qty) as si_qty
|
||||
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
||||
where si.name = si_item.parent and si.docstatus = 1 and
|
||||
ifnull(si.update_stock, 0) = 1 and ifnull(si.is_pos, 0) = 1 %s
|
||||
@@ -87,5 +87,5 @@ def get_condition(filters):
|
||||
if filters.get("from_date") and filters.get("to_date"):
|
||||
conditions += " and posting_date between '%s' and '%s'" % (filters["from_date"],filters["to_date"])
|
||||
else:
|
||||
webnotes.msgprint("Please set date in from date field",raise_exception=1)
|
||||
frappe.msgprint("Please set date in from date field",raise_exception=1)
|
||||
return conditions
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.require("assets/erpnext/js/purchase_trends_filters.js");
|
||||
frappe.require("assets/erpnext/js/purchase_trends_filters.js");
|
||||
|
||||
wn.query_reports["Purchase Receipt Trends"] = {
|
||||
frappe.query_reports["Purchase Receipt Trends"] = {
|
||||
filters: get_filters()
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
from erpnext.controllers.trends import get_columns,get_data
|
||||
|
||||
def execute(filters=None):
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Stock Ageing"] = {
|
||||
frappe.query_reports["Stock Ageing"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"label": frappe._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": wn.defaults.get_user_default("company"),
|
||||
"default": frappe.defaults.get_user_default("company"),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": wn._("To Date"),
|
||||
"label": frappe._("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": wn.datetime.get_today(),
|
||||
"default": frappe.datetime.get_today(),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"warehouse",
|
||||
"label": wn._("Warehouse"),
|
||||
"label": frappe._("Warehouse"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname":"item_code",
|
||||
"label": wn._("Item"),
|
||||
"label": frappe._("Item"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Item"
|
||||
},
|
||||
{
|
||||
"fieldname":"brand",
|
||||
"label": wn._("Brand"),
|
||||
"label": frappe._("Brand"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Brand"
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import date_diff
|
||||
import frappe
|
||||
from frappe.utils import date_diff
|
||||
|
||||
def execute(filters=None):
|
||||
|
||||
@@ -63,7 +63,7 @@ def get_fifo_queue(filters):
|
||||
return item_details
|
||||
|
||||
def get_stock_ledger_entries(filters):
|
||||
return webnotes.conn.sql("""select
|
||||
return frappe.conn.sql("""select
|
||||
item.name, item.item_name, item_group, brand, description, item.stock_uom,
|
||||
actual_qty, posting_date
|
||||
from `tabStock Ledger Entry` sle,
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Stock Ledger"] = {
|
||||
frappe.query_reports["Stock Ledger"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"label": frappe._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": wn.defaults.get_user_default("company"),
|
||||
"default": frappe.defaults.get_user_default("company"),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": wn._("From Date"),
|
||||
"label": frappe._("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": wn.datetime.add_months(wn.datetime.get_today(), -1),
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": wn._("To Date"),
|
||||
"label": frappe._("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": wn.datetime.get_today(),
|
||||
"default": frappe.datetime.get_today(),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"warehouse",
|
||||
"label": wn._("Warehouse"),
|
||||
"label": frappe._("Warehouse"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname":"item_code",
|
||||
"label": wn._("Item"),
|
||||
"label": frappe._("Item"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Item"
|
||||
},
|
||||
{
|
||||
"fieldname":"brand",
|
||||
"label": wn._("Brand"),
|
||||
"label": frappe._("Brand"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Brand"
|
||||
},
|
||||
{
|
||||
"fieldname":"voucher_no",
|
||||
"label": wn._("Voucher #"),
|
||||
"label": frappe._("Voucher #"),
|
||||
"fieldtype": "Data"
|
||||
}
|
||||
]
|
||||
@@ -53,6 +53,6 @@ wn.query_reports["Stock Ledger"] = {
|
||||
|
||||
// $(function() {
|
||||
// $(wrapper).bind("show", function() {
|
||||
// wn.query_report.load();
|
||||
// frappe.query_report.load();
|
||||
// });
|
||||
// });
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
def execute(filters=None):
|
||||
columns = get_columns()
|
||||
@@ -32,7 +32,7 @@ def get_columns():
|
||||
"Batch:Link/Batch:100", "Serial #:Link/Serial No:100", "Company:Link/Company:100"]
|
||||
|
||||
def get_stock_ledger_entries(filters):
|
||||
return webnotes.conn.sql("""select concat_ws(" ", posting_date, posting_time) as date,
|
||||
return frappe.conn.sql("""select concat_ws(" ", posting_date, posting_time) as date,
|
||||
item_code, warehouse, actual_qty, qty_after_transaction,
|
||||
stock_value, voucher_type, voucher_no, batch_no, serial_no, company
|
||||
from `tabStock Ledger Entry`
|
||||
@@ -44,7 +44,7 @@ def get_stock_ledger_entries(filters):
|
||||
|
||||
def get_item_details(filters):
|
||||
item_details = {}
|
||||
for item in webnotes.conn.sql("""select name, item_name, description, item_group,
|
||||
for item in frappe.conn.sql("""select name, item_name, description, item_group,
|
||||
brand, stock_uom from `tabItem` {item_conditions}"""\
|
||||
.format(item_conditions=get_item_conditions(filters)), filters, as_dict=1):
|
||||
item_details.setdefault(item.name, item)
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Stock Projected Qty"] = {
|
||||
frappe.query_reports["Stock Projected Qty"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"label": frappe._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company"
|
||||
},
|
||||
{
|
||||
"fieldname":"warehouse",
|
||||
"label": wn._("Warehouse"),
|
||||
"label": frappe._("Warehouse"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname":"item_code",
|
||||
"label": wn._("Item"),
|
||||
"label": frappe._("Item"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Item"
|
||||
},
|
||||
{
|
||||
"fieldname":"brand",
|
||||
"label": wn._("Brand"),
|
||||
"label": frappe._("Brand"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Brand"
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
def execute(filters=None):
|
||||
columns = get_columns()
|
||||
|
||||
data = webnotes.conn.sql("""select
|
||||
data = frappe.conn.sql("""select
|
||||
item.name, item.item_name, description, item_group, brand, warehouse, item.stock_uom,
|
||||
actual_qty, planned_qty, indented_qty, ordered_qty, reserved_qty,
|
||||
projected_qty, item.re_order_level, item.re_order_qty
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Supplier-Wise Sales Analytics"] = {
|
||||
frappe.query_reports["Supplier-Wise Sales Analytics"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"supplier",
|
||||
"label": wn._("Supplier"),
|
||||
"label": frappe._("Supplier"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Supplier",
|
||||
"width": "80"
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": wn._("From Date"),
|
||||
"label": frappe._("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"default": wn.datetime.month_start()
|
||||
"default": frappe.datetime.month_start()
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": wn._("To Date"),
|
||||
"label": frappe._("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"default": wn.datetime.month_end()
|
||||
"default": frappe.datetime.month_end()
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
columns = get_columns(filters)
|
||||
@@ -63,7 +63,7 @@ def get_consumed_details(filters):
|
||||
conditions, values = get_conditions(filters)
|
||||
consumed_details = {}
|
||||
|
||||
for d in webnotes.conn.sql("""select sle.item_code, i.item_name, i.description,
|
||||
for d in frappe.conn.sql("""select sle.item_code, i.item_name, i.description,
|
||||
i.stock_uom, sle.actual_qty, sle.stock_value_difference,
|
||||
sle.voucher_no, sle.voucher_type
|
||||
from `tabStock Ledger Entry` sle, `tabItem` i
|
||||
@@ -76,7 +76,7 @@ def get_suppliers_details(filters):
|
||||
item_supplier_map = {}
|
||||
supplier = filters.get('supplier')
|
||||
|
||||
for d in webnotes.conn.sql("""select pr.supplier, pri.item_code from
|
||||
for d in frappe.conn.sql("""select pr.supplier, pri.item_code from
|
||||
`tabPurchase Receipt` pr, `tabPurchase Receipt Item` pri
|
||||
where pr.name=pri.parent and pr.docstatus=1 and
|
||||
pri.item_code=(select name from `tabItem` where
|
||||
@@ -91,5 +91,5 @@ def get_suppliers_details(filters):
|
||||
return item_supplier_map
|
||||
|
||||
def get_material_transfer_vouchers():
|
||||
return webnotes.conn.sql_list("""select name from `tabStock Entry` where
|
||||
return frappe.conn.sql_list("""select name from `tabStock Entry` where
|
||||
purpose='Material Transfer' and docstatus=1""")
|
||||
@@ -1,21 +1,21 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Warehouse-Wise Stock Balance"] = {
|
||||
frappe.query_reports["Warehouse-Wise Stock Balance"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": wn._("From Date"),
|
||||
"label": frappe._("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"default": sys_defaults.year_start_date,
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": wn._("To Date"),
|
||||
"label": frappe._("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"default": wn.datetime.get_today()
|
||||
"default": frappe.datetime.get_today()
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@@ -37,19 +37,19 @@ def get_columns(filters):
|
||||
def get_conditions(filters):
|
||||
conditions = ""
|
||||
if not filters.get("from_date"):
|
||||
webnotes.msgprint("Please enter From Date", raise_exception=1)
|
||||
frappe.msgprint("Please enter From Date", raise_exception=1)
|
||||
|
||||
if filters.get("to_date"):
|
||||
conditions += " and posting_date <= '%s'" % filters["to_date"]
|
||||
else:
|
||||
webnotes.msgprint("Please enter To Date", raise_exception=1)
|
||||
frappe.msgprint("Please enter To Date", raise_exception=1)
|
||||
|
||||
return conditions
|
||||
|
||||
#get all details
|
||||
def get_stock_ledger_entries(filters):
|
||||
conditions = get_conditions(filters)
|
||||
return webnotes.conn.sql("""select item_code, warehouse,
|
||||
return frappe.conn.sql("""select item_code, warehouse,
|
||||
posting_date, actual_qty, company
|
||||
from `tabStock Ledger Entry`
|
||||
where docstatus < 2 %s order by item_code, warehouse""" %
|
||||
@@ -61,7 +61,7 @@ def get_item_warehouse_map(filters):
|
||||
|
||||
for d in sle:
|
||||
iwb_map.setdefault(d.company, {}).setdefault(d.item_code, {}).\
|
||||
setdefault(d.warehouse, webnotes._dict({\
|
||||
setdefault(d.warehouse, frappe._dict({\
|
||||
"opening_qty": 0.0, "in_qty": 0.0, "out_qty": 0.0, "bal_qty": 0.0
|
||||
}))
|
||||
qty_dict = iwb_map[d.company][d.item_code][d.warehouse]
|
||||
@@ -79,7 +79,7 @@ def get_item_warehouse_map(filters):
|
||||
|
||||
def get_item_details(filters):
|
||||
item_map = {}
|
||||
for d in webnotes.conn.sql("select name, item_name, description from tabItem", as_dict=1):
|
||||
for d in frappe.conn.sql("select name, item_name, description from tabItem", as_dict=1):
|
||||
item_map.setdefault(d.name, d)
|
||||
|
||||
return item_map
|
||||
@@ -2,16 +2,16 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import webnotes
|
||||
from webnotes import msgprint
|
||||
from webnotes.utils import cint, flt, cstr, now
|
||||
import frappe
|
||||
from frappe import msgprint
|
||||
from frappe.utils import cint, flt, cstr, now
|
||||
from erpnext.stock.utils import get_valuation_method
|
||||
import json
|
||||
|
||||
# future reposting
|
||||
class NegativeStockError(webnotes.ValidationError): pass
|
||||
class NegativeStockError(frappe.ValidationError): pass
|
||||
|
||||
_exceptions = webnotes.local('stockledger_exceptions')
|
||||
_exceptions = frappe.local('stockledger_exceptions')
|
||||
# _exceptions = []
|
||||
|
||||
def make_sl_entries(sl_entries, is_amended=None):
|
||||
@@ -42,21 +42,21 @@ def make_sl_entries(sl_entries, is_amended=None):
|
||||
sl_entries[0].get('voucher_no'))
|
||||
|
||||
def set_as_cancel(voucher_type, voucher_no):
|
||||
webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
|
||||
frappe.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
|
||||
modified=%s, modified_by=%s
|
||||
where voucher_no=%s and voucher_type=%s""",
|
||||
(now(), webnotes.session.user, voucher_type, voucher_no))
|
||||
(now(), frappe.session.user, voucher_type, voucher_no))
|
||||
|
||||
def make_entry(args):
|
||||
args.update({"doctype": "Stock Ledger Entry"})
|
||||
sle = webnotes.bean([args])
|
||||
sle = frappe.bean([args])
|
||||
sle.ignore_permissions = 1
|
||||
sle.insert()
|
||||
sle.submit()
|
||||
return sle.doc.name
|
||||
|
||||
def delete_cancelled_entry(voucher_type, voucher_no):
|
||||
webnotes.conn.sql("""delete from `tabStock Ledger Entry`
|
||||
frappe.conn.sql("""delete from `tabStock Ledger Entry`
|
||||
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
|
||||
|
||||
def update_entries_after(args, verbose=1):
|
||||
@@ -72,7 +72,7 @@ def update_entries_after(args, verbose=1):
|
||||
}
|
||||
"""
|
||||
if not _exceptions:
|
||||
webnotes.local.stockledger_exceptions = []
|
||||
frappe.local.stockledger_exceptions = []
|
||||
|
||||
previous_sle = get_sle_before_datetime(args)
|
||||
|
||||
@@ -89,7 +89,7 @@ def update_entries_after(args, verbose=1):
|
||||
stock_value_difference = 0.0
|
||||
|
||||
for sle in entries_to_fix:
|
||||
if sle.serial_no or not cint(webnotes.conn.get_default("allow_negative_stock")):
|
||||
if sle.serial_no or not cint(frappe.conn.get_default("allow_negative_stock")):
|
||||
# validate negative stock for serialized items, fifo valuation
|
||||
# or when negative stock is not allowed for moving average
|
||||
if not validate_negative_stock(qty_after_transaction, sle):
|
||||
@@ -115,17 +115,17 @@ def update_entries_after(args, verbose=1):
|
||||
stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in stock_queue))
|
||||
|
||||
# rounding as per precision
|
||||
from webnotes.model.meta import get_field_precision
|
||||
meta = webnotes.get_doctype("Stock Ledger Entry")
|
||||
from frappe.model.meta import get_field_precision
|
||||
meta = frappe.get_doctype("Stock Ledger Entry")
|
||||
|
||||
stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"),
|
||||
webnotes._dict({"fields": sle})))
|
||||
frappe._dict({"fields": sle})))
|
||||
|
||||
stock_value_difference = stock_value - prev_stock_value
|
||||
prev_stock_value = stock_value
|
||||
|
||||
# update current sle
|
||||
webnotes.conn.sql("""update `tabStock Ledger Entry`
|
||||
frappe.conn.sql("""update `tabStock Ledger Entry`
|
||||
set qty_after_transaction=%s, valuation_rate=%s, stock_queue=%s,
|
||||
stock_value=%s, stock_value_difference=%s where name=%s""",
|
||||
(qty_after_transaction, valuation_rate,
|
||||
@@ -135,9 +135,9 @@ def update_entries_after(args, verbose=1):
|
||||
_raise_exceptions(args, verbose)
|
||||
|
||||
# update bin
|
||||
if not webnotes.conn.exists({"doctype": "Bin", "item_code": args["item_code"],
|
||||
if not frappe.conn.exists({"doctype": "Bin", "item_code": args["item_code"],
|
||||
"warehouse": args["warehouse"]}):
|
||||
bin_wrapper = webnotes.bean([{
|
||||
bin_wrapper = frappe.bean([{
|
||||
"doctype": "Bin",
|
||||
"item_code": args["item_code"],
|
||||
"warehouse": args["warehouse"],
|
||||
@@ -145,7 +145,7 @@ def update_entries_after(args, verbose=1):
|
||||
bin_wrapper.ignore_permissions = 1
|
||||
bin_wrapper.insert()
|
||||
|
||||
webnotes.conn.sql("""update `tabBin` set valuation_rate=%s, actual_qty=%s,
|
||||
frappe.conn.sql("""update `tabBin` set valuation_rate=%s, actual_qty=%s,
|
||||
stock_value=%s,
|
||||
projected_qty = (actual_qty + indented_qty + ordered_qty + planned_qty - reserved_qty)
|
||||
where item_code=%s and warehouse=%s""", (valuation_rate, qty_after_transaction,
|
||||
@@ -165,7 +165,7 @@ def get_sle_before_datetime(args, for_update=False):
|
||||
["timestamp(posting_date, posting_time) < timestamp(%(posting_date)s, %(posting_time)s)"],
|
||||
"desc", "limit 1", for_update=for_update)
|
||||
|
||||
return sle and sle[0] or webnotes._dict()
|
||||
return sle and sle[0] or frappe._dict()
|
||||
|
||||
def get_sle_after_datetime(args, for_update=False):
|
||||
"""get Stock Ledger Entries after a particular datetime, for reposting"""
|
||||
@@ -181,7 +181,7 @@ def get_stock_ledger_entries(args, conditions=None, order="desc", limit=None, fo
|
||||
if not args.get("posting_time"):
|
||||
args["posting_time"] = "00:00"
|
||||
|
||||
return webnotes.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
return frappe.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
where item_code = %%(item_code)s
|
||||
and warehouse = %%(warehouse)s
|
||||
and ifnull(is_cancelled, 'No')='No'
|
||||
@@ -202,7 +202,7 @@ def validate_negative_stock(qty_after_transaction, sle):
|
||||
diff = qty_after_transaction + flt(sle.actual_qty)
|
||||
|
||||
if not _exceptions:
|
||||
webnotes.local.stockledger_exceptions = []
|
||||
frappe.local.stockledger_exceptions = []
|
||||
|
||||
if diff < 0 and abs(diff) > 0.0001:
|
||||
# negative stock!
|
||||
@@ -223,7 +223,7 @@ def get_serialized_values(qty_after_transaction, sle, valuation_rate):
|
||||
elif incoming_rate == 0 or flt(sle.actual_qty) < 0:
|
||||
# In case of delivery/stock issue, get average purchase rate
|
||||
# of serial nos of current entry
|
||||
incoming_rate = flt(webnotes.conn.sql("""select avg(ifnull(purchase_rate, 0))
|
||||
incoming_rate = flt(frappe.conn.sql("""select avg(ifnull(purchase_rate, 0))
|
||||
from `tabSerial No` where name in (%s)""" % (", ".join(["%s"]*len(serial_no))),
|
||||
tuple(serial_no))[0][0])
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
import frappe
|
||||
from frappe import msgprint, _
|
||||
import json
|
||||
from webnotes.utils import flt, cstr, nowdate, add_days, cint
|
||||
from webnotes.defaults import get_global_default
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
from frappe.utils import flt, cstr, nowdate, add_days, cint
|
||||
from frappe.defaults import get_global_default
|
||||
from frappe.utils.email_lib import sendmail
|
||||
|
||||
class InvalidWarehouseCompany(webnotes.ValidationError): pass
|
||||
class InvalidWarehouseCompany(frappe.ValidationError): pass
|
||||
|
||||
def get_stock_balance_on(warehouse, posting_date=None):
|
||||
if not posting_date: posting_date = nowdate()
|
||||
|
||||
stock_ledger_entries = webnotes.conn.sql("""
|
||||
stock_ledger_entries = frappe.conn.sql("""
|
||||
SELECT
|
||||
item_code, stock_value
|
||||
FROM
|
||||
@@ -31,16 +31,16 @@ def get_stock_balance_on(warehouse, posting_date=None):
|
||||
|
||||
def get_latest_stock_balance():
|
||||
bin_map = {}
|
||||
for d in webnotes.conn.sql("""SELECT item_code, warehouse, stock_value as stock_value
|
||||
for d in frappe.conn.sql("""SELECT item_code, warehouse, stock_value as stock_value
|
||||
FROM tabBin""", as_dict=1):
|
||||
bin_map.setdefault(d.warehouse, {}).setdefault(d.item_code, flt(d.stock_value))
|
||||
|
||||
return bin_map
|
||||
|
||||
def get_bin(item_code, warehouse):
|
||||
bin = webnotes.conn.get_value("Bin", {"item_code": item_code, "warehouse": warehouse})
|
||||
bin = frappe.conn.get_value("Bin", {"item_code": item_code, "warehouse": warehouse})
|
||||
if not bin:
|
||||
bin_wrapper = webnotes.bean([{
|
||||
bin_wrapper = frappe.bean([{
|
||||
"doctype": "Bin",
|
||||
"item_code": item_code,
|
||||
"warehouse": warehouse,
|
||||
@@ -49,12 +49,12 @@ def get_bin(item_code, warehouse):
|
||||
bin_wrapper.insert()
|
||||
bin_obj = bin_wrapper.make_controller()
|
||||
else:
|
||||
from webnotes.model.code import get_obj
|
||||
from frappe.model.code import get_obj
|
||||
bin_obj = get_obj('Bin', bin)
|
||||
return bin_obj
|
||||
|
||||
def update_bin(args):
|
||||
is_stock_item = webnotes.conn.get_value('Item', args.get("item_code"), 'is_stock_item')
|
||||
is_stock_item = frappe.conn.get_value('Item', args.get("item_code"), 'is_stock_item')
|
||||
if is_stock_item == 'Yes':
|
||||
bin = get_bin(args.get("item_code"), args.get("warehouse"))
|
||||
bin.update_stock(args)
|
||||
@@ -71,7 +71,7 @@ def get_incoming_rate(args):
|
||||
if args.get("serial_no"):
|
||||
in_rate = get_avg_purchase_rate(args.get("serial_no"))
|
||||
elif args.get("bom_no"):
|
||||
result = webnotes.conn.sql("""select ifnull(total_cost, 0) / ifnull(quantity, 1)
|
||||
result = frappe.conn.sql("""select ifnull(total_cost, 0) / ifnull(quantity, 1)
|
||||
from `tabBOM` where name = %s and docstatus=1 and is_active=1""", args.get("bom_no"))
|
||||
in_rate = result and flt(result[0][0]) or 0
|
||||
else:
|
||||
@@ -91,13 +91,13 @@ def get_avg_purchase_rate(serial_nos):
|
||||
"""get average value of serial numbers"""
|
||||
|
||||
serial_nos = get_valid_serial_nos(serial_nos)
|
||||
return flt(webnotes.conn.sql("""select avg(ifnull(purchase_rate, 0)) from `tabSerial No`
|
||||
return flt(frappe.conn.sql("""select avg(ifnull(purchase_rate, 0)) from `tabSerial No`
|
||||
where name in (%s)""" % ", ".join(["%s"] * len(serial_nos)),
|
||||
tuple(serial_nos))[0][0])
|
||||
|
||||
def get_valuation_method(item_code):
|
||||
"""get valuation method from item or default"""
|
||||
val_method = webnotes.conn.get_value('Item', item_code, 'valuation_method')
|
||||
val_method = frappe.conn.get_value('Item', item_code, 'valuation_method')
|
||||
if not val_method:
|
||||
val_method = get_global_default('valuation_method') or "FIFO"
|
||||
return val_method
|
||||
@@ -148,9 +148,9 @@ def get_valid_serial_nos(sr_nos, qty=0, item_code=''):
|
||||
return valid_serial_nos
|
||||
|
||||
def validate_warehouse_company(warehouse, company):
|
||||
warehouse_company = webnotes.conn.get_value("Warehouse", warehouse, "company")
|
||||
warehouse_company = frappe.conn.get_value("Warehouse", warehouse, "company")
|
||||
if warehouse_company and warehouse_company != company:
|
||||
webnotes.msgprint(_("Warehouse does not belong to company.") + " (" + \
|
||||
frappe.msgprint(_("Warehouse does not belong to company.") + " (" + \
|
||||
warehouse + ", " + company +")", raise_exception=InvalidWarehouseCompany)
|
||||
|
||||
def get_sales_bom_buying_amount(item_code, warehouse, voucher_type, voucher_no, voucher_detail_no,
|
||||
@@ -181,12 +181,12 @@ def get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries):
|
||||
|
||||
def reorder_item():
|
||||
""" Reorder item if stock reaches reorder level"""
|
||||
if getattr(webnotes.local, "auto_indent", None) is None:
|
||||
webnotes.local.auto_indent = cint(webnotes.conn.get_value('Stock Settings', None, 'auto_indent'))
|
||||
if getattr(frappe.local, "auto_indent", None) is None:
|
||||
frappe.local.auto_indent = cint(frappe.conn.get_value('Stock Settings', None, 'auto_indent'))
|
||||
|
||||
if webnotes.local.auto_indent:
|
||||
if frappe.local.auto_indent:
|
||||
material_requests = {}
|
||||
bin_list = webnotes.conn.sql("""select item_code, warehouse, projected_qty
|
||||
bin_list = frappe.conn.sql("""select item_code, warehouse, projected_qty
|
||||
from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != ''
|
||||
and exists (select name from `tabItem`
|
||||
where `tabItem`.name = `tabBin`.item_code and
|
||||
@@ -194,14 +194,14 @@ def reorder_item():
|
||||
(ifnull(end_of_life, '')='' or end_of_life > now()))""", as_dict=True)
|
||||
for bin in bin_list:
|
||||
#check if re-order is required
|
||||
item_reorder = webnotes.conn.get("Item Reorder",
|
||||
item_reorder = frappe.conn.get("Item Reorder",
|
||||
{"parent": bin.item_code, "warehouse": bin.warehouse})
|
||||
if item_reorder:
|
||||
reorder_level = item_reorder.warehouse_reorder_level
|
||||
reorder_qty = item_reorder.warehouse_reorder_qty
|
||||
material_request_type = item_reorder.material_request_type or "Purchase"
|
||||
else:
|
||||
reorder_level, reorder_qty = webnotes.conn.get_value("Item", bin.item_code,
|
||||
reorder_level, reorder_qty = frappe.conn.get_value("Item", bin.item_code,
|
||||
["re_order_level", "re_order_qty"])
|
||||
material_request_type = "Purchase"
|
||||
|
||||
@@ -209,12 +209,12 @@ def reorder_item():
|
||||
if flt(reorder_level) - flt(bin.projected_qty) > flt(reorder_qty):
|
||||
reorder_qty = flt(reorder_level) - flt(bin.projected_qty)
|
||||
|
||||
company = webnotes.conn.get_value("Warehouse", bin.warehouse, "company") or \
|
||||
webnotes.defaults.get_defaults()["company"] or \
|
||||
webnotes.conn.sql("""select name from tabCompany limit 1""")[0][0]
|
||||
company = frappe.conn.get_value("Warehouse", bin.warehouse, "company") or \
|
||||
frappe.defaults.get_defaults()["company"] or \
|
||||
frappe.conn.sql("""select name from tabCompany limit 1""")[0][0]
|
||||
|
||||
material_requests.setdefault(material_request_type, webnotes._dict()).setdefault(
|
||||
company, []).append(webnotes._dict({
|
||||
material_requests.setdefault(material_request_type, frappe._dict()).setdefault(
|
||||
company, []).append(frappe._dict({
|
||||
"item_code": bin.item_code,
|
||||
"warehouse": bin.warehouse,
|
||||
"reorder_qty": reorder_qty
|
||||
@@ -226,7 +226,7 @@ def reorder_item():
|
||||
def create_material_request(material_requests):
|
||||
""" Create indent on reaching reorder level """
|
||||
mr_list = []
|
||||
defaults = webnotes.defaults.get_defaults()
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
exceptions_list = []
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
current_fiscal_year = get_fiscal_year(nowdate())[0] or defaults.fiscal_year
|
||||
@@ -246,7 +246,7 @@ def create_material_request(material_requests):
|
||||
}]
|
||||
|
||||
for d in items:
|
||||
item = webnotes.doc("Item", d.item_code)
|
||||
item = frappe.doc("Item", d.item_code)
|
||||
mr.append({
|
||||
"doctype": "Material Request Item",
|
||||
"parenttype": "Material Request",
|
||||
@@ -262,24 +262,24 @@ def create_material_request(material_requests):
|
||||
"brand": item.brand,
|
||||
})
|
||||
|
||||
mr_bean = webnotes.bean(mr)
|
||||
mr_bean = frappe.bean(mr)
|
||||
mr_bean.insert()
|
||||
mr_bean.submit()
|
||||
mr_list.append(mr_bean)
|
||||
|
||||
except:
|
||||
if webnotes.local.message_log:
|
||||
exceptions_list.append([] + webnotes.local.message_log)
|
||||
webnotes.local.message_log = []
|
||||
if frappe.local.message_log:
|
||||
exceptions_list.append([] + frappe.local.message_log)
|
||||
frappe.local.message_log = []
|
||||
else:
|
||||
exceptions_list.append(webnotes.get_traceback())
|
||||
exceptions_list.append(frappe.get_traceback())
|
||||
|
||||
if mr_list:
|
||||
if getattr(webnotes.local, "reorder_email_notify", None) is None:
|
||||
webnotes.local.reorder_email_notify = cint(webnotes.conn.get_value('Stock Settings', None,
|
||||
if getattr(frappe.local, "reorder_email_notify", None) is None:
|
||||
frappe.local.reorder_email_notify = cint(frappe.conn.get_value('Stock Settings', None,
|
||||
'reorder_email_notify'))
|
||||
|
||||
if(webnotes.local.reorder_email_notify):
|
||||
if(frappe.local.reorder_email_notify):
|
||||
send_email_notification(mr_list)
|
||||
|
||||
if exceptions_list:
|
||||
@@ -288,7 +288,7 @@ def create_material_request(material_requests):
|
||||
def send_email_notification(mr_list):
|
||||
""" Notify user about auto creation of indent"""
|
||||
|
||||
email_list = webnotes.conn.sql_list("""select distinct r.parent
|
||||
email_list = frappe.conn.sql_list("""select distinct r.parent
|
||||
from tabUserRole r, tabProfile p
|
||||
where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
|
||||
and r.role in ('Purchase Manager','Material Manager')
|
||||
@@ -320,5 +320,5 @@ def notify_errors(exceptions_list):
|
||||
Regards,
|
||||
Administrator""" % ("\n\n".join(["\n".join(msg) for msg in exceptions_list]),)
|
||||
|
||||
from webnotes.profile import get_system_managers
|
||||
from frappe.profile import get_system_managers
|
||||
sendmail(get_system_managers(), subject=subject, msg=msg)
|
||||
|
||||
Reference in New Issue
Block a user