mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-03 16:40:19 +00:00
Merge pull request #9355 from rohitwaghchaure/company_wise_manufacturing_settings
[Enhance] Company wise perpetual inventory settings
This commit is contained in:
@@ -156,7 +156,7 @@ erpnext.company.setup_queries = function(frm) {
|
||||
erpnext.company.set_custom_query(frm, v);
|
||||
});
|
||||
|
||||
if (frappe.sys_defaults.auto_accounting_for_stock) {
|
||||
if (frm.doc.enable_perpetual_inventory) {
|
||||
$.each([
|
||||
["stock_adjustment_account",
|
||||
{"root_type": "Expense", "account_type": "Stock Adjustment"}],
|
||||
|
||||
@@ -1122,6 +1122,37 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fieldname": "enable_perpetual_inventory",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Enable Perpetual Inventory",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@@ -1243,6 +1274,7 @@
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@@ -1777,7 +1809,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2017-06-14 11:06:33.629948",
|
||||
"modified": "2017-06-15 19:46:10.875108",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
||||
@@ -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:
|
||||
@@ -88,6 +89,10 @@ class Company(Document):
|
||||
if self.default_currency:
|
||||
frappe.db.set_value("Currency", self.default_currency, "enabled", 1)
|
||||
|
||||
if hasattr(frappe.local, 'enable_perpetual_inventory') and \
|
||||
self.name in frappe.local.enable_perpetual_inventory:
|
||||
frappe.local.enable_perpetual_inventory[self.name] = self.enable_perpetual_inventory
|
||||
|
||||
frappe.clear_cache()
|
||||
|
||||
def install_country_fixtures(self):
|
||||
@@ -139,6 +144,12 @@ 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(_("Set default inventory account for perpetual inventory"),
|
||||
alert=True, indicator='orange')
|
||||
|
||||
def set_default_accounts(self):
|
||||
self._set_default_account("default_cash_account", "Cash")
|
||||
self._set_default_account("default_bank_account", "Bank")
|
||||
@@ -146,7 +157,7 @@ class Company(Document):
|
||||
self._set_default_account("accumulated_depreciation_account", "Accumulated Depreciation")
|
||||
self._set_default_account("depreciation_expense_account", "Depreciation")
|
||||
|
||||
if cint(frappe.db.get_single_value("Accounts Settings", "auto_accounting_for_stock")):
|
||||
if self.enable_perpetual_inventory:
|
||||
self._set_default_account("stock_received_but_not_billed", "Stock Received But Not Billed")
|
||||
self._set_default_account("default_inventory_account", "Stock")
|
||||
self._set_default_account("stock_adjustment_account", "Stock Adjustment")
|
||||
|
||||
@@ -85,6 +85,7 @@ def create_fiscal_year_and_company(args):
|
||||
frappe.get_doc({
|
||||
"doctype":"Company",
|
||||
'company_name':args.get('company_name').strip(),
|
||||
'enable_perpetual_inventory': 1,
|
||||
'abbr':args.get('company_abbr'),
|
||||
'default_currency':args.get('currency'),
|
||||
'country': args.get('country'),
|
||||
@@ -159,10 +160,6 @@ def set_defaults(args):
|
||||
|
||||
frappe.db.set_value("System Settings", None, "email_footer_address", args.get("company"))
|
||||
|
||||
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||
accounts_settings.auto_accounting_for_stock = 1
|
||||
accounts_settings.save()
|
||||
|
||||
stock_settings = frappe.get_doc("Stock Settings")
|
||||
stock_settings.item_naming_by = "Item Code"
|
||||
stock_settings.valuation_method = "FIFO"
|
||||
|
||||
Reference in New Issue
Block a user