Skip to content

Commit 39af6bd

Browse files
authored
Merge pull request #46581 from frappe/version-14-hotfix
chore: release v14
2 parents 609bfae + 300f1a8 commit 39af6bd

6 files changed

Lines changed: 71 additions & 33 deletions

File tree

erpnext/assets/doctype/asset_capitalization/asset_capitalization.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def before_submit(self):
6969
def on_submit(self):
7070
self.update_stock_ledger()
7171
self.make_gl_entries()
72+
self.repost_future_sle_and_gle()
7273
self.update_target_asset()
7374

7475
def on_cancel(self):
@@ -82,6 +83,7 @@ def on_cancel(self):
8283
self.cancel_target_asset()
8384
self.update_stock_ledger()
8485
self.make_gl_entries()
86+
self.repost_future_sle_and_gle()
8587
self.restore_consumed_asset_items()
8688

8789
def on_trash(self):

erpnext/public/js/controllers/buying.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ erpnext.buying.BuyingController = class BuyingController extends erpnext.Transac
174174
}
175175

176176
qty(doc, cdt, cdn) {
177-
if ((doc.doctype == "Purchase Receipt") || (doc.doctype == "Purchase Invoice" && (doc.update_stock || doc.is_return))) {
177+
if ((doc.doctype == "Purchase Receipt") || (doc.doctype == "Purchase Invoice" && doc.update_stock)) {
178178
this.calculate_received_qty(doc, cdt, cdn)
179179
}
180180
super.qty(doc, cdt, cdn);

erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -190,35 +190,42 @@ def delete_lead_addresses(self):
190190
"""Delete addresses to which leads are linked"""
191191
self.validate_doc_status()
192192
if not self.delete_leads_and_addresses:
193-
leads = frappe.get_all("Lead", filters={"company": self.company})
194-
leads = ["'%s'" % row.get("name") for row in leads]
193+
leads = frappe.db.get_all("Lead", filters={"company": self.company}, pluck="name")
195194
addresses = []
196195
if leads:
197-
addresses = frappe.db.sql_list(
198-
"""select parent from `tabDynamic Link` where link_name
199-
in ({leads})""".format(leads=",".join(leads))
196+
addresses = frappe.db.get_all(
197+
"Dynamic Link", filters={"link_name": ("in", leads)}, pluck="parent"
200198
)
201-
202199
if addresses:
203200
addresses = ["%s" % frappe.db.escape(addr) for addr in addresses]
204201

205-
frappe.db.sql(
206-
"""delete from `tabAddress` where name in ({addresses}) and
207-
name not in (select distinct dl1.parent from `tabDynamic Link` dl1
208-
inner join `tabDynamic Link` dl2 on dl1.parent=dl2.parent
209-
and dl1.link_doctype<>dl2.link_doctype)""".format(addresses=",".join(addresses))
210-
)
202+
address = qb.DocType("Address")
203+
dl1 = qb.DocType("Dynamic Link")
204+
dl2 = qb.DocType("Dynamic Link")
205+
206+
qb.from_(address).delete().where(
207+
(address.name.isin(addresses))
208+
& (
209+
address.name.notin(
210+
qb.from_(dl1)
211+
.join(dl2)
212+
.on((dl1.parent == dl2.parent) & (dl1.link_doctype != dl2.link_doctype))
213+
.select(dl1.parent)
214+
.distinct()
215+
)
216+
)
217+
).run()
211218

212-
frappe.db.sql(
213-
"""delete from `tabDynamic Link` where link_doctype='Lead'
214-
and parenttype='Address' and link_name in ({leads})""".format(leads=",".join(leads))
215-
)
219+
dynamic_link = qb.DocType("Dynamic Link")
220+
qb.from_(dynamic_link).delete().where(
221+
(dynamic_link.link_doctype == "Lead")
222+
& (dynamic_link.parenttype == "Address")
223+
& (dynamic_link.link_name.isin(leads))
224+
).run()
225+
226+
customer = qb.DocType("Customer")
227+
qb.update(customer).set(customer.lead_name, None).where(customer.lead_name.isin(leads)).run()
216228

217-
frappe.db.sql(
218-
"""update `tabCustomer` set lead_name=NULL where lead_name in ({leads})""".format(
219-
leads=",".join(leads)
220-
)
221-
)
222229
self.db_set("delete_leads_and_addresses", 1)
223230
self.enqueue_task(task="Reset Company Values")
224231

erpnext/stock/doctype/quality_inspection/quality_inspection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def get_item_specification_details(self):
4949
child = self.append("readings", {})
5050
child.update(d)
5151
child.status = "Accepted"
52+
child.parameter_group = frappe.get_value(
53+
"Quality Inspection Parameter", d.specification, "parameter_group"
54+
)
5255

5356
@frappe.whitelist()
5457
def get_quality_inspection_template(self):

erpnext/stock/doctype/serial_no/serial_no.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def get_stock_ledger_entries(self, serial_no=None):
209209
OR serial_no like %s
210210
)
211211
ORDER BY
212-
posting_date desc, posting_time desc, creation desc""",
212+
posting_datetime desc, creation desc""",
213213
(
214214
self.item_code,
215215
self.company,

erpnext/stock/doctype/stock_entry/stock_entry.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,17 +1314,38 @@ def _validate_work_order(pro_doc):
13141314

13151315
@frappe.whitelist()
13161316
def get_item_details(self, args=None, for_update=False):
1317-
item = frappe.db.sql(
1318-
"""select i.name, i.stock_uom, i.description, i.image, i.item_name, i.item_group,
1319-
i.has_batch_no, i.sample_quantity, i.has_serial_no, i.allow_alternative_item,
1320-
id.expense_account, id.buying_cost_center
1321-
from `tabItem` i LEFT JOIN `tabItem Default` id ON i.name=id.parent and id.company=%s
1322-
where i.name=%s
1323-
and i.disabled=0
1324-
and (i.end_of_life is null or i.end_of_life<'1900-01-01' or i.end_of_life > %s)""",
1325-
(self.company, args.get("item_code"), nowdate()),
1326-
as_dict=1,
1317+
item = frappe.qb.DocType("Item")
1318+
item_default = frappe.qb.DocType("Item Default")
1319+
1320+
query = (
1321+
frappe.qb.from_(item)
1322+
.left_join(item_default)
1323+
.on((item.name == item_default.parent) & (item_default.company == self.company))
1324+
.select(
1325+
item.name,
1326+
item.stock_uom,
1327+
item.description,
1328+
item.image,
1329+
item.item_name,
1330+
item.item_group,
1331+
item.has_batch_no,
1332+
item.sample_quantity,
1333+
item.has_serial_no,
1334+
item.allow_alternative_item,
1335+
item_default.expense_account,
1336+
item_default.buying_cost_center,
1337+
)
1338+
.where(
1339+
(item.name == args.get("item_code"))
1340+
& (item.disabled == 0)
1341+
& (
1342+
(item.end_of_life.isnull())
1343+
| (item.end_of_life < "1900-01-01")
1344+
| (item.end_of_life > nowdate())
1345+
)
1346+
)
13271347
)
1348+
item = query.run(as_dict=True)
13281349

13291350
if not item:
13301351
frappe.throw(
@@ -1369,6 +1390,11 @@ def get_item_details(self, args=None, for_update=False):
13691390
if self.purpose == "Material Issue":
13701391
ret["expense_account"] = item.get("expense_account") or item_group_defaults.get("expense_account")
13711392

1393+
if self.purpose == "Manufacture":
1394+
ret["expense_account"] = frappe.get_cached_value(
1395+
"Company", self.company, "stock_adjustment_account"
1396+
)
1397+
13721398
for company_field, field in {
13731399
"stock_adjustment_account": "expense_account",
13741400
"cost_center": "cost_center",

0 commit comments

Comments
 (0)