-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This is a semi-automatic backport of pull request #30868 done by [Mergify](https://mergify.com).
- Loading branch information
1 parent
60964a4
commit 97ea1f5
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
erpnext/patches/v13_0/set_per_billed_in_return_delivery_note.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors | ||
# For license information, please see license.txt | ||
|
||
import frappe | ||
|
||
|
||
def execute(): | ||
dn = frappe.qb.DocType("Delivery Note") | ||
dn_item = frappe.qb.DocType("Delivery Note Item") | ||
|
||
dn_list = ( | ||
frappe.qb.from_(dn) | ||
.inner_join(dn_item) | ||
.on(dn.name == dn_item.parent) | ||
.select(dn.name) | ||
.where(dn.docstatus == 1) | ||
.where(dn.is_return == 1) | ||
.where(dn.per_billed < 100) | ||
.where(dn_item.returned_qty > 0) | ||
.run(as_dict=True) | ||
) | ||
|
||
frappe.qb.update(dn_item).inner_join(dn).on(dn.name == dn_item.parent).set( | ||
dn_item.returned_qty, 0 | ||
).where(dn.is_return == 1).where(dn_item.returned_qty > 0).run() | ||
|
||
for d in dn_list: | ||
dn_doc = frappe.get_doc("Delivery Note", d.get("name")) | ||
dn_doc.run_method("update_billing_status") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters