Merge branch 'develop'
This commit is contained in:
commit
1a804e2217
@ -1,2 +1,2 @@
|
||||
from __future__ import unicode_literals
|
||||
__version__ = '5.0.8'
|
||||
__version__ = '5.0.9'
|
||||
|
@ -10,8 +10,8 @@ from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class GLEntry(Document):
|
||||
|
||||
def validate(self):
|
||||
self.flags.ignore_submit_comment = True
|
||||
self.check_mandatory()
|
||||
self.pl_must_have_cost_center()
|
||||
self.validate_posting_date()
|
||||
|
@ -98,7 +98,7 @@ class GrossProfitGenerator(object):
|
||||
|
||||
row.base_amount = flt(row.base_net_amount)
|
||||
|
||||
sales_boms = self.sales_boms.get(row.parenttype, {}).get(row.name, frappe._dict())
|
||||
sales_boms = self.sales_boms.get(row.parenttype, {}).get(row.parent, frappe._dict())
|
||||
|
||||
# get buying amount
|
||||
if row.item_code in sales_boms:
|
||||
@ -158,7 +158,7 @@ class GrossProfitGenerator(object):
|
||||
|
||||
def get_buying_amount_from_sales_bom(self, row, sales_bom):
|
||||
buying_amount = 0.0
|
||||
for bom_item in sales_bom[row.item_code]:
|
||||
for bom_item in sales_bom:
|
||||
if bom_item.get("parent_detail_docname")==row.item_row:
|
||||
buying_amount += self.get_buying_amount(row, bom_item.item_code)
|
||||
|
||||
@ -174,14 +174,17 @@ class GrossProfitGenerator(object):
|
||||
return flt(row.qty) * item_rate
|
||||
|
||||
else:
|
||||
if row.dn_detail:
|
||||
row.parenttype = "Delivery Note"
|
||||
row.parent = row.delivery_note
|
||||
row.item_row = row.dn_detail
|
||||
if row.update_stock or row.dn_detail:
|
||||
if row.dn_detail:
|
||||
row.parenttype = "Delivery Note"
|
||||
row.parent = row.delivery_note
|
||||
row.item_row = row.dn_detail
|
||||
|
||||
my_sle = self.sle.get((item_code, row.warehouse))
|
||||
for i, sle in enumerate(my_sle):
|
||||
# find the stock valution rate from stock ledger entry
|
||||
print sle.voucher_type, row.parenttype, sle.voucher_no, row.parent, \
|
||||
sle.voucher_detail_no, row.item_row
|
||||
if sle.voucher_type == row.parenttype and row.parent == sle.voucher_no and \
|
||||
sle.voucher_detail_no == row.item_row:
|
||||
previous_stock_value = len(my_sle) > i+1 and \
|
||||
@ -215,7 +218,7 @@ class GrossProfitGenerator(object):
|
||||
if self.filters.to_date:
|
||||
conditions += " and posting_date <= %(to_date)s"
|
||||
|
||||
self.si_list = frappe.db.sql("""select item.parenttype, si.name,
|
||||
self.si_list = frappe.db.sql("""select item.parenttype, item.parent,
|
||||
si.posting_date, si.posting_time, si.project_name, si.update_stock,
|
||||
si.customer, si.customer_group, si.territory,
|
||||
item.item_code, item.item_name, item.description, item.warehouse,
|
||||
|
@ -80,6 +80,8 @@ def create_purchase_order(**args):
|
||||
po.company = args.company or "_Test Company"
|
||||
po.supplier = args.customer or "_Test Supplier"
|
||||
po.is_subcontracted = args.is_subcontracted or "No"
|
||||
po.currency = args.currency or frappe.db.get_value("Company", po.company, "default_currency")
|
||||
po.conversion_factor = args.conversion_factor or 1
|
||||
|
||||
po.append("items", {
|
||||
"item_code": args.item or args.item_code or "_Test Item",
|
||||
|
@ -279,7 +279,7 @@ class BuyingController(StockController):
|
||||
|
||||
def set_qty_as_per_stock_uom(self):
|
||||
for d in self.get("items"):
|
||||
if d.meta.get_field("stock_qty") and not d.stock_qty:
|
||||
if d.meta.get_field("stock_qty"):
|
||||
if not d.conversion_factor:
|
||||
frappe.throw(_("Row {0}: Conversion Factor is mandatory").format(d.idx))
|
||||
d.stock_qty = flt(d.qty) * flt(d.conversion_factor)
|
||||
|
@ -92,7 +92,7 @@ def unsubscribe(email, name):
|
||||
return
|
||||
|
||||
subs_id = frappe.db.get_value("Newsletter List Subscriber", {"email": email, "newsletter_list": name})
|
||||
if name:
|
||||
if subs_id:
|
||||
subscriber = frappe.get_doc("Newsletter List Subscriber", subs_id)
|
||||
subscriber.unsubscribed = 1
|
||||
subscriber.save(ignore_permissions=True)
|
||||
|
@ -9,7 +9,16 @@ from urllib import unquote
|
||||
|
||||
class TestNewsletter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
frappe.db.sql("update `tabNewsletter List Subscriber` set unsubscribed = 0")
|
||||
if not frappe.get_all("Newsletter List Subscriber"):
|
||||
for email in ["test_subscriber1@example.com", "test_subscriber2@example.com",
|
||||
"test_subscriber3@example.com"]:
|
||||
frappe.get_doc({
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": email,
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
}).insert()
|
||||
else:
|
||||
frappe.db.sql("update `tabNewsletter List Subscriber` set unsubscribed = 0")
|
||||
|
||||
def test_send(self):
|
||||
self.send_newsletter()
|
||||
@ -39,6 +48,4 @@ class TestNewsletter(unittest.TestCase):
|
||||
|
||||
newsletter.send_emails()
|
||||
|
||||
|
||||
|
||||
test_dependencies = ["Newsletter List"]
|
||||
|
@ -6,8 +6,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
# test_records = frappe.get_test_records('Newletter List')
|
||||
|
||||
class TestNewletterList(unittest.TestCase):
|
||||
def test_import(self):
|
||||
new_list = frappe.get_doc({
|
||||
@ -15,13 +13,13 @@ class TestNewletterList(unittest.TestCase):
|
||||
"title": "_Test Newsletter List 1"
|
||||
}).insert()
|
||||
|
||||
n_leads = frappe.db.count("Lead")
|
||||
|
||||
n_leads = frappe.db.sql("select count(distinct email_id) from `tabLead`")[0][0]
|
||||
|
||||
added = new_list.import_from("Lead")
|
||||
|
||||
self.assertEquals(added, n_leads)
|
||||
|
||||
frappe.delete_doc("Newsletter List", new_list.name)
|
||||
def tearDown(self):
|
||||
frappe.delete_doc("Newsletter List", "_Test Newsletter List 1")
|
||||
|
||||
test_dependencies = ["Lead"]
|
||||
|
||||
|
@ -2,20 +2,5 @@
|
||||
{
|
||||
"doctype": "Newsletter List",
|
||||
"title": "_Test Newsletter List"
|
||||
},
|
||||
{
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": "test_subscriber1@example.com",
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
},
|
||||
{
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": "test_subscriber2@example.com",
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
},
|
||||
{
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": "test_subscriber3@example.com",
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
}
|
||||
]
|
||||
|
@ -10,4 +10,4 @@ class NewsletterListSubscriber(Document):
|
||||
pass
|
||||
|
||||
def after_doctype_insert():
|
||||
frappe.db.add_unique("Newsletter List Subscriber", ("name", "email"))
|
||||
frappe.db.add_unique("Newsletter List Subscriber", ("newsletter_list", "email"))
|
||||
|
@ -5,7 +5,7 @@ app_publisher = "Frappe Technologies Pvt. Ltd. and Contributors"
|
||||
app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations"
|
||||
app_icon = "icon-th"
|
||||
app_color = "#e74c3c"
|
||||
app_version = "5.0.8"
|
||||
app_version = "5.0.9"
|
||||
|
||||
error_report_email = "support@erpnext.com"
|
||||
|
||||
|
@ -12,6 +12,9 @@ class TestSalarySlip(unittest.TestCase):
|
||||
def setUp(self):
|
||||
frappe.db.sql("""delete from `tabLeave Application`""")
|
||||
frappe.db.sql("""delete from `tabSalary Slip`""")
|
||||
|
||||
frappe.db.set_value("Holiday List", "_Test Holiday List", "is_default", 1)
|
||||
|
||||
from erpnext.hr.doctype.leave_application.test_leave_application import _test_records as leave_applications
|
||||
la = frappe.copy_doc(leave_applications[2])
|
||||
la.insert()
|
||||
@ -26,6 +29,7 @@ class TestSalarySlip(unittest.TestCase):
|
||||
frappe.db.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 1)
|
||||
ss = frappe.copy_doc(test_records[0])
|
||||
ss.insert()
|
||||
|
||||
self.assertEquals(ss.total_days_in_month, 31)
|
||||
self.assertEquals(ss.payment_days, 30)
|
||||
self.assertEquals(ss.earnings[0].e_modified_amount, 14516.13)
|
||||
@ -36,8 +40,10 @@ class TestSalarySlip(unittest.TestCase):
|
||||
self.assertEquals(ss.net_pay, 14867.74)
|
||||
|
||||
def test_salary_slip_with_holidays_excluded(self):
|
||||
frappe.db.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 0)
|
||||
ss = frappe.copy_doc(test_records[0])
|
||||
ss.insert()
|
||||
|
||||
self.assertEquals(ss.total_days_in_month, 30)
|
||||
self.assertEquals(ss.payment_days, 29)
|
||||
self.assertEquals(ss.earnings[0].e_modified_amount, 14500)
|
||||
@ -102,6 +108,6 @@ class TestSalarySlip(unittest.TestCase):
|
||||
|
||||
return salary_slip
|
||||
|
||||
test_dependencies = ["Leave Application"]
|
||||
test_dependencies = ["Leave Application", "Holiday List"]
|
||||
|
||||
test_records = frappe.get_test_records('Salary Slip')
|
||||
|
@ -130,10 +130,9 @@ class TestProductionOrder(unittest.TestCase):
|
||||
prod_order = make_prod_order_test_record(item="_Test FG Item 2",
|
||||
planned_start_date="2014-11-25 00:00:00", qty=1, do_not_save=True)
|
||||
prod_order.set_production_order_operations()
|
||||
prod_order.save()
|
||||
cost = prod_order.planned_operating_cost
|
||||
prod_order.qty = 2
|
||||
prod_order.save()
|
||||
prod_order.set_production_order_operations()
|
||||
self.assertEqual(prod_order.planned_operating_cost, cost*2)
|
||||
|
||||
def make_prod_order_test_record(**args):
|
||||
|
@ -34,7 +34,9 @@ class TestCustomer(unittest.TestCase):
|
||||
|
||||
make_test_records("Address")
|
||||
make_test_records("Contact")
|
||||
|
||||
frappe.db.set_value("Contact", "_Test Contact For _Test Customer-_Test Customer",
|
||||
"is_primary_contact", 1)
|
||||
|
||||
details = get_party_details("_Test Customer")
|
||||
|
||||
for key, value in to_check.iteritems():
|
||||
|
@ -36,6 +36,15 @@
|
||||
"options": "Supplier",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.send_to=='All Sales Partner Contact'",
|
||||
"fieldname": "sales_partner",
|
||||
"fieldtype": "Link",
|
||||
"label": "Sales Partner",
|
||||
"options": "Sales Partner",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.send_to=='All Employee (Active)'",
|
||||
"fieldname": "department",
|
||||
@ -108,7 +117,7 @@
|
||||
"idx": 1,
|
||||
"in_create": 0,
|
||||
"issingle": 1,
|
||||
"modified": "2015-02-05 05:11:46.773913",
|
||||
"modified": "2015-05-25 17:46:37.555503",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "SMS Center",
|
||||
|
@ -34,7 +34,7 @@ def get_columns(filters):
|
||||
|
||||
def get_entries(filters):
|
||||
date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date"
|
||||
conditions, items = get_conditions(filters, date_field)
|
||||
conditions, values = get_conditions(filters, date_field)
|
||||
entries = frappe.db.sql("""select dt.name, dt.customer, dt.territory, dt.%s as posting_date,
|
||||
dt_item.item_code, dt_item.qty, dt_item.base_net_amount, st.sales_person,
|
||||
st.allocated_percentage, dt_item.base_net_amount*st.allocated_percentage/100 as contribution_amt
|
||||
@ -42,31 +42,33 @@ def get_entries(filters):
|
||||
where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s
|
||||
and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" %
|
||||
(date_field, filters["doc_type"], filters["doc_type"], '%s', conditions),
|
||||
tuple([filters["doc_type"]] + items), as_dict=1)
|
||||
tuple([filters["doc_type"]] + values), as_dict=1)
|
||||
|
||||
return entries
|
||||
|
||||
def get_conditions(filters, date_field):
|
||||
conditions = ""
|
||||
if filters.get("company"): conditions += " and dt.company = '%s'" % \
|
||||
filters["company"].replace("'", "\'")
|
||||
if filters.get("customer"): conditions += " and dt.customer = '%s'" % \
|
||||
filters["customer"].replace("'", "\'")
|
||||
if filters.get("territory"): conditions += " and dt.territory = '%s'" % \
|
||||
filters["territory"].replace("'", "\'")
|
||||
|
||||
if filters.get("from_date"): conditions += " and dt.%s >= '%s'" % \
|
||||
(date_field, filters["from_date"])
|
||||
if filters.get("to_date"): conditions += " and dt.%s <= '%s'" % (date_field, filters["to_date"])
|
||||
|
||||
if filters.get("sales_person"): conditions += " and st.sales_person = '%s'" % \
|
||||
filters["sales_person"].replace("'", "\'")
|
||||
conditions = [""]
|
||||
values = []
|
||||
|
||||
for field in ["company", "customer", "territory", "sales_person"]:
|
||||
if filters.get(field):
|
||||
conditions.append("dt.{0}=%s".format(field))
|
||||
values.append(filters[field])
|
||||
|
||||
if filters.get("from_date"):
|
||||
conditions.append("dt.{0}>=%s".format(date_field))
|
||||
values.append(filters["from_date"])
|
||||
|
||||
if filters.get("to_date"):
|
||||
conditions.append("dt.{0}<=%s".format(date_field))
|
||||
values.append(filters["to_date"])
|
||||
|
||||
items = get_items(filters)
|
||||
if items:
|
||||
conditions += " and dt_item.item_code in (%s)" % ', '.join(['%s']*len(items))
|
||||
conditions.append("dt_item.item_code in (%s)" % ', '.join(['%s']*len(items)))
|
||||
values += items
|
||||
|
||||
return conditions, items
|
||||
return " and ".join(conditions), values
|
||||
|
||||
def get_items(filters):
|
||||
if filters.get("item_group"): key = "item_group"
|
||||
|
@ -27,8 +27,12 @@ class Company(Document):
|
||||
return exists
|
||||
|
||||
def validate(self):
|
||||
self.abbr = self.abbr.strip()
|
||||
if self.get('__islocal') and len(self.abbr) > 5:
|
||||
frappe.throw(_("Abbreviation cannot have more than 5 characters"))
|
||||
|
||||
if not self.abbr.strip():
|
||||
frappe.throw(_("Abbr can not be blank or space"))
|
||||
|
||||
self.previous_default_currency = frappe.db.get_value("Company", self.name, "default_currency")
|
||||
if self.default_currency and self.previous_default_currency and \
|
||||
@ -174,6 +178,10 @@ class Company(Document):
|
||||
"""
|
||||
Trash accounts and cost centers for this company if no gl entry exists
|
||||
"""
|
||||
accounts = frappe.db.sql_list("select name from tabAccount where company=%s", self.name)
|
||||
cost_centers = frappe.db.sql_list("select name from `tabCost Center` where company=%s", self.name)
|
||||
warehouses = frappe.db.sql_list("select name from tabWarehouse where company=%s", self.name)
|
||||
|
||||
rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name)
|
||||
if not rec:
|
||||
# delete Account
|
||||
@ -192,23 +200,43 @@ class Company(Document):
|
||||
frappe.db.sql("""delete from `tabWarehouse` where company=%s""", self.name)
|
||||
|
||||
frappe.defaults.clear_default("company", value=self.name)
|
||||
|
||||
# clear default accounts, warehouses from item
|
||||
for f in ["default_warehouse", "website_warehouse"]:
|
||||
frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
|
||||
% (f, f, ', '.join(['%s']*len(warehouses))), tuple(warehouses))
|
||||
|
||||
frappe.db.sql("""delete from `tabItem Reorder` where warehouse in (%s)"""
|
||||
% ', '.join(['%s']*len(warehouses)), tuple(warehouses))
|
||||
|
||||
for f in ["income_account", "expense_account"]:
|
||||
frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
|
||||
% (f, f, ', '.join(['%s']*len(accounts))), tuple(accounts))
|
||||
|
||||
for f in ["selling_cost_center", "buying_cost_center"]:
|
||||
frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
|
||||
% (f, f, ', '.join(['%s']*len(cost_centers))), tuple(cost_centers))
|
||||
|
||||
# reset default company
|
||||
frappe.db.sql("""update `tabSingles` set value=""
|
||||
where doctype='Global Defaults' and field='default_company'
|
||||
and value=%s""", self.name)
|
||||
|
||||
@frappe.whitelist()
|
||||
def replace_abbr(company, old, new):
|
||||
new = new.strip()
|
||||
if not new:
|
||||
frappe.throw(_("Abbr can not be blank or space"))
|
||||
|
||||
frappe.only_for("System Manager")
|
||||
|
||||
frappe.db.set_value("Company", company, "abbr", new)
|
||||
|
||||
def _rename_record(dt):
|
||||
for d in frappe.db.sql("select name from `tab%s` where company=%s" % (dt, '%s'), company):
|
||||
parts = d[0].split(" - ")
|
||||
if parts[-1].lower() == old.lower():
|
||||
name_without_abbr = " - ".join(parts[:-1])
|
||||
frappe.rename_doc(dt, d[0], name_without_abbr + " - " + new)
|
||||
parts = d[0].rsplit(" - ", 1)
|
||||
if len(parts) == 1 or parts[1].lower() == old.lower():
|
||||
frappe.rename_doc(dt, d[0], parts[0] + " - " + new)
|
||||
|
||||
for dt in ["Account", "Cost Center", "Warehouse"]:
|
||||
_rename_record(dt)
|
||||
|
@ -29,5 +29,7 @@ class SalesPerson(NestedSet):
|
||||
return frappe.db.get_value("User", user, "email") or user
|
||||
|
||||
def validate_employee_id(self):
|
||||
if frappe.db.exists({"doctype": "Sales Person","employee": self.employee}):
|
||||
frappe.throw("Another sales person with the same employee id exists.", frappe.DuplicateEntryError)
|
||||
sales_person = frappe.db.get_value("Sales Person", {"employee": self.employee})
|
||||
|
||||
if sales_person and sales_person != self.name:
|
||||
frappe.throw(_("Another Sales Person {0} exists with the same Employee id").format(sales_person))
|
||||
|
@ -28,7 +28,7 @@ def setup_account(args=None):
|
||||
|
||||
args = frappe._dict(args)
|
||||
|
||||
if args.language != "english":
|
||||
if args.language and args.language != "english":
|
||||
set_default_language(args.language)
|
||||
|
||||
install_fixtures.install(args.get("country"))
|
||||
|
@ -110,7 +110,8 @@ class DeliveryNote(SellingController):
|
||||
def validate_with_previous_doc(self):
|
||||
items = self.get("items")
|
||||
|
||||
for fn in (("Sales Order", "against_sales_order"), ("Sales Invoice", "against_sales_invoice")):
|
||||
for fn in (("Sales Order", "against_sales_order", "so_detail"),
|
||||
("Sales Invoice", "against_sales_invoice", "si_detail")):
|
||||
if filter(None, [getattr(d, fn[1], None) for d in items]):
|
||||
super(DeliveryNote, self).validate_with_previous_doc({
|
||||
fn[0]: {
|
||||
@ -123,7 +124,7 @@ class DeliveryNote(SellingController):
|
||||
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
|
||||
super(DeliveryNote, self).validate_with_previous_doc({
|
||||
fn[0] + " Item": {
|
||||
"ref_dn_field": "so_detail",
|
||||
"ref_dn_field": fn[2],
|
||||
"compare_fields": [["rate", "="]],
|
||||
"is_child_table": True
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import unittest
|
||||
import frappe
|
||||
import json
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint, nowdate, nowtime, cstr, add_days
|
||||
from frappe.utils import cint, nowdate, nowtime, cstr, add_days, flt
|
||||
from erpnext.stock.stock_ledger import get_previous_sle
|
||||
from erpnext.accounts.utils import get_balance_on
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
|
||||
@ -136,7 +136,7 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
|
||||
# check stock in hand balance
|
||||
bal = get_balance_on(stock_in_hand_account)
|
||||
self.assertEquals(bal, prev_bal - stock_value_diff)
|
||||
self.assertEquals(flt(bal, 2), flt(prev_bal - stock_value_diff, 2))
|
||||
|
||||
dn.cancel()
|
||||
self.assertFalse(get_gl_entries("Delivery Note", dn.name))
|
||||
|
@ -34,6 +34,8 @@ class TestItem(unittest.TestCase):
|
||||
se = make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, incoming_rate=1)
|
||||
|
||||
item.has_variants = 1
|
||||
item.append("variants", {"item_attribute": "Test Size", "item_attribute_value": "Small"})
|
||||
|
||||
self.assertRaises(ItemTemplateCannotHaveStock, item.save)
|
||||
|
||||
def test_variant_item_codes(self):
|
||||
|
@ -445,10 +445,11 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
args: args,
|
||||
callback: function(r) {
|
||||
if(r.message) {
|
||||
var d = locals[cdt][cdn];
|
||||
$.each(r.message, function(k, v) {
|
||||
d[k] = v;
|
||||
});
|
||||
refresh_field('items');
|
||||
refresh_field("items");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -81,17 +81,21 @@ class TestStockEntry(unittest.TestCase):
|
||||
template = frappe.get_doc("Item", item.variant_of)
|
||||
else:
|
||||
template = item
|
||||
|
||||
projected_qty, actual_qty = frappe.db.get_value("Bin", {"item_code": item_code,
|
||||
"warehouse": "_Test Warehouse - _TC"}, ["projected_qty", "actual_qty"]) or [0, 0]
|
||||
|
||||
# stock entry reqd for auto-reorder
|
||||
create_stock_reconciliation(item_code=item_code, warehouse="_Test Warehouse - _TC",
|
||||
qty=10, rate=100)
|
||||
|
||||
frappe.db.set_value("Stock Settings", None, "auto_indent", 1)
|
||||
qty = actual_qty + abs(projected_qty) + 10, rate=100)
|
||||
|
||||
projected_qty = frappe.db.get_value("Bin", {"item_code": item_code,
|
||||
"warehouse": "_Test Warehouse - _TC"}, "projected_qty") or 0
|
||||
|
||||
|
||||
frappe.db.set_value("Stock Settings", None, "auto_indent", 1)
|
||||
|
||||
# update re-level qty so that it is more than projected_qty
|
||||
if projected_qty > template.reorder_levels[0].warehouse_reorder_level:
|
||||
if projected_qty >= template.reorder_levels[0].warehouse_reorder_level:
|
||||
template.reorder_levels[0].warehouse_reorder_level += projected_qty
|
||||
template.save()
|
||||
|
||||
|
@ -14,6 +14,7 @@ class StockFreezeError(frappe.ValidationError): pass
|
||||
|
||||
class StockLedgerEntry(Document):
|
||||
def validate(self):
|
||||
self.flags.ignore_submit_comment = True
|
||||
from erpnext.stock.utils import validate_warehouse_company
|
||||
self.validate_mandatory()
|
||||
self.validate_item()
|
||||
|
@ -227,7 +227,7 @@ class StockReconciliation(StockController):
|
||||
msgprint(_("Please enter Expense Account"), raise_exception=1)
|
||||
elif not frappe.db.sql("""select name from `tabStock Ledger Entry` limit 1"""):
|
||||
if frappe.db.get_value("Account", self.expense_account, "report_type") == "Profit and Loss":
|
||||
frappe.throw(_("Difference Account must be a 'Liability' type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError)
|
||||
frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError)
|
||||
|
||||
def get_items_for(self, warehouse):
|
||||
self.items = []
|
||||
|
@ -97,7 +97,8 @@ def create_stock_reconciliation(**args):
|
||||
sr.posting_time = args.posting_time or nowtime()
|
||||
sr.company = args.company or "_Test Company"
|
||||
sr.fiscal_year = get_fiscal_year(sr.posting_date)[0]
|
||||
sr.expense_account = args.expense_account or "Stock Adjustment - _TC"
|
||||
sr.expense_account = args.expense_account or \
|
||||
("Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC")
|
||||
sr.cost_center = args.cost_center or "_Test Cost Center - _TC"
|
||||
sr.append("items", {
|
||||
"item_code": args.item_code or "_Test Item",
|
||||
|
@ -11,10 +11,7 @@ def reorder_item():
|
||||
if not frappe.db.sql("select name from `tabFiscal Year` limit 1"):
|
||||
return
|
||||
|
||||
if getattr(frappe.local, "auto_indent", None) is None:
|
||||
frappe.local.auto_indent = cint(frappe.db.get_value('Stock Settings', None, 'auto_indent'))
|
||||
|
||||
if frappe.local.auto_indent:
|
||||
if cint(frappe.db.get_value('Stock Settings', None, 'auto_indent')):
|
||||
return _reorder_item()
|
||||
|
||||
def _reorder_item():
|
||||
|
Loading…
x
Reference in New Issue
Block a user