Added is_perpetual_inventory_enabled method
This commit is contained in:
parent
65ccb42f95
commit
e9ff1914fc
@ -38,10 +38,7 @@ def get_company_currency(company):
|
||||
|
||||
def set_perpetual_inventory(enable=1, company=None):
|
||||
if not company:
|
||||
company = get_default_company()
|
||||
|
||||
if frappe.flags.in_test:
|
||||
company = "_Test Company"
|
||||
company = "_Test Company" if frappe.flags.in_test else get_default_company()
|
||||
|
||||
company = frappe.get_doc("Company", company)
|
||||
company.enable_perpetual_inventory = enable
|
||||
@ -57,4 +54,23 @@ def encode_company_abbr(name, company):
|
||||
|
||||
return " - ".join(parts)
|
||||
|
||||
def is_perpetual_inventory_enabled(company):
|
||||
if not company:
|
||||
company = "_Test Company" if frappe.flags.in_test else get_default_company()
|
||||
|
||||
if not hasattr(frappe.local, 'enable_perpetual_inventory'):
|
||||
perpetual_inventory = get_company_wise_perptual_inventory()
|
||||
frappe.local.enable_perpetual_inventory = perpetual_inventory
|
||||
|
||||
if not frappe.local.enable_perpetual_inventory.get(company):
|
||||
is_enabled = frappe.db.get_value("Company", company, "enable_perpetual_inventory") or 0
|
||||
frappe.local.enable_perpetual_inventory.setdefault(company, is_enabled)
|
||||
|
||||
return frappe.local.enable_perpetual_inventory.get(company)
|
||||
|
||||
def get_company_wise_perptual_inventory():
|
||||
company_dict = {}
|
||||
for data in frappe.get_all('Company', fields = ["name", "enable_perpetual_inventory"]):
|
||||
company_dict[data.name] = data.enable_perpetual_inventory
|
||||
|
||||
return company_dict
|
||||
|
@ -39,7 +39,7 @@ frappe.ui.form.on('POS Profile', {
|
||||
|
||||
toggle_display_account_head: function(frm) {
|
||||
frm.toggle_display('expense_account',
|
||||
frappe.get_doc(":Company", frm.doc.company).enable_perpetual_inventory);
|
||||
erpnext.is_perpetual_inventory_enabled(frm.doc.company));
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -164,7 +164,7 @@ class PurchaseInvoice(BuyingController):
|
||||
frappe.msgprint(_("Item Code required at Row No {0}").format(d.idx), raise_exception=True)
|
||||
|
||||
def set_expense_account(self, for_validate=False):
|
||||
auto_accounting_for_stock = frappe.db.get_value('Company', self.company, 'enable_perpetual_inventory')
|
||||
auto_accounting_for_stock = erpnext.is_perpetual_inventory_enabled(self.company)
|
||||
|
||||
if auto_accounting_for_stock:
|
||||
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
|
||||
@ -335,7 +335,7 @@ class PurchaseInvoice(BuyingController):
|
||||
delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
|
||||
|
||||
def get_gl_entries(self, warehouse_account=None):
|
||||
self.auto_accounting_for_stock = frappe.db.get_value('Company', self.company, 'enable_perpetual_inventory')
|
||||
self.auto_accounting_for_stock = erpnext.is_perpetual_inventory_enabled(self.company)
|
||||
self.stock_received_but_not_billed = self.get_company_default("stock_received_but_not_billed")
|
||||
self.expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
||||
self.negative_expense_to_be_booked = 0.0
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
import frappe.model
|
||||
from frappe.utils import cint, flt, today, nowdate
|
||||
import frappe.defaults
|
||||
@ -28,7 +28,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
def test_gl_entries_without_perpetual_inventory(self):
|
||||
wrapper = frappe.copy_doc(test_records[0])
|
||||
set_perpetual_inventory(0, wrapper.company)
|
||||
self.assertTrue(not cint(frappe.db.get_value('Company', wrapper.company, 'enable_perpetual_inventory')))
|
||||
self.assertTrue(not cint(erpnext.is_perpetual_inventory_enabled(wrapper.company)))
|
||||
wrapper.insert()
|
||||
wrapper.submit()
|
||||
wrapper.load_from_db()
|
||||
@ -53,7 +53,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
def test_gl_entries_with_perpetual_inventory(self):
|
||||
pi = frappe.copy_doc(test_records[1])
|
||||
set_perpetual_inventory(1, pi.company)
|
||||
self.assertTrue(cint(frappe.db.get_value('Company', pi.company, 'enable_perpetual_inventory')), 1)
|
||||
self.assertTrue(cint(erpnext.is_perpetual_inventory_enabled(pi.company)), 1)
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
|
||||
@ -85,7 +85,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
def test_gl_entries_with_perpetual_inventory_against_pr(self):
|
||||
pr = frappe.copy_doc(pr_test_records[0])
|
||||
set_perpetual_inventory(1, pr.company)
|
||||
self.assertTrue(cint(frappe.db.get_value('Company', pr.company, 'enable_perpetual_inventory')), 1)
|
||||
self.assertTrue(cint(erpnext.is_perpetual_inventory_enabled(pr.company)), 1)
|
||||
pr.submit()
|
||||
|
||||
pi = frappe.copy_doc(test_records[1])
|
||||
@ -132,7 +132,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
def test_gl_entries_with_aia_for_non_stock_items(self):
|
||||
pi = frappe.copy_doc(test_records[1])
|
||||
set_perpetual_inventory(1, pi.company)
|
||||
self.assertTrue(cint(frappe.db.get_value('Company', pi.company, 'enable_perpetual_inventory')), 1)
|
||||
self.assertTrue(cint(erpnext.is_perpetual_inventory_enabled(pi.company)), 1)
|
||||
pi.get("items")[0].item_code = "_Test Non Stock Item"
|
||||
pi.get("items")[0].expense_account = "_Test Account Cost for Goods Sold - _TC"
|
||||
pi.get("taxes").pop(0)
|
||||
|
@ -492,7 +492,7 @@ frappe.ui.form.on('Sales Invoice', {
|
||||
|
||||
// expense account
|
||||
frm.fields_dict['items'].grid.get_field('expense_account').get_query = function(doc) {
|
||||
if (frappe.get_doc(":Company", doc.company).enable_perpetual_inventory) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(doc.company)) {
|
||||
return {
|
||||
filters: {
|
||||
'report_type': 'Profit and Loss',
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint, flt
|
||||
from frappe import _, msgprint, throw
|
||||
@ -559,7 +559,7 @@ class SalesInvoice(SellingController):
|
||||
throw(_("Delivery Note {0} is not submitted").format(d.delivery_note))
|
||||
|
||||
def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False):
|
||||
auto_accounting_for_stock = frappe.db.get_value('Company', self.company, 'enable_perpetual_inventory')
|
||||
auto_accounting_for_stock = erpnext.is_perpetual_inventory_enabled(self.company)
|
||||
|
||||
if not self.grand_total:
|
||||
return
|
||||
@ -675,7 +675,7 @@ class SalesInvoice(SellingController):
|
||||
|
||||
# expense account gl entries
|
||||
if cint(self.update_stock) and \
|
||||
frappe.db.get_value('Company', self.company, 'enable_perpetual_inventory'):
|
||||
erpnext.is_perpetual_inventory_enabled(self.company):
|
||||
gl_entries += super(SalesInvoice, self).get_gl_entries()
|
||||
|
||||
def make_pos_gl_entries(self, gl_entries):
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from frappe.utils import flt, cstr, cint
|
||||
from frappe import _
|
||||
from frappe.model.meta import get_field_precision
|
||||
@ -101,7 +101,7 @@ def make_entry(args, adv_adj, update_outstanding, from_repost=False):
|
||||
gle.submit()
|
||||
|
||||
def validate_account_for_perpetual_inventory(gl_map):
|
||||
if cint(frappe.db.get_value("Company", gl_map[0].company, 'enable_perpetual_inventory')) \
|
||||
if cint(erpnext.is_perpetual_inventory_enabled(gl_map[0].company)) \
|
||||
and gl_map[0].voucher_type=="Journal Entry":
|
||||
aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
|
||||
where account_type = 'Stock' and is_group=0""")]
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from frappe.utils import cint, flt, cstr
|
||||
from frappe import msgprint, _
|
||||
import frappe.defaults
|
||||
@ -21,7 +21,7 @@ class StockController(AccountsController):
|
||||
if self.docstatus == 2:
|
||||
delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
|
||||
|
||||
if cint(frappe.db.get_value('Company', self.company, 'enable_perpetual_inventory')):
|
||||
if cint(erpnext.is_perpetual_inventory_enabled(self.company)):
|
||||
warehouse_account = get_warehouse_account_map()
|
||||
|
||||
if self.docstatus==1:
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from frappe import _
|
||||
from frappe.utils import cint
|
||||
from frappe.utils.nestedset import rebuild_tree
|
||||
@ -51,7 +51,7 @@ def check_is_warehouse_associated_with_company():
|
||||
def make_warehouse_nestedset(company=None):
|
||||
validate_parent_account_for_warehouse(company)
|
||||
stock_account_group = get_stock_account_group(company.name)
|
||||
enable_perpetual_inventory = cint(frappe.db.get_value("Company", company, 'enable_perpetual_inventory')) or 0
|
||||
enable_perpetual_inventory = cint(erpnext.is_perpetual_inventory_enabled(company)) or 0
|
||||
if not stock_account_group and enable_perpetual_inventory:
|
||||
return
|
||||
|
||||
@ -73,7 +73,7 @@ def validate_parent_account_for_warehouse(company=None):
|
||||
if not company:
|
||||
return
|
||||
|
||||
if cint(frappe.db.get_value("Company", company, 'enable_perpetual_inventory')):
|
||||
if cint(erpnext.is_perpetual_inventory_enabled(company)):
|
||||
parent_account = frappe.db.sql("""select name from tabAccount
|
||||
where account_type='Stock' and company=%s and is_group=1
|
||||
and (warehouse is null or warehouse = '')""", company.name)
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
|
||||
def execute():
|
||||
frappe.reload_doctype("Account")
|
||||
@ -10,7 +10,7 @@ def execute():
|
||||
warehouses = frappe.db.sql_list("""select name, company from tabAccount
|
||||
where account_type = 'Stock' and is_group = 0
|
||||
and (warehouse is null or warehouse = '')""", as_dict)
|
||||
warehouses = [d.name for d in warehouses if frappe.db.get_value('Company', d.company, 'enable_perpetual_inventory')]
|
||||
warehouses = [d.name for d in warehouses if erpnext.is_perpetual_inventory_enabled(d.company)]
|
||||
if len(warehouses) > 0:
|
||||
warehouses = set_warehouse_for_stock_account(warehouses)
|
||||
if not warehouses:
|
||||
|
@ -7,4 +7,7 @@ import frappe
|
||||
def execute():
|
||||
frappe.reload_doctype('Company')
|
||||
enabled = frappe.db.get_single_value("Accounts Settings", "auto_accounting_for_stock") or 0
|
||||
frappe.db.sql("""update tabCompany set enable_perpetual_inventory = {0}""".format(enabled))
|
||||
for data in frappe.get_all('Company', fields = ["name"]):
|
||||
doc = frappe.get_doc('Company', data.name)
|
||||
doc.enable_perpetual_inventory = enabled
|
||||
doc.save(ignore_permissions=True)
|
@ -31,6 +31,12 @@ $.extend(erpnext, {
|
||||
}
|
||||
},
|
||||
|
||||
is_perpetual_inventory_enabled: function(company) {
|
||||
if(company) {
|
||||
return frappe.get_doc(":Company", company).enable_perpetual_inventory
|
||||
}
|
||||
},
|
||||
|
||||
setup_serial_no: function() {
|
||||
var grid_row = cur_frm.open_grid_row();
|
||||
if(!grid_row || !grid_row.grid_form.fields_dict.serial_no ||
|
||||
|
@ -33,6 +33,7 @@ class Company(Document):
|
||||
self.validate_default_accounts()
|
||||
self.validate_currency()
|
||||
self.validate_coa_input()
|
||||
self.validate_perpetual_inventory()
|
||||
|
||||
def validate_abbr(self):
|
||||
if not self.abbr:
|
||||
@ -139,6 +140,17 @@ class Company(Document):
|
||||
if not self.chart_of_accounts:
|
||||
self.chart_of_accounts = "Standard"
|
||||
|
||||
def validate_perpetual_inventory(self):
|
||||
if not self.get("__islocal"):
|
||||
if cint(self.enable_perpetual_inventory) == 1 and not self.default_inventory_account:
|
||||
frappe.msgprint(_("Warning: Set default inventory account for perpetual inventory"), alert=True)
|
||||
|
||||
enable_perpetual_inventory = frappe.db.get_value('Company', self.name, 'enable_perpetual_inventory')
|
||||
if enable_perpetual_inventory != self.enable_perpetual_inventory:
|
||||
if hasattr(frappe.local, 'enable_perpetual_inventory') and \
|
||||
self.name in frappe.local.enable_perpetual_inventory:
|
||||
del frappe.local.enable_perpetual_inventory[self.name]
|
||||
|
||||
def set_default_accounts(self):
|
||||
self._set_default_account("default_cash_account", "Cash")
|
||||
self._set_default_account("default_bank_account", "Bank")
|
||||
|
@ -40,7 +40,7 @@ frappe.ui.form.on("Delivery Note", {
|
||||
|
||||
|
||||
frm.set_query('expense_account', 'items', function(doc, cdt, cdn) {
|
||||
if (frappe.get_doc(":Company", doc.company).enable_perpetual_inventory) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(doc.company)) {
|
||||
return {
|
||||
filters: {
|
||||
"report_type": "Profit and Loss",
|
||||
@ -52,7 +52,7 @@ frappe.ui.form.on("Delivery Note", {
|
||||
});
|
||||
|
||||
frm.set_query('cost_center', 'items', function(doc, cdt, cdn) {
|
||||
if (frappe.get_doc(":Company", doc.company).enable_perpetual_inventory) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(doc.company)) {
|
||||
return {
|
||||
filters: {
|
||||
'company': doc.company,
|
||||
@ -141,7 +141,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
|
||||
if (doc.docstatus==1) {
|
||||
this.show_stock_ledger();
|
||||
if (frappe.get_doc(":Company", doc.company).enable_perpetual_inventory) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(doc.company)) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
if (this.frm.has_perm("submit") && doc.status !== "Closed") {
|
||||
@ -238,7 +238,7 @@ frappe.ui.form.on('Delivery Note', {
|
||||
|
||||
unhide_account_head: function(frm) {
|
||||
// unhide expense_account and cost_center if perpetual inventory is enabled in the company
|
||||
var aii_enabled = frappe.get_doc(":Company", frm.doc.company).enable_perpetual_inventory
|
||||
var aii_enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company)
|
||||
frm.fields_dict["items"].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled);
|
||||
}
|
||||
})
|
||||
|
@ -46,7 +46,7 @@ frappe.ui.form.on("Purchase Receipt", {
|
||||
},
|
||||
|
||||
toggle_display_account_head: function(frm) {
|
||||
var enabled = frappe.get_doc(":Company", frm.doc.company).enable_perpetual_inventory
|
||||
var enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company)
|
||||
frm.fields_dict["items"].grid.set_column_disp(["cost_center"], enabled);
|
||||
}
|
||||
});
|
||||
@ -62,7 +62,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
this._super();
|
||||
if(this.frm.doc.docstatus===1) {
|
||||
this.show_stock_ledger();
|
||||
if (frappe.get_doc(":Company", doc.company).enable_perpetual_inventory) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(doc.company)) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint, flt, cstr, today
|
||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||
@ -53,7 +53,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
def test_purchase_receipt_gl_entry(self):
|
||||
pr = frappe.copy_doc(test_records[0])
|
||||
set_perpetual_inventory(1, pr.company)
|
||||
self.assertEqual(cint(frappe.db.get_value("Company", pr.company, 'enable_perpetual_inventory')), 1)
|
||||
self.assertEqual(cint(erpnext.is_perpetual_inventory_enabled(pr.company)), 1)
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
|
||||
|
@ -104,7 +104,7 @@ frappe.ui.form.on('Stock Entry', {
|
||||
});
|
||||
},
|
||||
toggle_display_account_head: function(frm) {
|
||||
var enabled = frappe.get_doc(":Company", frm.doc.company).enable_perpetual_inventory;
|
||||
var enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company);
|
||||
frm.fields_dict["items"].grid.set_column_disp(["cost_center", "expense_account"], enabled);
|
||||
}
|
||||
})
|
||||
@ -222,12 +222,12 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
};
|
||||
});
|
||||
|
||||
if(me.frm.doc.company && frappe.get_doc(":Company", me.frm.doc.company).enable_perpetual_inventory) {
|
||||
if(me.frm.doc.company && erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) {
|
||||
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
|
||||
}
|
||||
|
||||
this.frm.fields_dict.items.grid.get_field('expense_account').get_query = function() {
|
||||
if (frappe.get_doc(":Company", me.frm.doc.company).enable_perpetual_inventory) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) {
|
||||
return {
|
||||
filters: {
|
||||
"company": me.frm.doc.company,
|
||||
@ -265,7 +265,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
this.toggle_related_fields(this.frm.doc);
|
||||
this.toggle_enable_bom();
|
||||
this.show_stock_ledger();
|
||||
if (this.frm.doc.docstatus===1 && frappe.get_doc(":Company", this.frm.doc.company).enable_perpetual_inventory) {
|
||||
if (this.frm.doc.docstatus===1 && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
erpnext.hide_company();
|
||||
@ -283,7 +283,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
set_default_account: function(callback) {
|
||||
var me = this;
|
||||
|
||||
if(this.frm.doc.company && frappe.get_doc(":Company", this.frm.doc.company).enable_perpetual_inventory) {
|
||||
if(this.frm.doc.company && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) {
|
||||
return this.frm.call({
|
||||
method: "erpnext.accounts.utils.get_company_default",
|
||||
args: {
|
||||
|
@ -113,7 +113,7 @@ frappe.ui.form.on("Stock Reconciliation", {
|
||||
},
|
||||
toggle_display_account_head: function(frm) {
|
||||
frm.toggle_display(['expense_account', 'cost_center'],
|
||||
frappe.get_doc(":Company", frm.doc.company).enable_perpetual_inventory);
|
||||
erpnext.is_perpetual_inventory_enabled(frm.doc.company));
|
||||
}
|
||||
});
|
||||
|
||||
@ -144,7 +144,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
set_default_expense_account: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.company) {
|
||||
if (frappe.get_doc(":Company", this.frm.doc.company).enable_perpetual_inventory && !this.frm.doc.expense_account) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(this.frm.doc.company) && !this.frm.doc.expense_account) {
|
||||
return this.frm.call({
|
||||
method: "erpnext.accounts.utils.get_company_default",
|
||||
args: {
|
||||
@ -166,12 +166,12 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
|
||||
this.setup_posting_date_time_check();
|
||||
|
||||
if (me.frm.doc.company && frappe.get_doc(":Company", me.frm.doc.company).enable_perpetual_inventory) {
|
||||
if (me.frm.doc.company && erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) {
|
||||
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
|
||||
this.frm.add_fetch("company", "cost_center", "cost_center");
|
||||
}
|
||||
this.frm.fields_dict["expense_account"].get_query = function() {
|
||||
if(frappe.get_doc(":Company", me.frm.doc.company).enable_perpetual_inventory) {
|
||||
if(erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) {
|
||||
return {
|
||||
"filters": {
|
||||
'company': me.frm.doc.company,
|
||||
@ -181,7 +181,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
}
|
||||
}
|
||||
this.frm.fields_dict["cost_center"].get_query = function() {
|
||||
if(frappe.get_doc(":Company", me.frm.doc.company).enable_perpetual_inventory) {
|
||||
if(erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) {
|
||||
return {
|
||||
"filters": {
|
||||
'company': me.frm.doc.company,
|
||||
@ -195,7 +195,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
refresh: function() {
|
||||
if(this.frm.doc.docstatus==1) {
|
||||
this.show_stock_ledger();
|
||||
if (frappe.get_doc(":Company", this.frm.doc.company).enable_perpetual_inventory) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
import frappe.defaults
|
||||
from frappe import msgprint, _
|
||||
from frappe.utils import cstr, flt, cint
|
||||
@ -231,7 +231,7 @@ class StockReconciliation(StockController):
|
||||
self.expense_account, self.cost_center)
|
||||
|
||||
def validate_expense_account(self):
|
||||
if not cint(frappe.db.get_value("Company", self.company, 'enable_perpetual_inventory')):
|
||||
if not cint(erpnext.is_perpetual_inventory_enabled(self.company)):
|
||||
return
|
||||
|
||||
if not self.expense_account:
|
||||
|
@ -454,7 +454,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
||||
dict(item_code=item_code, buying=1, currency=currency), 'price_list_rate')
|
||||
|
||||
if not allow_zero_rate and not valuation_rate \
|
||||
and cint(frappe.db.get_value("Company", company, "enable_perpetual_inventory")):
|
||||
and cint(erpnext.is_perpetual_inventory_enabled(company)):
|
||||
frappe.local.message_log = []
|
||||
frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a sample item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting/cancelling this entry").format(item_code, voucher_type, voucher_no))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user