|
diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
index ce64ee4f5a2..601c8fcda66 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
+++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
@@ -344,7 +344,15 @@ def get_pe_matching_query(amount_condition, account_from_to, transaction):
def get_je_matching_query(amount_condition, transaction):
# get matching journal entry query
- cr_or_dr = "credit" if transaction.withdrawal > 0 else "debit"
+
+ company_account = frappe.get_value("Bank Account", transaction.bank_account, "account")
+ root_type = frappe.get_value("Account", company_account, "root_type")
+
+ if root_type == "Liability":
+ cr_or_dr = "debit" if transaction.withdrawal > 0 else "credit"
+ else:
+ cr_or_dr = "credit" if transaction.withdrawal > 0 else "debit"
+
return f"""
SELECT
diff --git a/erpnext/accounts/doctype/loyalty_program/loyalty_program.js b/erpnext/accounts/doctype/loyalty_program/loyalty_program.js
index f90f86728de..6951b2a2b32 100644
--- a/erpnext/accounts/doctype/loyalty_program/loyalty_program.js
+++ b/erpnext/accounts/doctype/loyalty_program/loyalty_program.js
@@ -6,7 +6,7 @@ frappe.provide("erpnext.accounts.dimensions");
frappe.ui.form.on('Loyalty Program', {
setup: function(frm) {
var help_content =
- `
+ `
diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
index 28bd10283e7..2ed5fb79189 100644
--- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
+++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
@@ -113,9 +113,15 @@ class POSInvoiceMergeLog(Document):
def merge_pos_invoice_into(self, invoice, data):
items, payments, taxes = [], [], []
+
loyalty_amount_sum, loyalty_points_sum = 0, 0
+
rounding_adjustment, base_rounding_adjustment = 0, 0
rounded_total, base_rounded_total = 0, 0
+
+ loyalty_amount_sum, loyalty_points_sum, idx = 0, 0, 1
+
+
for doc in data:
map_doc(doc, invoice, table_map={ "doctype": invoice.doctype })
@@ -149,6 +155,8 @@ class POSInvoiceMergeLog(Document):
found = True
if not found:
tax.charge_type = 'Actual'
+ tax.idx = idx
+ idx += 1
tax.included_in_print_rate = 0
tax.tax_amount = tax.tax_amount_after_discount_amount
tax.base_tax_amount = tax.base_tax_amount_after_discount_amount
@@ -166,8 +174,8 @@ class POSInvoiceMergeLog(Document):
payments.append(payment)
rounding_adjustment += doc.rounding_adjustment
rounded_total += doc.rounded_total
- base_rounding_adjustment += doc.rounding_adjustment
- base_rounded_total += doc.rounded_total
+ base_rounding_adjustment += doc.base_rounding_adjustment
+ base_rounded_total += doc.base_rounded_total
if loyalty_points_sum:
@@ -179,9 +187,9 @@ class POSInvoiceMergeLog(Document):
invoice.set('payments', payments)
invoice.set('taxes', taxes)
invoice.set('rounding_adjustment',rounding_adjustment)
- invoice.set('rounding_adjustment',base_rounding_adjustment)
- invoice.set('base_rounded_total',base_rounded_total)
+ invoice.set('base_rounding_adjustment',base_rounding_adjustment)
invoice.set('rounded_total',rounded_total)
+ invoice.set('base_rounded_total',base_rounded_total)
invoice.additional_discount_percentage = 0
invoice.discount_amount = 0.0
invoice.taxes_and_charges = None
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
index d79ad5f528f..826758245a3 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
@@ -38,7 +38,7 @@ frappe.ui.form.on('Pricing Rule', {
refresh: function(frm) {
var help_content =
- `
+ `
diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py
index f5391ca4cc9..0e1ebd21660 100644
--- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py
+++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py
@@ -22,6 +22,9 @@ price_discount_fields = ['rate_or_discount', 'apply_discount_on', 'apply_discoun
product_discount_fields = ['free_item', 'free_qty', 'free_item_uom',
'free_item_rate', 'same_item', 'is_recursive', 'apply_multiple_pricing_rules']
+class TransactionExists(frappe.ValidationError):
+ pass
+
class PromotionalScheme(Document):
def validate(self):
if not self.selling and not self.buying:
@@ -30,6 +33,40 @@ class PromotionalScheme(Document):
or self.product_discount_slabs):
frappe.throw(_("Price or product discount slabs are required"))
+ self.validate_applicable_for()
+ self.validate_pricing_rules()
+
+ def validate_applicable_for(self):
+ if self.applicable_for:
+ applicable_for = frappe.scrub(self.applicable_for)
+
+ if not self.get(applicable_for):
+ msg = (f'The field {frappe.bold(self.applicable_for)} is required')
+ frappe.throw(_(msg))
+
+ def validate_pricing_rules(self):
+ if self.is_new():
+ return
+
+ transaction_exists = False
+ docnames = []
+
+ # If user has changed applicable for
+ if self._doc_before_save.applicable_for == self.applicable_for:
+ return
+
+ docnames = frappe.get_all('Pricing Rule',
+ filters= {'promotional_scheme': self.name})
+
+ for docname in docnames:
+ if frappe.db.exists('Pricing Rule Detail',
+ {'pricing_rule': docname.name, 'docstatus': ('<', 2)}):
+ raise_for_transaction_exists(self.name)
+
+ if docnames and not transaction_exists:
+ for docname in docnames:
+ frappe.delete_doc('Pricing Rule', docname.name)
+
def on_update(self):
pricing_rules = frappe.get_all(
'Pricing Rule',
@@ -69,6 +106,13 @@ class PromotionalScheme(Document):
{'promotional_scheme': self.name}):
frappe.delete_doc('Pricing Rule', rule.name)
+def raise_for_transaction_exists(name):
+ msg = (f"""You can't change the {frappe.bold(_('Applicable For'))}
+ because transactions are present against the Promotional Scheme {frappe.bold(name)}. """)
+ msg += 'Kindly disable this Promotional Scheme and create new for new Applicable For.'
+
+ frappe.throw(_(msg), TransactionExists)
+
def get_pricing_rules(doc, rules=None):
if rules is None:
rules = {}
@@ -86,45 +130,59 @@ def _get_pricing_rules(doc, child_doc, discount_fields, rules=None):
new_doc = []
args = get_args_for_pricing_rule(doc)
applicable_for = frappe.scrub(doc.get('applicable_for'))
+
for idx, d in enumerate(doc.get(child_doc)):
if d.name in rules:
- for applicable_for_value in args.get(applicable_for):
- temp_args = args.copy()
- docname = frappe.get_all(
- 'Pricing Rule',
- fields = ["promotional_scheme_id", "name", applicable_for],
- filters = {
- 'promotional_scheme_id': d.name,
- applicable_for: applicable_for_value
- }
- )
-
- if docname:
- pr = frappe.get_doc('Pricing Rule', docname[0].get('name'))
- temp_args[applicable_for] = applicable_for_value
- pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
- else:
- pr = frappe.new_doc("Pricing Rule")
- pr.title = doc.name
- temp_args[applicable_for] = applicable_for_value
- pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
-
+ if not args.get(applicable_for):
+ docname = get_pricing_rule_docname(d)
+ pr = prepare_pricing_rule(args, doc, child_doc, discount_fields, d, docname)
new_doc.append(pr)
+ else:
+ for applicable_for_value in args.get(applicable_for):
+ docname = get_pricing_rule_docname(d, applicable_for, applicable_for_value)
+ pr = prepare_pricing_rule(args, doc, child_doc, discount_fields,
+ d, docname, applicable_for, applicable_for_value)
+ new_doc.append(pr)
- else:
+ elif args.get(applicable_for):
applicable_for_values = args.get(applicable_for) or []
for applicable_for_value in applicable_for_values:
- pr = frappe.new_doc("Pricing Rule")
- pr.title = doc.name
- temp_args = args.copy()
- temp_args[applicable_for] = applicable_for_value
- pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
+ pr = prepare_pricing_rule(args, doc, child_doc, discount_fields,
+ d, applicable_for=applicable_for, value= applicable_for_value)
+
new_doc.append(pr)
+ else:
+ pr = prepare_pricing_rule(args, doc, child_doc, discount_fields, d)
+ new_doc.append(pr)
return new_doc
+def get_pricing_rule_docname(row: dict, applicable_for: str = None, applicable_for_value: str = None) -> str:
+ fields = ['promotional_scheme_id', 'name']
+ filters = {
+ 'promotional_scheme_id': row.name
+ }
+ if applicable_for:
+ fields.append(applicable_for)
+ filters[applicable_for] = applicable_for_value
+ docname = frappe.get_all('Pricing Rule', fields = fields, filters = filters)
+ return docname[0].name if docname else ''
+
+def prepare_pricing_rule(args, doc, child_doc, discount_fields, d, docname=None, applicable_for=None, value=None):
+ if docname:
+ pr = frappe.get_doc("Pricing Rule", docname)
+ else:
+ pr = frappe.new_doc("Pricing Rule")
+
+ pr.title = doc.name
+ temp_args = args.copy()
+
+ if value:
+ temp_args[applicable_for] = value
+
+ return set_args(temp_args, pr, doc, child_doc, discount_fields, d)
def set_args(args, pr, doc, child_doc, discount_fields, child_doc_fields):
pr.update(args)
@@ -147,6 +205,7 @@ def set_args(args, pr, doc, child_doc, discount_fields, child_doc_fields):
apply_on: d.get(apply_on),
'uom': d.uom
})
+
return pr
def get_args_for_pricing_rule(doc):
diff --git a/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py
index 190b734cc17..139076c927f 100644
--- a/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py
+++ b/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py
@@ -7,10 +7,17 @@ import unittest
import frappe
+from erpnext.accounts.doctype.promotional_scheme.promotional_scheme import TransactionExists
+from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
+
class TestPromotionalScheme(unittest.TestCase):
+ def setUp(self):
+ if frappe.db.exists('Promotional Scheme', '_Test Scheme'):
+ frappe.delete_doc('Promotional Scheme', '_Test Scheme')
+
def test_promotional_scheme(self):
- ps = make_promotional_scheme()
+ ps = make_promotional_scheme(applicable_for='Customer', customer='_Test Customer')
price_rules = frappe.get_all('Pricing Rule', fields = ["promotional_scheme_id", "name", "creation"],
filters = {'promotional_scheme': ps.name})
self.assertTrue(len(price_rules),1)
@@ -41,22 +48,62 @@ class TestPromotionalScheme(unittest.TestCase):
filters = {'promotional_scheme': ps.name})
self.assertEqual(price_rules, [])
-def make_promotional_scheme():
+ def test_promotional_scheme_without_applicable_for(self):
+ ps = make_promotional_scheme()
+ price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
+
+ self.assertTrue(len(price_rules), 1)
+ frappe.delete_doc('Promotional Scheme', ps.name)
+
+ price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
+ self.assertEqual(price_rules, [])
+
+ def test_change_applicable_for_in_promotional_scheme(self):
+ ps = make_promotional_scheme()
+ price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
+ self.assertTrue(len(price_rules), 1)
+
+ so = make_sales_order(qty=5, currency='USD', do_not_save=True)
+ so.set_missing_values()
+ so.save()
+ self.assertEqual(price_rules[0].name, so.pricing_rules[0].pricing_rule)
+
+ ps.applicable_for = 'Customer'
+ ps.append('customer', {
+ 'customer': '_Test Customer'
+ })
+
+ self.assertRaises(TransactionExists, ps.save)
+
+ frappe.delete_doc('Sales Order', so.name)
+ frappe.delete_doc('Promotional Scheme', ps.name)
+ price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
+ self.assertEqual(price_rules, [])
+
+def make_promotional_scheme(**args):
+ args = frappe._dict(args)
+
ps = frappe.new_doc('Promotional Scheme')
ps.name = '_Test Scheme'
ps.append('items',{
'item_code': '_Test Item'
})
+
ps.selling = 1
ps.append('price_discount_slabs',{
'min_qty': 4,
+ 'validate_applied_rule': 0,
'discount_percentage': 20,
'rule_description': 'Test'
})
- ps.applicable_for = 'Customer'
- ps.append('customer',{
- 'customer': "_Test Customer"
- })
+
+ ps.company = '_Test Company'
+ if args.applicable_for:
+ ps.applicable_for = args.applicable_for
+ ps.append(frappe.scrub(args.applicable_for), {
+ frappe.scrub(args.applicable_for): args.get(frappe.scrub(args.applicable_for))
+ })
+
ps.save()
return ps
diff --git a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json
index a70d5c9d430..aa3696d216d 100644
--- a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json
+++ b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json
@@ -136,7 +136,7 @@
"label": "Threshold for Suggestion"
},
{
- "default": "1",
+ "default": "0",
"fieldname": "validate_applied_rule",
"fieldtype": "Check",
"label": "Validate Applied Rule"
@@ -169,7 +169,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2021-08-19 15:49:29.598727",
+ "modified": "2021-11-16 00:25:33.843996",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Promotional Scheme Price Discount",
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index ecc8783df2c..98a84d28209 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -85,7 +85,8 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
if party_type=="Customer":
party_details["sales_team"] = [{
"sales_person": d.sales_person,
- "allocated_percentage": d.allocated_percentage or None
+ "allocated_percentage": d.allocated_percentage or None,
+ "commission_rate": d.commission_rate
} for d in party.get("sales_team")]
# supplier tax withholding category
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 2cb8a6802a7..352b1c8392f 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -425,8 +425,7 @@ def set_gl_entries_by_account(
{additional_conditions}
and posting_date <= %(to_date)s
and is_cancelled = 0
- {distributed_cost_center_query}
- order by account, posting_date""".format(
+ {distributed_cost_center_query}""".format(
additional_conditions=additional_conditions,
distributed_cost_center_query=distributed_cost_center_query), gl_filters, as_dict=True) #nosec
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index 31416da4ac4..5cc0d9126a9 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -7,7 +7,7 @@ from collections import OrderedDict
import frappe
from frappe import _, _dict
-from frappe.utils import cstr, flt, getdate
+from frappe.utils import cstr, getdate
from six import iteritems
from erpnext import get_company_currency, get_default_company
@@ -19,6 +19,8 @@ from erpnext.accounts.report.financial_statements import get_cost_centers_with_c
from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency
from erpnext.accounts.utils import get_account_currency
+# to cache translations
+TRANSLATIONS = frappe._dict()
def execute(filters=None):
if not filters:
@@ -44,10 +46,20 @@ def execute(filters=None):
columns = get_columns(filters)
+ update_translations()
+
res = get_result(filters, account_details)
return columns, res
+def update_translations():
+ TRANSLATIONS.update(
+ dict(
+ OPENING = _('Opening'),
+ TOTAL = _('Total'),
+ CLOSING_TOTAL = _('Closing (Opening + Total)')
+ )
+ )
def validate_filters(filters, account_details):
if not filters.get("company"):
@@ -353,9 +365,9 @@ def get_totals_dict():
credit_in_account_currency=0.0
)
return _dict(
- opening = _get_debit_credit_dict(_('Opening')),
- total = _get_debit_credit_dict(_('Total')),
- closing = _get_debit_credit_dict(_('Closing (Opening + Total)'))
+ opening = _get_debit_credit_dict(TRANSLATIONS.OPENING),
+ total = _get_debit_credit_dict(TRANSLATIONS.TOTAL),
+ closing = _get_debit_credit_dict(TRANSLATIONS.CLOSING_TOTAL)
)
def group_by_field(group_by):
@@ -380,22 +392,23 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
entries = []
consolidated_gle = OrderedDict()
group_by = group_by_field(filters.get('group_by'))
+ group_by_voucher_consolidated = filters.get("group_by") == 'Group by Voucher (Consolidated)'
if filters.get('show_net_values_in_party_account'):
account_type_map = get_account_type_map(filters.get('company'))
def update_value_in_dict(data, key, gle):
- data[key].debit += flt(gle.debit)
- data[key].credit += flt(gle.credit)
+ data[key].debit += gle.debit
+ data[key].credit += gle.credit
- data[key].debit_in_account_currency += flt(gle.debit_in_account_currency)
- data[key].credit_in_account_currency += flt(gle.credit_in_account_currency)
+ data[key].debit_in_account_currency += gle.debit_in_account_currency
+ data[key].credit_in_account_currency += gle.credit_in_account_currency
if filters.get('show_net_values_in_party_account') and \
account_type_map.get(data[key].account) in ('Receivable', 'Payable'):
- net_value = flt(data[key].debit) - flt(data[key].credit)
- net_value_in_account_currency = flt(data[key].debit_in_account_currency) \
- - flt(data[key].credit_in_account_currency)
+ net_value = data[key].debit - data[key].credit
+ net_value_in_account_currency = data[key].debit_in_account_currency \
+ - data[key].credit_in_account_currency
if net_value < 0:
dr_or_cr = 'credit'
@@ -413,19 +426,29 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
data[key].against_voucher += ', ' + gle.against_voucher
from_date, to_date = getdate(filters.from_date), getdate(filters.to_date)
- for gle in gl_entries:
- if (gle.posting_date < from_date or
- (cstr(gle.is_opening) == "Yes" and not filters.get("show_opening_entries"))):
- update_value_in_dict(gle_map[gle.get(group_by)].totals, 'opening', gle)
- update_value_in_dict(totals, 'opening', gle)
+ show_opening_entries = filters.get("show_opening_entries")
- update_value_in_dict(gle_map[gle.get(group_by)].totals, 'closing', gle)
+ for gle in gl_entries:
+ group_by_value = gle.get(group_by)
+
+ if (gle.posting_date < from_date or (cstr(gle.is_opening) == "Yes" and not show_opening_entries)):
+ if not group_by_voucher_consolidated:
+ update_value_in_dict(gle_map[group_by_value].totals, 'opening', gle)
+ update_value_in_dict(gle_map[group_by_value].totals, 'closing', gle)
+
+ update_value_in_dict(totals, 'opening', gle)
update_value_in_dict(totals, 'closing', gle)
elif gle.posting_date <= to_date:
- if filters.get("group_by") != 'Group by Voucher (Consolidated)':
- gle_map[gle.get(group_by)].entries.append(gle)
- elif filters.get("group_by") == 'Group by Voucher (Consolidated)':
+ if not group_by_voucher_consolidated:
+ update_value_in_dict(gle_map[group_by_value].totals, 'total', gle)
+ update_value_in_dict(gle_map[group_by_value].totals, 'closing', gle)
+ update_value_in_dict(totals, 'total', gle)
+ update_value_in_dict(totals, 'closing', gle)
+
+ gle_map[group_by_value].entries.append(gle)
+
+ elif group_by_voucher_consolidated:
keylist = [gle.get("voucher_type"), gle.get("voucher_no"), gle.get("account")]
for dim in accounting_dimensions:
keylist.append(gle.get(dim))
@@ -437,9 +460,7 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
update_value_in_dict(consolidated_gle, key, gle)
for key, value in consolidated_gle.items():
- update_value_in_dict(gle_map[value.get(group_by)].totals, 'total', value)
update_value_in_dict(totals, 'total', value)
- update_value_in_dict(gle_map[value.get(group_by)].totals, 'closing', value)
update_value_in_dict(totals, 'closing', value)
entries.append(value)
diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.json b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.json
index 2623585aeae..3668b2505f6 100644
--- a/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.json
+++ b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.json
@@ -1,184 +1,70 @@
{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "field:criteria_name",
- "beta": 0,
- "creation": "2017-05-29 01:32:43.064891",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "allow_rename": 1,
+ "autoname": "field:criteria_name",
+ "creation": "2017-05-29 01:32:43.064891",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "criteria_name",
+ "max_score",
+ "formula",
+ "weight"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "criteria_name",
- "fieldtype": "Data",
- "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": "Criteria Name",
- "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": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "fieldname": "criteria_name",
+ "fieldtype": "Data",
+ "label": "Criteria Name",
+ "reqd": 1,
"unique": 1
- },
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "100",
- "fieldname": "max_score",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Max Score",
- "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": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
+ "default": "100",
+ "fieldname": "max_score",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Max Score",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "formula",
- "fieldtype": "Small Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 1,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Criteria Formula",
- "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": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
+ "fieldname": "formula",
+ "fieldtype": "Small Text",
+ "ignore_xss_filter": 1,
+ "in_list_view": 1,
+ "label": "Criteria Formula",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "weight",
- "fieldtype": "Percent",
- "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": "Criteria Weight",
- "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
+ "fieldname": "weight",
+ "fieldtype": "Percent",
+ "label": "Criteria Weight"
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2019-01-22 10:47:00.000822",
- "modified_by": "Administrator",
- "module": "Buying",
- "name": "Supplier Scorecard Criteria",
- "name_case": "",
- "owner": "Administrator",
+ ],
+ "links": [],
+ "modified": "2021-11-11 18:34:58.477648",
+ "modified_by": "Administrator",
+ "module": "Buying",
+ "name": "Supplier Scorecard Criteria",
+ "naming_rule": "By fieldname",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 0,
- "apply_user_permissions": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "System Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "share": 1,
"write": 1
}
- ],
- "quick_entry": 1,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
- "sort_field": "modified",
- "sort_order": "DESC",
- "track_changes": 1,
- "track_seen": 0
+ ],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py
index 1b25dd45d2d..a566d568119 100644
--- a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py
+++ b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py
@@ -41,10 +41,13 @@ def get_conditions(filters):
if filters.get("from_date") and filters.get("to_date"):
conditions += " and po.transaction_date between %(from_date)s and %(to_date)s"
- for field in ['company', 'name', 'status']:
+ for field in ['company', 'name']:
if filters.get(field):
conditions += f" and po.{field} = %({field})s"
+ if filters.get('status'):
+ conditions += " and po.status in %(status)s"
+
if filters.get('project'):
conditions += " and poi.project = %(project)s"
diff --git a/erpnext/e_commerce/shopping_cart/cart.py b/erpnext/e_commerce/shopping_cart/cart.py
index 1b4d68e4f58..f13fabc78f0 100644
--- a/erpnext/e_commerce/shopping_cart/cart.py
+++ b/erpnext/e_commerce/shopping_cart/cart.py
@@ -201,7 +201,9 @@ def add_new_address(doc):
def create_lead_for_item_inquiry(lead, subject, message):
lead = frappe.parse_json(lead)
lead_doc = frappe.new_doc('Lead')
- lead_doc.update(lead)
+ for fieldname in ("lead_name", "company_name", "email_id", "phone"):
+ lead_doc.set(fieldname, lead.get(fieldname))
+
lead_doc.set('lead_owner', '')
if not frappe.db.exists('Lead Source', 'Product Inquiry'):
@@ -209,6 +211,7 @@ def create_lead_for_item_inquiry(lead, subject, message):
'doctype': 'Lead Source',
'source_name' : 'Product Inquiry'
}).insert(ignore_permissions=True)
+
lead_doc.set('source', 'Product Inquiry')
try:
diff --git a/erpnext/education/report/student_fee_collection/student_fee_collection.json b/erpnext/education/report/student_fee_collection/student_fee_collection.json
index 8deb865ebcd..c0229a2ee26 100644
--- a/erpnext/education/report/student_fee_collection/student_fee_collection.json
+++ b/erpnext/education/report/student_fee_collection/student_fee_collection.json
@@ -1,5 +1,5 @@
{
- "add_total_row": 0,
+ "add_total_row": 1,
"creation": "2016-06-22 02:58:41.024538",
"disable_prepared_report": 0,
"disabled": 0,
@@ -13,7 +13,7 @@
"name": "Student Fee Collection",
"owner": "Administrator",
"prepared_report": 0,
- "query": "SELECT\n student as \"Student:Link/Student:200\",\n student_name as \"Student Name::200\",\n sum(grand_total) - sum(outstanding_amount) as \"Paid Amount:Currency:150\",\n sum(outstanding_amount) as \"Outstanding Amount:Currency:150\",\n sum(grand_total) as \"Grand Total:Currency:150\"\nFROM\n `tabFees` \nGROUP BY\n student",
+ "query": "SELECT\n student as \"Student:Link/Student:200\",\n student_name as \"Student Name::200\",\n sum(grand_total) - sum(outstanding_amount) as \"Paid Amount:Currency:150\",\n sum(outstanding_amount) as \"Outstanding Amount:Currency:150\",\n sum(grand_total) as \"Grand Total:Currency:150\"\nFROM\n `tabFees` \nWHERE\n docstatus=1 \nGROUP BY\n student",
"ref_doctype": "Fees",
"report_name": "Student Fee Collection",
"report_type": "Query Report",
@@ -22,4 +22,4 @@
"role": "Academics User"
}
]
-}
\ No newline at end of file
+}
diff --git a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py
index 192ec147e36..49edd7e6dd3 100644
--- a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py
+++ b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py
@@ -22,8 +22,7 @@ def verify_request():
)
if frappe.request.data and \
- frappe.get_request_header("X-Wc-Webhook-Signature") and \
- not sig == bytes(frappe.get_request_header("X-Wc-Webhook-Signature").encode()):
+ not sig == frappe.get_request_header("X-Wc-Webhook-Signature", "").encode():
frappe.throw(_("Unverified Webhook Data"))
frappe.set_user(woocommerce_settings.creation_user)
diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py
index 4ce85e58a61..1aef82f9fc3 100644
--- a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py
+++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py
@@ -143,6 +143,9 @@ def verify_transaction(**kwargs):
transaction_response = frappe._dict(kwargs["Body"]["stkCallback"])
checkout_id = getattr(transaction_response, "CheckoutRequestID", "")
+ if not isinstance(checkout_id, str):
+ frappe.throw(_("Invalid Checkout Request ID"))
+
integration_request = frappe.get_doc("Integration Request", checkout_id)
transaction_data = frappe._dict(loads(integration_request.data))
total_paid = 0 # for multiple integration request made against a pos invoice
@@ -233,6 +236,9 @@ def process_balance_info(**kwargs):
account_balance_response = frappe._dict(kwargs["Result"])
conversation_id = getattr(account_balance_response, "ConversationID", "")
+ if not isinstance(conversation_id, str):
+ frappe.throw(_("Invalid Conversation ID"))
+
request = frappe.get_doc("Integration Request", conversation_id)
if request.status == "Completed":
diff --git a/erpnext/erpnext_integrations/utils.py b/erpnext/erpnext_integrations/utils.py
index bb5c0c2dd10..2671ff32ce6 100644
--- a/erpnext/erpnext_integrations/utils.py
+++ b/erpnext/erpnext_integrations/utils.py
@@ -25,7 +25,6 @@ def validate_webhooks_request(doctype, hmac_key, secret_key='secret'):
)
if frappe.request.data and \
- frappe.get_request_header(hmac_key) and \
not sig == bytes(frappe.get_request_header(hmac_key).encode()):
frappe.throw(_("Unverified Webhook Data"))
frappe.set_user(settings.modified_by)
diff --git a/erpnext/healthcare/workspace/healthcare/healthcare.json b/erpnext/healthcare/workspace/healthcare/healthcare.json
index ea5c61e4da9..0384405f968 100644
--- a/erpnext/healthcare/workspace/healthcare/healthcare.json
+++ b/erpnext/healthcare/workspace/healthcare/healthcare.json
@@ -16,6 +16,7 @@
"hide_custom": 0,
"icon": "healthcare",
"idx": 0,
+ "is_default": 0,
"is_standard": 1,
"label": "Healthcare",
"links": [
@@ -534,7 +535,7 @@
"type": "Link"
}
],
- "modified": "2021-01-30 19:35:45.316999",
+ "modified": "2021-10-29 14:31:16.795628",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare",
@@ -569,8 +570,12 @@
"type": "DocType"
},
{
+ "color": "#29CD42",
+ "doc_view": "List",
+ "format": "{} Active",
"label": "Healthcare Practitioner",
"link_to": "Healthcare Practitioner",
+ "stats_filter": "{\n \"status\": \"Active\"\n}",
"type": "DocType"
},
{
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js
index bb258812b21..01cb73ef157 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.js
+++ b/erpnext/manufacturing/doctype/job_card/job_card.js
@@ -23,6 +23,12 @@ frappe.ui.form.on('Job Card', {
);
},
+ onload: function(frm) {
+ if (frm.doc.scrap_items.length == 0) {
+ frm.fields_dict['scrap_items_section'].collapse();
+ }
+ },
+
refresh: function(frm) {
frappe.flags.pause_job = 0;
frappe.flags.resume_job = 0;
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.json b/erpnext/manufacturing/doctype/job_card/job_card.json
index 8095e66eac0..dd5bb89bee3 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.json
+++ b/erpnext/manufacturing/doctype/job_card/job_card.json
@@ -397,6 +397,7 @@
"options": "Batch"
},
{
+ "collapsible": 1,
"fieldname": "scrap_items_section",
"fieldtype": "Section Break",
"label": "Scrap Items"
@@ -419,7 +420,7 @@
],
"is_submittable": 1,
"links": [],
- "modified": "2021-11-09 14:07:20.290306",
+ "modified": "2021-11-12 10:15:06.572401",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Job Card",
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index dd1df20216b..ffc375690d0 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -505,13 +505,11 @@ class JobCard(Document):
self.status = 'Work In Progress'
if (self.docstatus == 1 and
- (self.for_quantity <= self.transferred_qty or not self.items)):
- # consider excess transfer
- # completed qty is checked via separate validation
+ (self.for_quantity <= self.total_completed_qty or not self.items)):
self.status = 'Completed'
if self.status != 'Completed':
- if self.for_quantity == self.transferred_qty:
+ if self.for_quantity <= self.transferred_qty:
self.status = 'Material Transferred'
if update_status:
@@ -629,17 +627,22 @@ def make_material_request(source_name, target_doc=None):
@frappe.whitelist()
def make_stock_entry(source_name, target_doc=None):
- def update_item(obj, target, source_parent):
+ def update_item(source, target, source_parent):
target.t_warehouse = source_parent.wip_warehouse
+
if not target.conversion_factor:
target.conversion_factor = 1
+ pending_rm_qty = flt(source.required_qty) - flt(source.transferred_qty)
+ if pending_rm_qty > 0:
+ target.qty = pending_rm_qty
+
def set_missing_values(source, target):
target.purpose = "Material Transfer for Manufacture"
target.from_bom = 1
# avoid negative 'For Quantity'
- pending_fg_qty = source.get('for_quantity', 0) - source.get('transferred_qty', 0)
+ pending_fg_qty = flt(source.get('for_quantity', 0)) - flt(source.get('transferred_qty', 0))
target.fg_completed_qty = pending_fg_qty if pending_fg_qty > 0 else 0
target.set_transfer_qty()
diff --git a/erpnext/manufacturing/doctype/job_card/test_job_card.py b/erpnext/manufacturing/doctype/job_card/test_job_card.py
index ea5d364a9ce..ee6c60648e6 100644
--- a/erpnext/manufacturing/doctype/job_card/test_job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/test_job_card.py
@@ -16,11 +16,22 @@ from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
class TestJobCard(unittest.TestCase):
-
def setUp(self):
+ make_bom_for_jc_tests()
+
transfer_material_against, source_warehouse = None, None
- tests_that_transfer_against_jc = ("test_job_card_multiple_materials_transfer",
- "test_job_card_excess_material_transfer")
+
+ tests_that_skip_setup = (
+ "test_job_card_material_transfer_correctness",
+ )
+ tests_that_transfer_against_jc = (
+ "test_job_card_multiple_materials_transfer",
+ "test_job_card_excess_material_transfer",
+ "test_job_card_partial_material_transfer"
+ )
+
+ if self._testMethodName in tests_that_skip_setup:
+ return
if self._testMethodName in tests_that_transfer_against_jc:
transfer_material_against = "Job Card"
@@ -191,4 +202,132 @@ class TestJobCard(unittest.TestCase):
job_card.submit()
# JC is Completed with excess transfer
- self.assertEqual(job_card.status, "Completed")
\ No newline at end of file
+ self.assertEqual(job_card.status, "Completed")
+
+ def test_job_card_partial_material_transfer(self):
+ "Test partial material transfer against Job Card"
+
+ make_stock_entry(item_code="_Test Item", target="Stores - _TC",
+ qty=25, basic_rate=100)
+ make_stock_entry(item_code="_Test Item Home Desktop Manufactured",
+ target="Stores - _TC", qty=15, basic_rate=100)
+
+ job_card_name = frappe.db.get_value("Job Card", {'work_order': self.work_order.name})
+ job_card = frappe.get_doc("Job Card", job_card_name)
+
+ # partially transfer
+ transfer_entry = make_stock_entry_from_jc(job_card_name)
+ transfer_entry.fg_completed_qty = 1
+ transfer_entry.get_items()
+ transfer_entry.insert()
+ transfer_entry.submit()
+
+ job_card.reload()
+ self.assertEqual(job_card.transferred_qty, 1)
+ self.assertEqual(transfer_entry.items[0].qty, 5)
+ self.assertEqual(transfer_entry.items[1].qty, 3)
+
+ # transfer remaining
+ transfer_entry_2 = make_stock_entry_from_jc(job_card_name)
+
+ self.assertEqual(transfer_entry_2.fg_completed_qty, 1)
+ self.assertEqual(transfer_entry_2.items[0].qty, 5)
+ self.assertEqual(transfer_entry_2.items[1].qty, 3)
+
+ transfer_entry_2.insert()
+ transfer_entry_2.submit()
+
+ job_card.reload()
+ self.assertEqual(job_card.transferred_qty, 2)
+
+ def test_job_card_material_transfer_correctness(self):
+ """
+ 1. Test if only current Job Card Items are pulled in a Stock Entry against a Job Card
+ 2. Test impact of changing 'For Qty' in such a Stock Entry
+ """
+ create_bom_with_multiple_operations()
+ work_order = make_wo_with_transfer_against_jc()
+
+ job_card_name = frappe.db.get_value(
+ "Job Card",
+ {"work_order": work_order.name,"operation": "Test Operation A"}
+ )
+ job_card = frappe.get_doc("Job Card", job_card_name)
+
+ self.assertEqual(len(job_card.items), 1)
+ self.assertEqual(job_card.items[0].item_code, "_Test Item")
+
+ # check if right items are mapped in transfer entry
+ transfer_entry = make_stock_entry_from_jc(job_card_name)
+ transfer_entry.insert()
+
+ self.assertEqual(len(transfer_entry.items), 1)
+ self.assertEqual(transfer_entry.items[0].item_code, "_Test Item")
+ self.assertEqual(transfer_entry.items[0].qty, 4)
+
+ # change 'For Qty' and check impact on items table
+ # no.of items should be the same with qty change
+ transfer_entry.fg_completed_qty = 2
+ transfer_entry.get_items()
+
+ self.assertEqual(len(transfer_entry.items), 1)
+ self.assertEqual(transfer_entry.items[0].item_code, "_Test Item")
+ self.assertEqual(transfer_entry.items[0].qty, 2)
+
+ # rollback via tearDown method
+
+def create_bom_with_multiple_operations():
+ "Create a BOM with multiple operations and Material Transfer against Job Card"
+ from erpnext.manufacturing.doctype.operation.test_operation import make_operation
+
+ test_record = frappe.get_test_records("BOM")[2]
+ bom_doc = frappe.get_doc(test_record)
+
+ row = {
+ "operation": "Test Operation A",
+ "workstation": "_Test Workstation A",
+ "hour_rate_rent": 300,
+ "time_in_mins": 60
+ }
+ make_workstation(row)
+ make_operation(row)
+
+ bom_doc.append("operations", {
+ "operation": "Test Operation A",
+ "description": "Test Operation A",
+ "workstation": "_Test Workstation A",
+ "hour_rate": 300,
+ "time_in_mins": 60,
+ "operating_cost": 100
+ })
+
+ bom_doc.transfer_material_against = "Job Card"
+ bom_doc.save()
+ bom_doc.submit()
+
+ return bom_doc
+
+def make_wo_with_transfer_against_jc():
+ "Create a WO with multiple operations and Material Transfer against Job Card"
+
+ work_order = make_wo_order_test_record(
+ item="_Test FG Item 2",
+ qty=4,
+ transfer_material_against="Job Card",
+ source_warehouse="Stores - _TC",
+ do_not_submit=True
+ )
+ work_order.required_items[0].operation = "Test Operation A"
+ work_order.required_items[1].operation = "_Test Operation 1"
+ work_order.submit()
+
+ return work_order
+
+def make_bom_for_jc_tests():
+ test_records = frappe.get_test_records('BOM')
+ bom = frappe.copy_doc(test_records[2])
+ bom.set_rate_of_sub_assembly_item_based_on_bom = 0
+ bom.rm_cost_as_per = "Valuation Rate"
+ bom.items[0].uom = "_Test UOM 1"
+ bom.items[0].conversion_factor = 5
+ bom.insert()
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/operation/test_operation.py b/erpnext/manufacturing/doctype/operation/test_operation.py
index 2b24118fc41..c216e1b73de 100644
--- a/erpnext/manufacturing/doctype/operation/test_operation.py
+++ b/erpnext/manufacturing/doctype/operation/test_operation.py
@@ -18,15 +18,13 @@ def make_operation(*args, **kwargs):
args = frappe._dict(args)
- try:
+ if not frappe.db.exists("Operation", args.operation):
doc = frappe.get_doc({
"doctype": "Operation",
"name": args.operation,
"workstation": args.workstation
})
-
doc.insert()
-
return doc
- except frappe.DuplicateEntryError:
- return frappe.get_doc("Operation", args.operation)
+
+ return frappe.get_doc("Operation", args.operation)
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js
index 6f81c17adb1..d94d37aa9d8 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.js
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js
@@ -105,7 +105,7 @@ frappe.ui.form.on('Production Plan', {
}
frm.trigger("material_requirement");
- const projected_qty_formula = `
+ const projected_qty_formula = `
diff --git a/erpnext/manufacturing/doctype/workstation/test_workstation.py b/erpnext/manufacturing/doctype/workstation/test_workstation.py
index 6c6ab77dd8f..345a7d7d3b8 100644
--- a/erpnext/manufacturing/doctype/workstation/test_workstation.py
+++ b/erpnext/manufacturing/doctype/workstation/test_workstation.py
@@ -90,7 +90,7 @@ def make_workstation(*args, **kwargs):
args = frappe._dict(args)
workstation_name = args.workstation_name or args.workstation
- try:
+ if not frappe.db.exists("Workstation", workstation_name):
doc = frappe.get_doc({
"doctype": "Workstation",
"workstation_name": workstation_name
@@ -100,5 +100,5 @@ def make_workstation(*args, **kwargs):
doc.insert()
return doc
- except frappe.DuplicateEntryError:
- return frappe.get_doc("Workstation", workstation_name)
+
+ return frappe.get_doc("Workstation", workstation_name)
diff --git a/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py b/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py
index 9a4d0c42db4..1eb65229df2 100644
--- a/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py
+++ b/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py
@@ -29,8 +29,15 @@ def get_production_plan_item_details(filters, data, order_details):
production_plan_doc = frappe.get_cached_doc("Production Plan", filters.get("production_plan"))
for row in production_plan_doc.po_items:
- work_order = frappe.get_cached_value("Work Order", {"production_plan_item": row.name,
- "bom_no": row.bom_no, "production_item": row.item_code}, "name")
+ work_order = frappe.get_value(
+ "Work Order",
+ {
+ "production_plan_item": row.name,
+ "bom_no": row.bom_no,
+ "production_item": row.item_code
+ },
+ "name"
+ )
if row.item_code not in itemwise_indent:
itemwise_indent.setdefault(row.item_code, {})
@@ -41,10 +48,10 @@ def get_production_plan_item_details(filters, data, order_details):
"item_name": frappe.get_cached_value("Item", row.item_code, "item_name"),
"qty": row.planned_qty,
"document_type": "Work Order",
- "document_name": work_order,
+ "document_name": work_order or "",
"bom_level": frappe.get_cached_value("BOM", row.bom_no, "bom_level"),
- "produced_qty": order_details.get((work_order, row.item_code)).get("produced_qty"),
- "pending_qty": flt(row.planned_qty) - flt(order_details.get((work_order, row.item_code)).get("produced_qty"))
+ "produced_qty": order_details.get((work_order, row.item_code), {}).get("produced_qty", 0),
+ "pending_qty": flt(row.planned_qty) - flt(order_details.get((work_order, row.item_code), {}).get("produced_qty", 0))
})
get_production_plan_sub_assembly_item_details(filters, row, production_plan_doc, data, order_details)
@@ -55,11 +62,23 @@ def get_production_plan_sub_assembly_item_details(filters, row, production_plan_
subcontracted_item = (item.type_of_manufacturing == 'Subcontract')
if subcontracted_item:
- docname = frappe.get_cached_value("Purchase Order Item",
- {"production_plan_sub_assembly_item": item.name, "docstatus": ("<", 2)}, "parent")
+ docname = frappe.get_value(
+ "Purchase Order Item",
+ {
+ "production_plan_sub_assembly_item": item.name,
+ "docstatus": ("<", 2)
+ },
+ "parent"
+ )
else:
- docname = frappe.get_cached_value("Work Order",
- {"production_plan_sub_assembly_item": item.name, "docstatus": ("<", 2)}, "name")
+ docname = frappe.get_value(
+ "Work Order",
+ {
+ "production_plan_sub_assembly_item": item.name,
+ "docstatus": ("<", 2)
+ },
+ "name"
+ )
data.append({
"indent": 1,
@@ -67,10 +86,10 @@ def get_production_plan_sub_assembly_item_details(filters, row, production_plan_
"item_name": item.item_name,
"qty": item.qty,
"document_type": "Work Order" if not subcontracted_item else "Purchase Order",
- "document_name": docname,
+ "document_name": docname or "",
"bom_level": item.bom_level,
- "produced_qty": order_details.get((docname, item.production_item)).get("produced_qty"),
- "pending_qty": flt(item.qty) - flt(order_details.get((docname, item.production_item)).get("produced_qty"))
+ "produced_qty": order_details.get((docname, item.production_item), {}).get("produced_qty", 0),
+ "pending_qty": flt(item.qty) - flt(order_details.get((docname, item.production_item), {}).get("produced_qty", 0))
})
def get_work_order_details(filters, order_details):
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index a43f083141f..e6c6c80d16f 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -329,6 +329,8 @@ erpnext.patches.v13_0.trim_sales_invoice_custom_field_length
erpnext.patches.v13_0.enable_scheduler_job_for_item_reposting
erpnext.patches.v13_0.requeue_failed_reposts
erpnext.patches.v13_0.fetch_thumbnail_in_website_items
+erpnext.patches.v13_0.update_job_card_status
erpnext.patches.v12_0.update_production_plan_status
+erpnext.patches.v13_0.item_naming_series_not_mandatory
erpnext.patches.v13_0.update_category_in_ltds_certificate
erpnext.patches.v13_0.create_ksa_vat_custom_fields
diff --git a/erpnext/patches/v13_0/item_naming_series_not_mandatory.py b/erpnext/patches/v13_0/item_naming_series_not_mandatory.py
new file mode 100644
index 00000000000..5fe85a48308
--- /dev/null
+++ b/erpnext/patches/v13_0/item_naming_series_not_mandatory.py
@@ -0,0 +1,11 @@
+import frappe
+
+from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
+
+
+def execute():
+
+ stock_settings = frappe.get_doc("Stock Settings")
+
+ set_by_naming_series("Item", "item_code",
+ stock_settings.get("item_naming_by")=="Naming Series", hide_name_field=True, make_mandatory=0)
diff --git a/erpnext/patches/v13_0/update_job_card_status.py b/erpnext/patches/v13_0/update_job_card_status.py
new file mode 100644
index 00000000000..797a3e2ae35
--- /dev/null
+++ b/erpnext/patches/v13_0/update_job_card_status.py
@@ -0,0 +1,18 @@
+# Copyright (c) 2021, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe
+
+
+def execute():
+
+ job_card = frappe.qb.DocType("Job Card")
+ (frappe.qb
+ .update(job_card)
+ .set(job_card.status, "Completed")
+ .where(
+ (job_card.docstatus == 1)
+ & (job_card.for_quantity <= job_card.total_completed_qty)
+ & (job_card.status.isin(["Work In Progress", "Material Transferred"]))
+ )
+ ).run()
diff --git a/erpnext/payroll/report/salary_register/salary_register.py b/erpnext/payroll/report/salary_register/salary_register.py
index 2a9dad66e25..5fadb133963 100644
--- a/erpnext/payroll/report/salary_register/salary_register.py
+++ b/erpnext/payroll/report/salary_register/salary_register.py
@@ -135,11 +135,11 @@ def get_ss_earning_map(salary_slips, currency, company_currency):
ss_earning_map = {}
for d in ss_earnings:
- ss_earning_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, [])
+ ss_earning_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, 0.0)
if currency == company_currency:
- ss_earning_map[d.parent][d.salary_component] = flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
+ ss_earning_map[d.parent][d.salary_component] += flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
else:
- ss_earning_map[d.parent][d.salary_component] = flt(d.amount)
+ ss_earning_map[d.parent][d.salary_component] += flt(d.amount)
return ss_earning_map
@@ -150,10 +150,10 @@ def get_ss_ded_map(salary_slips, currency, company_currency):
ss_ded_map = {}
for d in ss_deductions:
- ss_ded_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, [])
+ ss_ded_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, 0.0)
if currency == company_currency:
- ss_ded_map[d.parent][d.salary_component] = flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
+ ss_ded_map[d.parent][d.salary_component] += flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
else:
- ss_ded_map[d.parent][d.salary_component] = flt(d.amount)
+ ss_ded_map[d.parent][d.salary_component] += flt(d.amount)
return ss_ded_map
diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py
index cd2c8a26b1c..b0b40758ab0 100644
--- a/erpnext/regional/india/e_invoice/utils.py
+++ b/erpnext/regional/india/e_invoice/utils.py
@@ -936,7 +936,7 @@ class GSPConnector():
if errors:
frappe.throw(errors, title=title, as_list=1)
else:
- link_to_error_list = 'Error Log'
+ link_to_error_list = 'Error Log'
frappe.msgprint(
_('An error occurred while making e-invoicing request. Please check {} for more information.').format(link_to_error_list),
title=title,
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 254a293dbf9..b7c47dcc248 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -29,12 +29,13 @@ def validate_gstin_for_india(doc, method):
gst_category = []
- if len(doc.links):
- link_doctype = doc.links[0].get("link_doctype")
- link_name = doc.links[0].get("link_name")
+ if hasattr(doc, 'gst_category'):
+ if len(doc.links):
+ link_doctype = doc.links[0].get("link_doctype")
+ link_name = doc.links[0].get("link_name")
- if link_doctype in ["Customer", "Supplier"]:
- gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
+ if link_doctype in ["Customer", "Supplier"]:
+ gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
doc.gstin = doc.gstin.upper().strip()
if not doc.gstin or doc.gstin == 'NA':
@@ -76,12 +77,11 @@ def validate_tax_category(doc, method):
frappe.throw(_("Intra State tax category for GST State {0} already exists").format(doc.gst_state))
def update_gst_category(doc, method):
- for link in doc.links:
- if link.link_doctype in ['Customer', 'Supplier']:
- if doc.get('gstin'):
- frappe.db.sql("""
- UPDATE `tab{0}` SET gst_category = %s WHERE name = %s AND gst_category = 'Unregistered'
- """.format(link.link_doctype), ("Registered Regular", link.link_name)) #nosec
+ if hasattr(doc, 'gst_category'):
+ for link in doc.links:
+ if link.link_doctype in ['Customer', 'Supplier']:
+ if doc.get('gstin'):
+ frappe.db.set_value(link.link_doctype, {'name': link.link_name, 'gst_category': 'Unregistered'}, 'gst_category', 'Registered Regular')
def set_gst_state_and_state_number(doc):
if not doc.gst_state:
diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py
index 7d401bab669..d3d8b3b9c41 100644
--- a/erpnext/regional/report/gstr_1/gstr_1.py
+++ b/erpnext/regional/report/gstr_1/gstr_1.py
@@ -250,18 +250,17 @@ class Gstr1Report(object):
""" % (self.doctype, ', '.join(['%s']*len(self.invoices))), tuple(self.invoices), as_dict=1)
for d in items:
- if d.item_code not in self.invoice_items.get(d.parent, {}):
- self.invoice_items.setdefault(d.parent, {}).setdefault(d.item_code, 0.0)
- self.invoice_items[d.parent][d.item_code] += d.get('taxable_value', 0) or d.get('base_net_amount', 0)
+ self.invoice_items.setdefault(d.parent, {}).setdefault(d.item_code, 0.0)
+ self.invoice_items[d.parent][d.item_code] += d.get('taxable_value', 0) or d.get('base_net_amount', 0)
- item_tax_rate = {}
+ item_tax_rate = {}
- if d.item_tax_rate:
- item_tax_rate = json.loads(d.item_tax_rate)
+ if d.item_tax_rate:
+ item_tax_rate = json.loads(d.item_tax_rate)
- for account, rate in item_tax_rate.items():
- tax_rate_dict = self.item_tax_rate.setdefault(d.parent, {}).setdefault(d.item_code, [])
- tax_rate_dict.append(rate)
+ for account, rate in item_tax_rate.items():
+ tax_rate_dict = self.item_tax_rate.setdefault(d.parent, {}).setdefault(d.item_code, [])
+ tax_rate_dict.append(rate)
def get_items_based_on_tax_rate(self):
self.tax_details = frappe.db.sql("""
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index b8b023307f2..886ed071716 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -319,7 +319,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
title: __('Select Items to Manufacture'),
fields: fields,
primary_action: function() {
- var data = d.get_values();
+ var data = {items: d.fields_dict.items.grid.get_selected_children()};
me.frm.call({
method: 'make_work_orders',
args: {
diff --git a/erpnext/selling/doctype/sales_team/sales_team.json b/erpnext/selling/doctype/sales_team/sales_team.json
index 876789135c8..cac5b763ffd 100644
--- a/erpnext/selling/doctype/sales_team/sales_team.json
+++ b/erpnext/selling/doctype/sales_team/sales_team.json
@@ -1,247 +1,100 @@
{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
- "creation": "2013-04-19 13:30:51",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Setup",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "creation": "2013-04-19 13:30:51",
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "sales_person",
+ "contact_no",
+ "allocated_percentage",
+ "allocated_amount",
+ "commission_rate",
+ "incentives"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "sales_person",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Sales Person",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "sales_person",
- "oldfieldtype": "Link",
- "options": "Sales Person",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": "200px",
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 1,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0,
+ "allow_on_submit": 1,
+ "fieldname": "sales_person",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Sales Person",
+ "oldfieldname": "sales_person",
+ "oldfieldtype": "Link",
+ "options": "Sales Person",
+ "print_width": "200px",
+ "reqd": 1,
+ "search_index": 1,
"width": "200px"
- },
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "contact_no",
- "fieldtype": "Data",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Contact No.",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "contact_no",
- "oldfieldtype": "Data",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": "100px",
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0,
+ "allow_on_submit": 1,
+ "fieldname": "contact_no",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "in_list_view": 1,
+ "label": "Contact No.",
+ "oldfieldname": "contact_no",
+ "oldfieldtype": "Data",
+ "print_width": "100px",
"width": "100px"
- },
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "allocated_percentage",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Contribution (%)",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "allocated_percentage",
- "oldfieldtype": "Currency",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": "100px",
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0,
+ "allow_on_submit": 1,
+ "fieldname": "allocated_percentage",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Contribution (%)",
+ "oldfieldname": "allocated_percentage",
+ "oldfieldtype": "Currency",
+ "print_width": "100px",
"width": "100px"
- },
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "allocated_amount",
- "fieldtype": "Currency",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Contribution to Net Total",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "allocated_amount",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": "120px",
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0,
+ "allow_on_submit": 1,
+ "fieldname": "allocated_amount",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Contribution to Net Total",
+ "oldfieldname": "allocated_amount",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "print_width": "120px",
+ "read_only": 1,
"width": "120px"
- },
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "commission_rate",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Commission Rate",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fetch_from": "sales_person.commission_rate",
+ "fetch_if_empty": 1,
+ "fieldname": "commission_rate",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Commission Rate",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "incentives",
- "fieldtype": "Currency",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Incentives",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "incentives",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "allow_on_submit": 1,
+ "fieldname": "incentives",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Incentives",
+ "oldfieldname": "incentives",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency"
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 1,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 1,
- "max_attachments": 0,
- "modified": "2018-09-17 13:03:14.755974",
- "modified_by": "Administrator",
- "module": "Selling",
- "name": "Sales Team",
- "owner": "Administrator",
- "permissions": [],
- "quick_entry": 1,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
-}
+ ],
+ "idx": 1,
+ "istable": 1,
+ "links": [],
+ "modified": "2021-11-09 23:55:20.670475",
+ "modified_by": "Administrator",
+ "module": "Selling",
+ "name": "Sales Team",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index fdc55f3ab5e..aebc273e4cc 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -111,6 +111,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
erpnext.utils.set_taxes_from_address(this.frm, "shipping_address_name", "customer_address", "shipping_address_name");
},
+ dispatch_address_name: function() {
+ erpnext.utils.get_address_display(this.frm, "dispatch_address_name", "dispatch_address");
+ },
+
sales_partner: function() {
this.apply_pricing_rule();
},
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index b69d9b0e4c8..59ef566a588 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -41,7 +41,6 @@ class ItemGroup(NestedSet, WebsiteGenerator):
def on_update(self):
NestedSet.on_update(self)
invalidate_cache_for(self)
- self.validate_name_with_item()
self.validate_one_root()
self.delete_child_item_groups_key()
@@ -65,10 +64,6 @@ class ItemGroup(NestedSet, WebsiteGenerator):
WebsiteGenerator.on_trash(self)
self.delete_child_item_groups_key()
- def validate_name_with_item(self):
- if frappe.db.exists("Item", self.name):
- frappe.throw(frappe._("An item exists with same name ({0}), please change the item group name or rename the item").format(self.name), frappe.NameError)
-
def get_context(self, context):
context.show_search = True
context.body_class = "product-page"
diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py
index 005cfec769a..c7b196651d0 100644
--- a/erpnext/setup/doctype/naming_series/naming_series.py
+++ b/erpnext/setup/doctype/naming_series/naming_series.py
@@ -181,11 +181,11 @@ class NamingSeries(Document):
prefix = parse_naming_series(parts)
return prefix
-def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True):
+def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True, make_mandatory=1):
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
if naming_series:
make_property_setter(doctype, "naming_series", "hidden", 0, "Check", validate_fields_for_doctype=False)
- make_property_setter(doctype, "naming_series", "reqd", 1, "Check", validate_fields_for_doctype=False)
+ make_property_setter(doctype, "naming_series", "reqd", make_mandatory, "Check", validate_fields_for_doctype=False)
# set values for mandatory
try:
diff --git a/erpnext/setup/setup_wizard/data/country_wise_tax.json b/erpnext/setup/setup_wizard/data/country_wise_tax.json
index 08fef32d849..14b79510c12 100644
--- a/erpnext/setup/setup_wizard/data/country_wise_tax.json
+++ b/erpnext/setup/setup_wizard/data/country_wise_tax.json
@@ -1195,7 +1195,7 @@
"*": {
"item_tax_templates": [
{
- "title": "GST 9%",
+ "title": "GST 18%",
"taxes": [
{
"tax_type": {
diff --git a/erpnext/setup/workspace/erpnext_settings/erpnext_settings.json b/erpnext/setup/workspace/erpnext_settings/erpnext_settings.json
index db171fa9627..2e42c41f2b6 100644
--- a/erpnext/setup/workspace/erpnext_settings/erpnext_settings.json
+++ b/erpnext/setup/workspace/erpnext_settings/erpnext_settings.json
@@ -16,7 +16,7 @@
"is_standard": 1,
"label": "ERPNext Settings",
"links": [],
- "modified": "2021-10-26 21:32:55.323591",
+ "modified": "2021-11-12 01:32:55.323591",
"modified_by": "Administrator",
"module": "Setup",
"name": "ERPNext Settings",
@@ -76,8 +76,8 @@
},
{
"icon": "retail",
- "label": "Shopping Cart Settings",
- "link_to": "Shopping Cart Settings",
+ "label": "E Commerce Settings",
+ "link_to": "E Commerce Settings",
"type": "DocType"
},
{
@@ -119,13 +119,6 @@
"label": "Domain Settings",
"link_to": "Domain Settings",
"type": "DocType"
- },
- {
- "doc_view": "",
- "icon": "retail",
- "label": "Products Settings",
- "link_to": "Products Settings",
- "type": "DocType"
}
]
}
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index ba7ace20cbf..8f2985e2c21 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -131,7 +131,6 @@ class Item(Document):
def on_update(self):
invalidate_cache_for_item(self)
- self.validate_name_with_item_group()
self.update_variants()
self.update_item_price()
self.update_website_item()
@@ -377,12 +376,6 @@ class Item(Document):
where item_code = %s and is_cancelled = 0 limit 1""", self.name))
return self._stock_ledger_created
- def validate_name_with_item_group(self):
- # causes problem with tree build
- if frappe.db.exists("Item Group", self.name):
- frappe.throw(
- _("An Item Group exists with same name, please change the item name or rename the item group"))
-
def update_item_price(self):
frappe.db.sql("""
UPDATE `tabItem Price`
@@ -417,6 +410,8 @@ class Item(Document):
def after_rename(self, old_name, new_name, merge):
if merge:
self.validate_duplicate_item_in_stock_reconciliation(old_name, new_name)
+ frappe.msgprint(_("It can take upto few hours for accurate stock values to be visible after merging items."),
+ indicator="orange", title="Note")
if self.published_in_website:
invalidate_cache_for_item(self)
diff --git a/erpnext/stock/doctype/item_price/item_price.py b/erpnext/stock/doctype/item_price/item_price.py
index 3f0fc4136b0..197b147e7ee 100644
--- a/erpnext/stock/doctype/item_price/item_price.py
+++ b/erpnext/stock/doctype/item_price/item_price.py
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
+from frappe.utils import getdate
class ItemPriceDuplicateItem(frappe.ValidationError):
@@ -27,7 +28,7 @@ class ItemPrice(Document):
def validate_dates(self):
if self.valid_from and self.valid_upto:
- if self.valid_from > self.valid_upto:
+ if getdate(self.valid_from) > getdate(self.valid_upto):
frappe.throw(_("Valid From Date must be lesser than Valid Upto Date."))
def update_price_list_details(self):
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
index 1abbc35334f..d8168941b3c 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
@@ -35,7 +35,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
refresh: function() {
var help_content =
`
-
+
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index f06c12359da..72907cee65d 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -1085,6 +1085,7 @@ class TestPurchaseReceipt(ERPNextTestCase):
automatically_fetch_payment_terms()
+
po = create_purchase_order(qty=10, rate=100, do_not_save=1)
create_payment_terms_template()
po.payment_terms_template = 'Test Receivable Template'
diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
index 8f3ae23dcef..07433bd8d8c 100644
--- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
+++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
@@ -33,6 +33,9 @@ class RepostItemValuation(Document):
self.voucher_type = None
self.voucher_no = None
+ self.allow_negative_stock = self.allow_negative_stock or \
+ cint(frappe.db.get_single_value("Stock Settings", "allow_negative_stock"))
+
def set_company(self):
if self.voucher_type and self.voucher_no:
self.company = frappe.get_cached_value(self.voucher_type, self.voucher_no, "company")
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index bf3127555ba..e565012bd00 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -1452,7 +1452,7 @@ class StockEntry(StockController):
item_dict[item]["qty"] = 0
# delete items with 0 qty
- list_of_items = item_dict.keys()
+ list_of_items = list(item_dict.keys())
for item in list_of_items:
if not item_dict[item]["qty"]:
del item_dict[item]
@@ -1464,52 +1464,94 @@ class StockEntry(StockController):
return item_dict
def get_pro_order_required_items(self, backflush_based_on=None):
- item_dict = frappe._dict()
- pro_order = frappe.get_doc("Work Order", self.work_order)
- if not frappe.db.get_value("Warehouse", pro_order.wip_warehouse, "is_group"):
- wip_warehouse = pro_order.wip_warehouse
+ """
+ Gets Work Order Required Items only if Stock Entry purpose is **Material Transferred for Manufacture**.
+ """
+ item_dict, job_card_items = frappe._dict(), []
+ work_order = frappe.get_doc("Work Order", self.work_order)
+
+ consider_job_card = work_order.transfer_material_against == "Job Card" and self.get("job_card")
+ if consider_job_card:
+ job_card_items = self.get_job_card_item_codes(self.get("job_card"))
+
+ if not frappe.db.get_value("Warehouse", work_order.wip_warehouse, "is_group"):
+ wip_warehouse = work_order.wip_warehouse
else:
wip_warehouse = None
- for d in pro_order.get("required_items"):
- if ( ((flt(d.required_qty) > flt(d.transferred_qty)) or
- (backflush_based_on == "Material Transferred for Manufacture")) and
- (d.include_item_in_manufacturing or self.purpose != "Material Transfer for Manufacture")):
+ for d in work_order.get("required_items"):
+ if consider_job_card and (d.item_code not in job_card_items):
+ continue
+
+ transfer_pending = flt(d.required_qty) > flt(d.transferred_qty)
+ can_transfer = transfer_pending or (backflush_based_on == "Material Transferred for Manufacture")
+
+ if not can_transfer:
+ continue
+
+ if d.include_item_in_manufacturing:
item_row = d.as_dict()
+ item_row["idx"] = len(item_dict) + 1
+
+ if consider_job_card:
+ job_card_item = frappe.db.get_value(
+ "Job Card Item",
+ {
+ "item_code": d.item_code,
+ "parent": self.get("job_card")
+ }
+ )
+ item_row["job_card_item"] = job_card_item or None
+
if d.source_warehouse and not frappe.db.get_value("Warehouse", d.source_warehouse, "is_group"):
item_row["from_warehouse"] = d.source_warehouse
item_row["to_warehouse"] = wip_warehouse
if item_row["allow_alternative_item"]:
- item_row["allow_alternative_item"] = pro_order.allow_alternative_item
+ item_row["allow_alternative_item"] = work_order.allow_alternative_item
item_dict.setdefault(d.item_code, item_row)
return item_dict
+ def get_job_card_item_codes(self, job_card=None):
+ if not job_card:
+ return []
+
+ job_card_items = frappe.get_all(
+ "Job Card Item",
+ filters={
+ "parent": job_card
+ },
+ fields=["item_code"],
+ distinct=True
+ )
+ return [d.item_code for d in job_card_items]
+
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
for d in item_dict:
- stock_uom = item_dict[d].get("stock_uom") or frappe.db.get_value("Item", d, "stock_uom")
+ item_row = item_dict[d]
+ stock_uom = item_row.get("stock_uom") or frappe.db.get_value("Item", d, "stock_uom")
se_child = self.append('items')
- se_child.s_warehouse = item_dict[d].get("from_warehouse")
- se_child.t_warehouse = item_dict[d].get("to_warehouse")
- se_child.item_code = item_dict[d].get('item_code') or cstr(d)
- se_child.uom = item_dict[d]["uom"] if item_dict[d].get("uom") else stock_uom
+ se_child.s_warehouse = item_row.get("from_warehouse")
+ se_child.t_warehouse = item_row.get("to_warehouse")
+ se_child.item_code = item_row.get('item_code') or cstr(d)
+ se_child.uom = item_row["uom"] if item_row.get("uom") else stock_uom
se_child.stock_uom = stock_uom
- se_child.qty = flt(item_dict[d]["qty"], se_child.precision("qty"))
- se_child.allow_alternative_item = item_dict[d].get("allow_alternative_item", 0)
- se_child.subcontracted_item = item_dict[d].get("main_item_code")
- se_child.cost_center = (item_dict[d].get("cost_center") or
- get_default_cost_center(item_dict[d], company = self.company))
- se_child.is_finished_item = item_dict[d].get("is_finished_item", 0)
- se_child.is_scrap_item = item_dict[d].get("is_scrap_item", 0)
- se_child.is_process_loss = item_dict[d].get("is_process_loss", 0)
+ se_child.qty = flt(item_row["qty"], se_child.precision("qty"))
+ se_child.allow_alternative_item = item_row.get("allow_alternative_item", 0)
+ se_child.subcontracted_item = item_row.get("main_item_code")
+ se_child.cost_center = (item_row.get("cost_center") or
+ get_default_cost_center(item_row, company = self.company))
+ se_child.is_finished_item = item_row.get("is_finished_item", 0)
+ se_child.is_scrap_item = item_row.get("is_scrap_item", 0)
+ se_child.is_process_loss = item_row.get("is_process_loss", 0)
for field in ["idx", "po_detail", "original_item", "expense_account",
"description", "item_name", "serial_no", "batch_no", "allow_zero_valuation_rate"]:
- if item_dict[d].get(field):
- se_child.set(field, item_dict[d].get(field))
+ if item_row.get(field):
+ se_child.set(field, item_row.get(field))
if se_child.s_warehouse==None:
se_child.s_warehouse = self.from_warehouse
@@ -1517,12 +1559,11 @@ class StockEntry(StockController):
se_child.t_warehouse = self.to_warehouse
# in stock uom
- se_child.conversion_factor = flt(item_dict[d].get("conversion_factor")) or 1
- se_child.transfer_qty = flt(item_dict[d]["qty"]*se_child.conversion_factor, se_child.precision("qty"))
+ se_child.conversion_factor = flt(item_row.get("conversion_factor")) or 1
+ se_child.transfer_qty = flt(item_row["qty"]*se_child.conversion_factor, se_child.precision("qty"))
-
- # to be assigned for finished item
- se_child.bom_no = bom_no
+ se_child.bom_no = bom_no # to be assigned for finished item
+ se_child.job_card_item = item_row.get("job_card_item") if self.get("job_card") else None
def validate_with_material_request(self):
for item in self.get("items"):
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json
index f75cb561385..33d9a6ce414 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.json
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.json
@@ -21,6 +21,7 @@
"mr_qty_allowance",
"column_break_12",
"auto_insert_price_list_rate_if_missing",
+ "update_existing_price_list_rate",
"allow_negative_stock",
"show_barcode_field",
"clean_description_html",
@@ -290,6 +291,13 @@
"fieldname": "mr_qty_allowance",
"fieldtype": "Float",
"label": "Over Transfer Allowance"
+ },
+ {
+ "default": "0",
+ "depends_on": "auto_insert_price_list_rate_if_missing",
+ "fieldname": "update_existing_price_list_rate",
+ "fieldtype": "Check",
+ "label": "Update Existing Price List Rate"
}
],
"icon": "icon-cog",
@@ -297,7 +305,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2021-06-28 17:02:26.683002",
+ "modified": "2021-11-06 19:40:02.183592",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Settings",
@@ -317,4 +325,4 @@
"sort_field": "modified",
"sort_order": "ASC",
"track_changes": 1
-}
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py
index 2a634b3d16b..c837e632a27 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.py
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.py
@@ -21,7 +21,7 @@ class StockSettings(Document):
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
set_by_naming_series("Item", "item_code",
- self.get("item_naming_by")=="Naming Series", hide_name_field=True)
+ self.get("item_naming_by")=="Naming Series", hide_name_field=True, make_mandatory=0)
stock_frozen_limit = 356
submitted_stock_frozen = self.stock_frozen_upto_days or 0
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index e0190b64a75..0d78607118e 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -708,7 +708,7 @@ def insert_item_price(args):
{'item_code': args.item_code, 'price_list': args.price_list, 'currency': args.currency},
['name', 'price_list_rate'], as_dict=1)
if item_price and item_price.name:
- if item_price.price_list_rate != price_list_rate:
+ if item_price.price_list_rate != price_list_rate and frappe.db.get_single_value('Stock Settings', 'update_existing_price_list_rate'):
frappe.db.set_value('Item Price', item_price.name, "price_list_rate", price_list_rate)
frappe.msgprint(_("Item Price updated for {0} in Price List {1}").format(args.item_code,
args.price_list), alert=True)
diff --git a/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.py b/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.py
index cf273265599..7d7e9644854 100644
--- a/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.py
+++ b/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.py
@@ -47,7 +47,7 @@ def get_incorrect_data(data):
return row
def get_stock_ledger_entries(report_filters):
- filters = {}
+ filters = {"is_cancelled": 0}
fields = ['name', 'voucher_type', 'voucher_no', 'item_code', 'actual_qty',
'posting_date', 'posting_time', 'company', 'warehouse', 'qty_after_transaction', 'batch_no']
diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.json b/erpnext/support/doctype/warranty_claim/warranty_claim.json
index 88ee4a3bebd..45485ca2c2f 100644
--- a/erpnext/support/doctype/warranty_claim/warranty_claim.json
+++ b/erpnext/support/doctype/warranty_claim/warranty_claim.json
@@ -256,6 +256,7 @@
"fieldname": "contact_email",
"fieldtype": "Data",
"label": "Contact Email",
+ "options": "Email",
"read_only": 1
},
{
@@ -361,7 +362,7 @@
],
"icon": "fa fa-bug",
"idx": 1,
- "modified": "2020-09-18 17:26:09.703215",
+ "modified": "2021-11-09 17:26:09.703215",
"modified_by": "Administrator",
"module": "Support",
"name": "Warranty Claim",
@@ -385,4 +386,4 @@
"sort_order": "DESC",
"timeline_field": "customer",
"title_field": "customer_name"
-}
\ No newline at end of file
+}
| | | | |