Merge branch 'develop' into workstation-type-feat-for-bom
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index dc3011f..73aae33 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -16,8 +16,8 @@
- id: check-merge-conflict
- id: check-ast
- - repo: https://gitlab.com/pycqa/flake8
- rev: 3.9.2
+ - repo: https://github.com/PyCQA/flake8
+ rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: [
diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.js b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.js
index 750e129..8a6b021 100644
--- a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.js
+++ b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.js
@@ -3,10 +3,6 @@
frappe.ui.form.on('Accounting Dimension Filter', {
refresh: function(frm, cdt, cdn) {
- if (frm.doc.accounting_dimension) {
- frm.set_df_property('dimensions', 'label', frm.doc.accounting_dimension, cdn, 'dimension_value');
- }
-
let help_content =
`<table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
<tr><td>
@@ -68,6 +64,7 @@
frm.clear_table("dimensions");
let row = frm.add_child("dimensions");
row.accounting_dimension = frm.doc.accounting_dimension;
+ frm.fields_dict["dimensions"].grid.update_docfield_property("dimension_value", "label", frm.doc.accounting_dimension);
frm.refresh_field("dimensions");
frm.trigger('setup_filters');
},
diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js
index cf5fbe1..88f1c90 100644
--- a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js
+++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js
@@ -45,21 +45,6 @@
frm.trigger("clear_child");
switch(frm.doc.voucher_type){
- case "Opening Entry":
- frm.set_value("is_opening", "Yes");
- frappe.call({
- type:"GET",
- method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_opening_accounts",
- args: {
- "company": frm.doc.company
- },
- callback: function(r) {
- if(r.message) {
- add_accounts(frm.doc, r.message);
- }
- }
- });
- break;
case "Bank Entry":
case "Cash Entry":
frappe.call({
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 9487489..51b134a 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -62,7 +62,6 @@
self.set_missing_values()
self.validate_payment_type()
self.validate_party_details()
- self.validate_bank_accounts()
self.set_exchange_rate()
self.validate_mandatory()
self.validate_reference_documents()
@@ -243,23 +242,6 @@
if not frappe.db.exists(self.party_type, self.party):
frappe.throw(_("Invalid {0}: {1}").format(self.party_type, self.party))
- if self.party_account and self.party_type in ("Customer", "Supplier"):
- self.validate_account_type(
- self.party_account, [erpnext.get_party_account_type(self.party_type)]
- )
-
- def validate_bank_accounts(self):
- if self.payment_type in ("Pay", "Internal Transfer"):
- self.validate_account_type(self.paid_from, ["Bank", "Cash"])
-
- if self.payment_type in ("Receive", "Internal Transfer"):
- self.validate_account_type(self.paid_to, ["Bank", "Cash"])
-
- def validate_account_type(self, account, account_types):
- account_type = frappe.db.get_value("Account", account, "account_type")
- # if account_type not in account_types:
- # frappe.throw(_("Account Type for {0} must be {1}").format(account, comma_or(account_types)))
-
def set_exchange_rate(self, ref_doc=None):
self.set_source_exchange_rate(ref_doc)
self.set_target_exchange_rate(ref_doc)
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 15d1d25..dc2f9a9 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -2098,7 +2098,7 @@
{
"collapsible": 1,
"collapsible_depends_on": "write_off_amount",
- "depends_on": "grand_total",
+ "depends_on": "is_pos",
"fieldname": "write_off_section",
"fieldtype": "Section Break",
"hide_days": 1,
@@ -2126,7 +2126,7 @@
"link_fieldname": "consolidated_invoice"
}
],
- "modified": "2022-11-07 16:02:07.972258",
+ "modified": "2022-11-15 09:33:47.870616",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 911440f..62cf0dc 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -571,13 +571,14 @@
# validate if deferred revenue is enabled for any item
# Don't allow to update the invoice if deferred revenue is enabled
- for item in self.get("items"):
- if item.enable_deferred_revenue:
- frappe.throw(
- _(
- "Deferred Revenue is enabled for item {0}. You cannot update the invoice after submission."
- ).format(item.item_code)
- )
+ if needs_repost:
+ for item in self.get("items"):
+ if item.enable_deferred_revenue:
+ frappe.throw(
+ _(
+ "Deferred Revenue is enabled for item {0}. You cannot update the invoice after submission."
+ ).format(item.item_code)
+ )
self.db_set("repost_required", needs_repost)
@@ -1393,7 +1394,11 @@
def make_write_off_gl_entry(self, gl_entries):
# write off entries, applicable if only pos
- if self.write_off_account and flt(self.write_off_amount, self.precision("write_off_amount")):
+ if (
+ self.is_pos
+ and self.write_off_account
+ and flt(self.write_off_amount, self.precision("write_off_amount"))
+ ):
write_off_account_currency = get_account_currency(self.write_off_account)
default_cost_center = frappe.get_cached_value("Company", self.company, "cost_center")
diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py
index 7819fa5..8d67e30 100644
--- a/erpnext/controllers/subcontracting_controller.py
+++ b/erpnext/controllers/subcontracting_controller.py
@@ -100,7 +100,7 @@
and self._doc_before_save
):
for row in self._doc_before_save.get("items"):
- item_dict[row.name] = (row.item_code, row.received_qty or row.qty)
+ item_dict[row.name] = (row.item_code, row.qty)
return item_dict
@@ -118,9 +118,7 @@
for row in self.items:
self.__reference_name.append(row.name)
- if (row.name not in item_dict) or (row.item_code, row.received_qty or row.qty) != item_dict[
- row.name
- ]:
+ if (row.name not in item_dict) or (row.item_code, row.qty) != item_dict[row.name]:
self.__changed_name.append(row.name)
if item_dict.get(row.name):
@@ -463,13 +461,12 @@
def __get_qty_based_on_material_transfer(self, item_row, transfer_item):
key = (item_row.item_code, item_row.get(self.subcontract_data.order_field))
- item_qty = item_row.received_qty or item_row.qty
- if self.qty_to_be_received.get(key) == item_qty:
+ if self.qty_to_be_received == item_row.qty:
return transfer_item.qty
if self.qty_to_be_received:
- qty = (flt(item_qty) * flt(transfer_item.qty)) / flt(self.qty_to_be_received.get(key, 0))
+ qty = (flt(item_row.qty) * flt(transfer_item.qty)) / flt(self.qty_to_be_received.get(key, 0))
transfer_item.item_details.required_qty = transfer_item.qty
if transfer_item.serial_no or frappe.get_cached_value(
@@ -494,11 +491,7 @@
for bom_item in self.__get_materials_from_bom(
row.item_code, row.bom, row.get("include_exploded_items")
):
- qty = (
- flt(bom_item.qty_consumed_per_unit)
- * flt(row.received_qty or row.qty)
- * row.conversion_factor
- )
+ qty = flt(bom_item.qty_consumed_per_unit) * flt(row.qty) * row.conversion_factor
bom_item.main_item_code = row.item_code
self.__update_reserve_warehouse(bom_item, row)
self.__set_alternative_item(bom_item)
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 000ee07..caff0a3 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -649,23 +649,13 @@
else:
material_request = material_request_map[key]
- conversion_factor = 1.0
- if (
- material_request_type == "Purchase"
- and item_doc.purchase_uom
- and item_doc.purchase_uom != item_doc.stock_uom
- ):
- conversion_factor = (
- get_conversion_factor(item_doc.name, item_doc.purchase_uom).get("conversion_factor") or 1.0
- )
-
# add item
material_request.append(
"items",
{
"item_code": item.item_code,
"from_warehouse": item.from_warehouse,
- "qty": item.quantity / conversion_factor,
+ "qty": item.quantity,
"schedule_date": schedule_date,
"warehouse": item.warehouse,
"sales_order": item.sales_order,
@@ -1053,11 +1043,25 @@
if include_safety_stock:
required_qty += flt(row["safety_stock"])
+ item_details = frappe.get_cached_value(
+ "Item", row.item_code, ["purchase_uom", "stock_uom"], as_dict=1
+ )
+
+ conversion_factor = 1.0
+ if (
+ row.get("default_material_request_type") == "Purchase"
+ and item_details.purchase_uom
+ and item_details.purchase_uom != item_details.stock_uom
+ ):
+ conversion_factor = (
+ get_conversion_factor(row.item_code, item_details.purchase_uom).get("conversion_factor") or 1.0
+ )
+
if required_qty > 0:
return {
"item_code": row.item_code,
"item_name": row.item_name,
- "quantity": required_qty,
+ "quantity": required_qty / conversion_factor,
"required_bom_qty": total_qty,
"stock_uom": row.get("stock_uom"),
"warehouse": warehouse
diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py
index c4ab0f8..a6d034d 100644
--- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py
@@ -826,6 +826,11 @@
)
pln.make_material_request()
+
+ for row in pln.mr_items:
+ self.assertEqual(row.uom, "Nos")
+ self.assertEqual(row.quantity, 1)
+
for row in frappe.get_all(
"Material Request Item",
filters={"production_plan": pln.name},
diff --git a/erpnext/public/js/bulk_transaction_processing.js b/erpnext/public/js/bulk_transaction_processing.js
index 101f50c..0e42b47 100644
--- a/erpnext/public/js/bulk_transaction_processing.js
+++ b/erpnext/public/js/bulk_transaction_processing.js
@@ -11,7 +11,7 @@
});
let count_of_rows = checked_items.length;
- frappe.confirm(__("Create {0} {1} ?", [count_of_rows, to_doctype]), ()=>{
+ frappe.confirm(__("Create {0} {1} ?", [count_of_rows, __(to_doctype)]), ()=>{
if (doc_name.length == 0) {
frappe.call({
method: "erpnext.utilities.bulk_transaction.transaction_processing",
@@ -20,11 +20,11 @@
});
if (count_of_rows > 10) {
- frappe.show_alert("Starting a background job to create {0} {1}", [count_of_rows, to_doctype]);
+ frappe.show_alert("Starting a background job to create {0} {1}", [count_of_rows, __(to_doctype)]);
}
} else {
frappe.msgprint(__("Selected document must be in submitted state"));
}
});
}
-});
\ No newline at end of file
+});
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index c12a9f8..999ddc2 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -6,6 +6,7 @@
from typing import Dict, Optional
import frappe
+from frappe.utils import cint
from frappe.utils.nestedset import get_root_of
from erpnext.accounts.doctype.pos_invoice.pos_invoice import get_stock_availability
@@ -108,10 +109,10 @@
item.name asc
LIMIT
{page_length} offset {start}""".format(
- start=start,
- page_length=page_length,
- lft=lft,
- rgt=rgt,
+ start=cint(start),
+ page_length=cint(page_length),
+ lft=cint(lft),
+ rgt=cint(rgt),
condition=condition,
bin_join_selection=bin_join_selection,
bin_join_condition=bin_join_condition,
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
index c7f592b..bce5360 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
@@ -58,7 +58,6 @@
def before_validate(self):
super(SubcontractingReceipt, self).before_validate()
self.set_items_bom()
- self.set_received_qty()
self.set_items_cost_center()
self.set_items_expense_account()
@@ -213,10 +212,6 @@
"bom",
)
- def set_received_qty(self):
- for item in self.items:
- item.received_qty = flt(item.qty) + flt(item.rejected_qty)
-
def set_items_cost_center(self):
if self.company:
cost_center = frappe.get_cached_value("Company", self.company, "cost_center")
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py
index ca72ddf..72ed4d4 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py
@@ -515,17 +515,18 @@
scr.items[0].rejected_qty = 3
scr.save()
- # consumed_qty should be ((received_qty) * (transfered_qty / qty)) = ((5 + 3) * (20 / 10)) = 16
- self.assertEqual(scr.supplied_items[0].consumed_qty, 16)
+ # consumed_qty should be (accepted_qty * (transfered_qty / qty)) = (5 * (20 / 10)) = 10
+ self.assertEqual(scr.supplied_items[0].consumed_qty, 10)
# Set Backflush Based On as "BOM"
set_backflush_based_on("BOM")
+ scr.items[0].qty = 6 # Accepted Qty
scr.items[0].rejected_qty = 4
scr.save()
- # consumed_qty should be ((received_qty) * (qty_consumed_per_unit)) = ((5 + 4) * (1)) = 9
- self.assertEqual(scr.supplied_items[0].consumed_qty, 9)
+ # consumed_qty should be (accepted_qty * qty_consumed_per_unit) = (6 * 1) = 6
+ self.assertEqual(scr.supplied_items[0].consumed_qty, 6)
def make_return_subcontracting_receipt(**args):