added scripts for daily status update and patch for supplier invoices
This commit is contained in:
parent
af80ee33fc
commit
f668698c25
3 changed files with 52 additions and 23 deletions
|
|
@ -148,23 +148,21 @@ app_license = "mit"
|
|||
# Scheduled Tasks
|
||||
# ---------------
|
||||
|
||||
# scheduler_events = {
|
||||
# "all": [
|
||||
# "suppliers_portal.tasks.all"
|
||||
# ],
|
||||
# "daily": [
|
||||
# "suppliers_portal.tasks.daily"
|
||||
# ],
|
||||
# "hourly": [
|
||||
# "suppliers_portal.tasks.hourly"
|
||||
# ],
|
||||
# "weekly": [
|
||||
# "suppliers_portal.tasks.weekly"
|
||||
# ],
|
||||
# "monthly": [
|
||||
# "suppliers_portal.tasks.monthly"
|
||||
# ],
|
||||
# }
|
||||
scheduler_events = {
|
||||
# "all": [
|
||||
# "suppliers_portal.tasks.all"
|
||||
# ],
|
||||
"daily": ["suppliers_portal.utils.daily_invoice_status_update"],
|
||||
# "hourly": [
|
||||
# "suppliers_portal.tasks.hourly"
|
||||
# ],
|
||||
# "weekly": [
|
||||
# "suppliers_portal.tasks.weekly"
|
||||
# ],
|
||||
# "monthly": [
|
||||
# "suppliers_portal.tasks.monthly"
|
||||
# ],
|
||||
}
|
||||
|
||||
# Testing
|
||||
# -------
|
||||
|
|
|
|||
21
suppliers_portal/patches/oct_12.py
Normal file
21
suppliers_portal/patches/oct_12.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
suppliers = frappe.get_list("Supplier", pluck="name")
|
||||
|
||||
for supplier in suppliers:
|
||||
supplier_doc = frappe.get_doc("Supplier", supplier)
|
||||
invoices = frappe.get_list(
|
||||
"Invoices", filters={"supplier": supplier}, pluck="name"
|
||||
)
|
||||
if len(invoices) == 0:
|
||||
continue
|
||||
|
||||
supplier_doc.set("invoices", [])
|
||||
for invoice in invoices:
|
||||
supplier_doc.append("invoices", {"invoice_number": invoice})
|
||||
|
||||
supplier_doc.save()
|
||||
|
||||
frappe.db.commit()
|
||||
|
|
@ -1,6 +1,16 @@
|
|||
def before_request(request, method, url, headers):
|
||||
print("Before Request")
|
||||
print(request)
|
||||
print(method)
|
||||
print(url)
|
||||
print(headers)
|
||||
import frappe
|
||||
|
||||
|
||||
def daily_invoice_status_update():
|
||||
invoices = frappe.get_all(
|
||||
"Invoices",
|
||||
filters={
|
||||
"status": ["in", ["Unpaid", "Partially Paid", "Partially Paid and Overdue"]]
|
||||
},
|
||||
fields=["name"],
|
||||
)
|
||||
for invoice in invoices:
|
||||
invoice_doc = frappe.get_doc("Invoices", invoice.name)
|
||||
invoice_doc.update_status()
|
||||
invoice_doc.save()
|
||||
frappe.db.commit()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue