diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 566dd158a67..1fdf73a0595 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '12.20.0' +__version__ = '12.21.0' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 709dccd2230..dbe8fe40923 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -29,7 +29,11 @@ class JournalEntry(AccountsController): self.validate_entries_for_advance() self.validate_multi_currency() self.set_amounts_in_company_currency() - self.validate_total_debit_and_credit() + + # Do not validate while importing via data import + if not frappe.flags.in_import: + self.validate_total_debit_and_credit() + self.validate_against_jv() self.validate_reference_doc() self.set_against_account() @@ -1047,4 +1051,4 @@ def make_reverse_journal_entry(source_name, target_doc=None): }, }, target_doc) - return doclist \ No newline at end of file + return doclist \ No newline at end of file diff --git a/erpnext/change_log/v12/v12_21_0.md b/erpnext/change_log/v12/v12_21_0.md new file mode 100644 index 00000000000..946bf09d9e4 --- /dev/null +++ b/erpnext/change_log/v12/v12_21_0.md @@ -0,0 +1,21 @@ +## Version 12.21.0 Release Notes + + +### Fixes & Enhancements + +- Incorrect qty calculated for sub-contracted raw materials in purchase receipt ([#25443](https://github.com/frappe/erpnext/pull/25443)) +- Update cost center in the item table fetched from POS Profile in v12 ([#25612](https://github.com/frappe/erpnext/pull/25612)) +- Total stock summary report not working ([#25552](https://github.com/frappe/erpnext/pull/25552)) +- Timeout error while loading warehouse tree ([#25693](https://github.com/frappe/erpnext/pull/25693)) +- RCM rounding precision ([#25410](https://github.com/frappe/erpnext/pull/25410)) +- Change subcontracted item display ([#25426](https://github.com/frappe/erpnext/pull/25426)) +- Remove invalid changes added due to merge conflict ([#25437](https://github.com/frappe/erpnext/pull/25437)) +- Add document type field for e-invoicing (Italy) ([#25420](https://github.com/frappe/erpnext/pull/25420)) +- Issue in project custom status ([#25453](https://github.com/frappe/erpnext/pull/25453)) +- Employee Separation ([#25504](https://github.com/frappe/erpnext/pull/25504)) +- State code for Other Territory ([#25422](https://github.com/frappe/erpnext/pull/25422)) +- Remove invalid changes added due to merge conflict ([#25405](https://github.com/frappe/erpnext/pull/25405)) +- Check for None in item.schedule_date before setting ([#25589](https://github.com/frappe/erpnext/pull/25589)) +- Can't multiply sequence by non-int of type 'float' ([#25385](https://github.com/frappe/erpnext/pull/25385)) +- Filter using purpose, make requested changes ([#25388](https://github.com/frappe/erpnext/pull/25388)) +- Purchase from registered composition dealer ([#25419](https://github.com/frappe/erpnext/pull/25419)) \ No newline at end of file diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py index ae8abf2eb15..05b7d11b794 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py @@ -146,8 +146,9 @@ def sync_transactions(bank, bank_account): transactions = get_transactions(bank=bank, bank_account=bank_account, start_date=start_date, end_date=end_date) result = [] - for transaction in reversed(transactions): - result += new_bank_transaction(transaction) + if transactions: + for transaction in reversed(transactions): + result += new_bank_transaction(transaction) if result: last_transaction_date = frappe.db.get_value('Bank Transaction', result.pop(), 'date') diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py index 312488984cd..5a55635d334 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.py +++ b/erpnext/stock/doctype/warehouse/warehouse.py @@ -3,8 +3,9 @@ from __future__ import unicode_literals import frappe, erpnext -from frappe.utils import cint, nowdate +from frappe.utils import cint, flt from frappe import throw, _ +from collections import defaultdict from frappe.utils.nestedset import NestedSet from erpnext.stock import get_warehouse_account from frappe.contacts.address_and_contact import load_address_and_contact @@ -29,7 +30,6 @@ class Warehouse(NestedSet): self.set_onload('account', account) load_address_and_contact(self) - def on_update(self): self.update_nsm_model() @@ -140,8 +140,6 @@ class Warehouse(NestedSet): @frappe.whitelist() def get_children(doctype, parent=None, company=None, is_root=False): - from erpnext.stock.utils import get_stock_value_from_bin - if is_root: parent = "" @@ -154,13 +152,48 @@ def get_children(doctype, parent=None, company=None, is_root=False): warehouses = frappe.get_list(doctype, fields=fields, filters=filters, order_by='name') + company_currency = '' + if company: + company_currency = frappe.get_cached_value('Company', company, 'default_currency') + + warehouse_wise_value = get_warehouse_wise_stock_value(company) + # return warehouses for wh in warehouses: - wh["balance"] = get_stock_value_from_bin(warehouse=wh.value) - if company: - wh["company_currency"] = frappe.db.get_value('Company', company, 'default_currency') + wh["balance"] = warehouse_wise_value.get(wh.value) + if company_currency: + wh["company_currency"] = company_currency return warehouses +def get_warehouse_wise_stock_value(company): + warehouses = frappe.get_all('Warehouse', + fields = ['name', 'parent_warehouse'], filters = {'company': company}) + parent_warehouse = {d.name : d.parent_warehouse for d in warehouses} + + filters = {'warehouse': ('in', [data.name for data in warehouses])} + bin_data = frappe.get_all('Bin', fields = ['sum(stock_value) as stock_value', 'warehouse'], + filters = filters, group_by = 'warehouse') + + warehouse_wise_stock_value = defaultdict(float) + for row in bin_data: + if not row.stock_value: + continue + + warehouse_wise_stock_value[row.warehouse] = row.stock_value + update_value_in_parent_warehouse(warehouse_wise_stock_value, + parent_warehouse, row.warehouse, row.stock_value) + + return warehouse_wise_stock_value + +def update_value_in_parent_warehouse(warehouse_wise_stock_value, parent_warehouse_dict, warehouse, stock_value): + parent_warehouse = parent_warehouse_dict.get(warehouse) + if not parent_warehouse: + return + + warehouse_wise_stock_value[parent_warehouse] += flt(stock_value) + update_value_in_parent_warehouse(warehouse_wise_stock_value, parent_warehouse_dict, + parent_warehouse, stock_value) + @frappe.whitelist() def add_node(): from frappe.desk.treeview import make_tree_args diff --git a/erpnext/stock/doctype/warehouse/warehouse_tree.js b/erpnext/stock/doctype/warehouse/warehouse_tree.js index 918d2f15593..a69660ffa2b 100644 --- a/erpnext/stock/doctype/warehouse/warehouse_tree.js +++ b/erpnext/stock/doctype/warehouse/warehouse_tree.js @@ -20,7 +20,7 @@ frappe.treeview_settings['Warehouse'] = { onrender: function(node) { if (node.data && node.data.balance!==undefined) { $('' - + format_currency(Math.abs(node.data.balance), node.data.company_currency) + + format_currency((node.data.balance), node.data.company_currency) + '').insertBefore(node.$ul); } }