Skip to content

Commit

Permalink
Merge pull request #37787 from frappe/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
deepeshgarg007 authored Nov 1, 2023
2 parents 0925cb2 + 7a5bfe0 commit 98a8267
Show file tree
Hide file tree
Showing 64 changed files with 984 additions and 1,147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
{
"fieldname": "posting_date",
"fieldtype": "Date",
"label": "Posting Date"
"label": "Posting Date",
"search_index": 1
},
{
"fieldname": "account_type",
Expand Down Expand Up @@ -153,7 +154,7 @@
"in_create": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-06-29 12:24:20.500632",
"modified": "2023-10-30 16:15:00.470283",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Ledger Entry",
Expand Down
36 changes: 31 additions & 5 deletions erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,19 +776,45 @@ def test_pos_batch_reservation(self):
)

create_batch_item_with_batch("_BATCH ITEM Test For Reserve", "TestBatch-RS 02")
make_stock_entry(
se = make_stock_entry(
target="_Test Warehouse - _TC",
item_code="_BATCH ITEM Test For Reserve",
qty=20,
qty=30,
basic_rate=100,
batch_no="TestBatch-RS 02",
)

se.reload()

batch_no = get_batch_from_bundle(se.items[0].serial_and_batch_bundle)

# POS Invoice 1, for the batch without bundle
pos_inv1 = create_pos_invoice(
item="_BATCH ITEM Test For Reserve", rate=300, qty=15, batch_no="TestBatch-RS 02"
item="_BATCH ITEM Test For Reserve", rate=300, qty=15, do_not_save=1
)

pos_inv1.items[0].batch_no = batch_no
pos_inv1.save()
pos_inv1.submit()
pos_inv1.reload()

self.assertFalse(pos_inv1.items[0].serial_and_batch_bundle)

batches = get_auto_batch_nos(
frappe._dict(
{"item_code": "_BATCH ITEM Test For Reserve", "warehouse": "_Test Warehouse - _TC"}
)
)

for batch in batches:
if batch.batch_no == batch_no and batch.warehouse == "_Test Warehouse - _TC":
self.assertEqual(batch.qty, 15)

# POS Invoice 2, for the batch with bundle
pos_inv2 = create_pos_invoice(
item="_BATCH ITEM Test For Reserve", rate=300, qty=10, batch_no=batch_no
)
pos_inv2.reload()
self.assertTrue(pos_inv2.items[0].serial_and_batch_bundle)

batches = get_auto_batch_nos(
frappe._dict(
Expand All @@ -797,7 +823,7 @@ def test_pos_batch_reservation(self):
)

for batch in batches:
if batch.batch_no == "TestBatch-RS 02" and batch.warehouse == "_Test Warehouse - _TC":
if batch.batch_no == batch_no and batch.warehouse == "_Test Warehouse - _TC":
self.assertEqual(batch.qty, 5)

def test_pos_batch_item_qty_validation(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,7 @@ def update_item(obj, target, source_parent):
"po_detail": "purchase_order_item",
"material_request": "material_request",
"material_request_item": "material_request_item",
"wip_composite_asset": "wip_composite_asset",
},
"postprocess": update_item,
"condition": lambda doc: abs(doc.received_qty) < abs(doc.qty),
Expand Down
15 changes: 15 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,7 @@ def test_sle_for_target_warehouse(self):
)

si = frappe.copy_doc(test_records[0])
si.customer = "_Test Internal Customer 3"
si.update_stock = 1
si.set_warehouse = "Finished Goods - _TC"
si.set_target_warehouse = "Stores - _TC"
Expand Down Expand Up @@ -3696,6 +3697,20 @@ def create_internal_parties():
allowed_to_interact_with="_Test Company with perpetual inventory",
)

create_internal_customer(
customer_name="_Test Internal Customer 3",
represents_company="_Test Company",
allowed_to_interact_with="_Test Company",
)

account = create_account(
account_name="Unrealized Profit",
parent_account="Current Liabilities - _TC",
company="_Test Company",
)

frappe.db.set_value("Company", "_Test Company", "unrealized_profit_loss_account", account)

create_internal_supplier(
supplier_name="_Test Internal Supplier",
represents_company="Wind Power LLC",
Expand Down
20 changes: 14 additions & 6 deletions erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Optional

import frappe
from frappe import _, msgprint, scrub
from frappe import _, msgprint, qb, scrub
from frappe.contacts.doctype.address.address import get_company_address, get_default_address
from frappe.core.doctype.user_permission.user_permission import get_permitted_documents
from frappe.model.utils import get_fetch_values
Expand Down Expand Up @@ -480,11 +480,19 @@ def generator():

def get_party_gle_currency(party_type, party, company):
def generator():
existing_gle_currency = frappe.db.sql(
"""select account_currency from `tabGL Entry`
where docstatus=1 and company=%(company)s and party_type=%(party_type)s and party=%(party)s
limit 1""",
{"company": company, "party_type": party_type, "party": party},
gl = qb.DocType("GL Entry")
existing_gle_currency = (
qb.from_(gl)
.select(gl.account_currency)
.where(
(gl.docstatus == 1)
& (gl.company == company)
& (gl.party_type == party_type)
& (gl.party == party)
& (gl.is_cancelled == 0)
)
.limit(1)
.run()
)

return existing_gle_currency[0][0] if existing_gle_currency else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ def get_ple_entries(self):
query = (
qb.from_(ple)
.select(
ple.name,
ple.account,
ple.voucher_type,
ple.voucher_no,
Expand All @@ -731,13 +732,15 @@ def get_ple_entries(self):
ple.account_currency,
ple.amount,
ple.amount_in_account_currency,
ple.remarks,
)
.where(ple.delinked == 0)
.where(Criterion.all(self.qb_selection_filter))
.where(Criterion.any(self.or_filters))
)

if self.filters.get("show_remarks"):
query = query.select(ple.remarks)

if self.filters.get("group_by_party"):
query = query.orderby(self.ple.party, self.ple.posting_date)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ frappe.query_reports["Profitability Analysis"] = {
"label": __("Accounting Dimension"),
"fieldtype": "Link",
"options": "Accounting Dimension",
"get_query": () =>{
return {
filters: {
"disabled": 0
}
}
}
},
{
"fieldname": "fiscal_year",
Expand Down
1 change: 0 additions & 1 deletion erpnext/assets/doctype/asset/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ frappe.ui.form.on('Asset', {
frm.set_query("item_code", function() {
return {
"filters": {
"disabled": 0,
"is_fixed_asset": 1,
"is_stock_item": 0
}
Expand Down
16 changes: 12 additions & 4 deletions erpnext/assets/doctype/asset/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@
"read_only": 1
},
{
"depends_on": "eval:!(doc.is_composite_asset && !doc.capitalized_in)",
"fieldname": "gross_purchase_amount",
"fieldtype": "Currency",
"label": "Gross Purchase Amount",
"options": "Company:company:default_currency",
"read_only": 1,
"read_only_depends_on": "eval:!doc.is_existing_asset",
"reqd": 1
},
Expand Down Expand Up @@ -399,6 +399,7 @@
"fieldtype": "Column Break"
},
{
"depends_on": "eval:!doc.is_composite_asset && !doc.is_existing_asset",
"fieldname": "purchase_receipt",
"fieldtype": "Link",
"label": "Purchase Receipt",
Expand All @@ -416,6 +417,7 @@
"read_only": 1
},
{
"depends_on": "eval:!doc.is_composite_asset && !doc.is_existing_asset",
"fieldname": "purchase_invoice",
"fieldtype": "Link",
"label": "Purchase Invoice",
Expand Down Expand Up @@ -479,10 +481,11 @@
"read_only": 1
},
{
"depends_on": "eval.doc.asset_quantity",
"fieldname": "asset_quantity",
"fieldtype": "Int",
"label": "Asset Quantity",
"read_only_depends_on": "eval:!doc.is_existing_asset && !doc.is_composite_asset"
"read_only": 1
},
{
"fieldname": "depr_entry_posting_status",
Expand Down Expand Up @@ -562,9 +565,14 @@
"link_doctype": "Journal Entry",
"link_fieldname": "reference_name",
"table_fieldname": "accounts"
},
{
"group": "Asset Capitalization",
"link_doctype": "Asset Capitalization",
"link_fieldname": "target_asset"
}
],
"modified": "2023-10-03 23:28:26.732269",
"modified": "2023-10-27 17:03:46.629617",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset",
Expand Down Expand Up @@ -608,4 +616,4 @@
"states": [],
"title_field": "asset_name",
"track_changes": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -876,12 +876,8 @@ def get_items_tagged_to_wip_composite_asset(asset):
"amount",
]

pi_items = frappe.get_all(
"Purchase Invoice Item", filters={"wip_composite_asset": asset}, fields=fields
)

pr_items = frappe.get_all(
"Purchase Receipt Item", filters={"wip_composite_asset": asset}, fields=fields
)

return pi_items + pr_items
return pr_items
18 changes: 9 additions & 9 deletions erpnext/buying/doctype/buying_settings/buying_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"transaction_settings_section",
"po_required",
"pr_required",
"over_order_allowance",
"blanket_order_allowance",
"column_break_12",
"maintain_same_rate",
"set_landed_cost_based_on_purchase_invoice_rate",
Expand Down Expand Up @@ -159,27 +159,27 @@
"fieldtype": "Check",
"label": "Set Landed Cost Based on Purchase Invoice Rate"
},
{
"default": "0",
"description": "Percentage you are allowed to order more against the Blanket Order Quantity. For example: If you have a Blanket Order of Quantity 100 units. and your Allowance is 10% then you are allowed to order 110 units.",
"fieldname": "over_order_allowance",
"fieldtype": "Float",
"label": "Over Order Allowance (%)"
},
{
"default": "0",
"description": "While making Purchase Invoice from Purchase Order, use Exchange Rate on Invoice's transaction date rather than inheriting it from Purchase Order. Only applies for Purchase Invoice.",
"fieldname": "use_transaction_date_exchange_rate",
"fieldtype": "Check",
"label": "Use Transaction Date Exchange Rate"
},
{
"default": "0",
"description": "Percentage you are allowed to order beyond the Blanket Order quantity.",
"fieldname": "blanket_order_allowance",
"fieldtype": "Float",
"label": "Blanket Order Allowance (%)"
}
],
"icon": "fa fa-cog",
"idx": 1,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-10-16 16:22:03.201078",
"modified": "2023-10-25 14:03:32.520418",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying Settings",
Expand Down
4 changes: 4 additions & 0 deletions erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ def update_item(obj, target, source_parent):
"bom": "bom",
"material_request": "material_request",
"material_request_item": "material_request_item",
"sales_order": "sales_order",
"sales_order_item": "sales_order_item",
"wip_composite_asset": "wip_composite_asset",
},
"postprocess": update_item,
"condition": lambda doc: abs(doc.received_qty) < abs(doc.qty)
Expand Down Expand Up @@ -632,6 +635,7 @@ def update_item(obj, target, source_parent):
"field_map": {
"name": "po_detail",
"parent": "purchase_order",
"wip_composite_asset": "wip_composite_asset",
},
"postprocess": update_item,
"condition": lambda doc: (doc.base_amount == 0 or abs(doc.billed_amt) < abs(doc.amount)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
"billed_amt",
"accounting_details",
"expense_account",
"column_break_fyqr",
"wip_composite_asset",
"manufacture_details",
"manufacturer",
"manufacturer_part_no",
Expand Down Expand Up @@ -896,13 +898,23 @@
"fieldname": "apply_tds",
"fieldtype": "Check",
"label": "Apply TDS"
},
{
"fieldname": "wip_composite_asset",
"fieldtype": "Link",
"label": "WIP Composite Asset",
"options": "Asset"
},
{
"fieldname": "column_break_fyqr",
"fieldtype": "Column Break"
}
],
"idx": 1,
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-13 16:22:40.825092",
"modified": "2023-10-27 15:50:42.655573",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order Item",
Expand All @@ -915,4 +927,4 @@
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
}
}
}
else {
return {
filters: { "disabled": 0 }
}
}
}
},
{
Expand Down
Loading

0 comments on commit 98a8267

Please sign in to comment.