Merge branch 'develop' into so-to-wo-bom

This commit is contained in:
Marica 2022-06-15 12:58:13 +05:30 committed by GitHub
commit fafdaff4d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 51 additions and 44 deletions

View File

@ -1444,7 +1444,7 @@ def get_negative_outstanding_invoices(
voucher_type = "Sales Invoice" if party_type == "Customer" else "Purchase Invoice" voucher_type = "Sales Invoice" if party_type == "Customer" else "Purchase Invoice"
supplier_condition = "" supplier_condition = ""
if voucher_type == "Purchase Invoice": if voucher_type == "Purchase Invoice":
supplier_condition = "and (release_date is null or release_date <= CURDATE())" supplier_condition = "and (release_date is null or release_date <= CURRENT_DATE)"
if party_account_currency == company_currency: if party_account_currency == company_currency:
grand_total_field = "base_grand_total" grand_total_field = "base_grand_total"
rounded_total_field = "base_rounded_total" rounded_total_field = "base_rounded_total"

View File

@ -100,7 +100,7 @@ def get_sales_details(filters):
sales_data = frappe.db.sql( sales_data = frappe.db.sql(
""" """
select s.territory, s.customer, si.item_group, si.item_code, si.qty, {date_field} as last_order_date, select s.territory, s.customer, si.item_group, si.item_code, si.qty, {date_field} as last_order_date,
DATEDIFF(CURDATE(), {date_field}) as days_since_last_order DATEDIFF(CURRENT_DATE, {date_field}) as days_since_last_order
from `tab{doctype}` s, `tab{doctype} Item` si from `tab{doctype}` s, `tab{doctype} Item` si
where s.name = si.parent and s.docstatus = 1 where s.name = si.parent and s.docstatus = 1
order by days_since_last_order """.format( # nosec order by days_since_last_order """.format( # nosec

View File

@ -330,7 +330,7 @@ class TestPurchaseOrder(FrappeTestCase):
else: else:
# update valid from # update valid from
frappe.db.sql( frappe.db.sql(
"""UPDATE `tabItem Tax` set valid_from = CURDATE() """UPDATE `tabItem Tax` set valid_from = CURRENT_DATE
where parent = %(item)s and item_tax_template = %(tax)s""", where parent = %(item)s and item_tax_template = %(tax)s""",
{"item": item, "tax": tax_template}, {"item": item, "tax": tax_template},
) )

View File

@ -691,7 +691,7 @@ def get_doctype_wise_filters(filters):
def get_batch_numbers(doctype, txt, searchfield, start, page_len, filters): def get_batch_numbers(doctype, txt, searchfield, start, page_len, filters):
query = """select batch_id from `tabBatch` query = """select batch_id from `tabBatch`
where disabled = 0 where disabled = 0
and (expiry_date >= CURDATE() or expiry_date IS NULL) and (expiry_date >= CURRENT_DATE or expiry_date IS NULL)
and name like {txt}""".format( and name like {txt}""".format(
txt=frappe.db.escape("%{0}%".format(txt)) txt=frappe.db.escape("%{0}%".format(txt))
) )

View File

@ -8,7 +8,8 @@ import frappe
from frappe import _ from frappe import _
from frappe.email.inbox import link_communication_to_document from frappe.email.inbox import link_communication_to_document
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe.query_builder import DocType from frappe.query_builder import DocType, Interval
from frappe.query_builder.functions import Now
from frappe.utils import cint, flt, get_fullname from frappe.utils import cint, flt, get_fullname
from erpnext.crm.utils import add_link_in_communication, copy_comments from erpnext.crm.utils import add_link_in_communication, copy_comments
@ -398,15 +399,17 @@ def auto_close_opportunity():
frappe.db.get_single_value("CRM Settings", "close_opportunity_after_days") or 15 frappe.db.get_single_value("CRM Settings", "close_opportunity_after_days") or 15
) )
opportunities = frappe.db.sql( table = frappe.qb.DocType("Opportunity")
""" select name from tabOpportunity where status='Replied' and opportunities = (
modified<DATE_SUB(CURDATE(), INTERVAL %s DAY) """, frappe.qb.from_(table)
(auto_close_after_days), .select(table.name)
as_dict=True, .where(
) (table.modified < (Now() - Interval(days=auto_close_after_days))) & (table.status == "Replied")
)
).run(pluck=True)
for opportunity in opportunities: for opportunity in opportunities:
doc = frappe.get_doc("Opportunity", opportunity.get("name")) doc = frappe.get_doc("Opportunity", opportunity)
doc.status = "Closed" doc.status = "Closed"
doc.flags.ignore_permissions = True doc.flags.ignore_permissions = True
doc.flags.ignore_mandatory = True doc.flags.ignore_mandatory = True

View File

@ -216,7 +216,7 @@ def make_payment_entry(advance):
def make_employee_advance(employee_name, args=None): def make_employee_advance(employee_name, args=None):
doc = frappe.new_doc("Employee Advance") doc = frappe.new_doc("Employee Advance")
doc.employee = employee_name doc.employee = employee_name
doc.company = "_Test company" doc.company = "_Test Company"
doc.purpose = "For site visit" doc.purpose = "For site visit"
doc.currency = erpnext.get_company_currency("_Test company") doc.currency = erpnext.get_company_currency("_Test company")
doc.exchange_rate = 1 doc.exchange_rate = 1

View File

@ -28,7 +28,7 @@ def daily_reminder():
for drafts in draft: for drafts in draft:
number_of_drafts = drafts[0] number_of_drafts = drafts[0]
update = frappe.db.sql( update = frappe.db.sql(
"""SELECT name,date,time,progress,progress_details FROM `tabProject Update` WHERE `tabProject Update`.project = %s AND date = DATE_ADD(CURDATE(), INTERVAL -1 DAY);""", """SELECT name,date,time,progress,progress_details FROM `tabProject Update` WHERE `tabProject Update`.project = %s AND date = DATE_ADD(CURRENT_DATE, INTERVAL -1 DAY);""",
project_name, project_name,
) )
email_sending(project_name, frequency, date_start, date_end, progress, number_of_drafts, update) email_sending(project_name, frequency, date_start, date_end, progress, number_of_drafts, update)
@ -39,7 +39,7 @@ def email_sending(
): ):
holiday = frappe.db.sql( holiday = frappe.db.sql(
"""SELECT holiday_date FROM `tabHoliday` where holiday_date = CURDATE();""" """SELECT holiday_date FROM `tabHoliday` where holiday_date = CURRENT_DATE;"""
) )
msg = ( msg = (
"<p>Project Name: " "<p>Project Name: "

View File

@ -296,7 +296,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"depends_on": "eval:doc.quotaion_to=='Customer' && doc.party_name", "depends_on": "eval:doc.quotation_to=='Customer' && doc.party_name",
"fieldname": "col_break98", "fieldname": "col_break98",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"width": "50%" "width": "50%"
@ -316,7 +316,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"depends_on": "eval:doc.quotaion_to=='Customer' && doc.party_name", "depends_on": "eval:doc.quotation_to=='Customer' && doc.party_name",
"fieldname": "customer_group", "fieldname": "customer_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
@ -1084,4 +1084,4 @@
"states": [], "states": [],
"timeline_field": "party_name", "timeline_field": "party_name",
"title_field": "title" "title_field": "title"
} }

View File

@ -644,7 +644,7 @@ class TestSalesOrder(FrappeTestCase):
else: else:
# update valid from # update valid from
frappe.db.sql( frappe.db.sql(
"""UPDATE `tabItem Tax` set valid_from = CURDATE() """UPDATE `tabItem Tax` set valid_from = CURRENT_DATE
where parent = %(item)s and item_tax_template = %(tax)s""", where parent = %(item)s and item_tax_template = %(tax)s""",
{"item": item, "tax": tax_template}, {"item": item, "tax": tax_template},
) )

View File

@ -31,13 +31,13 @@ def execute(filters=None):
def get_sales_details(doctype): def get_sales_details(doctype):
cond = """sum(so.base_net_total) as 'total_order_considered', cond = """sum(so.base_net_total) as 'total_order_considered',
max(so.posting_date) as 'last_order_date', max(so.posting_date) as 'last_order_date',
DATEDIFF(CURDATE(), max(so.posting_date)) as 'days_since_last_order' """ DATEDIFF(CURRENT_DATE, max(so.posting_date)) as 'days_since_last_order' """
if doctype == "Sales Order": if doctype == "Sales Order":
cond = """sum(if(so.status = "Stopped", cond = """sum(if(so.status = "Stopped",
so.base_net_total * so.per_delivered/100, so.base_net_total * so.per_delivered/100,
so.base_net_total)) as 'total_order_considered', so.base_net_total)) as 'total_order_considered',
max(so.transaction_date) as 'last_order_date', max(so.transaction_date) as 'last_order_date',
DATEDIFF(CURDATE(), max(so.transaction_date)) as 'days_since_last_order'""" DATEDIFF(CURRENT_DATE, max(so.transaction_date)) as 'days_since_last_order'"""
return frappe.db.sql( return frappe.db.sql(
"""select """select

View File

@ -64,7 +64,7 @@ def get_data(conditions, filters):
soi.delivery_date as delivery_date, soi.delivery_date as delivery_date,
so.name as sales_order, so.name as sales_order,
so.status, so.customer, soi.item_code, so.status, so.customer, soi.item_code,
DATEDIFF(CURDATE(), soi.delivery_date) as delay_days, DATEDIFF(CURRENT_DATE, soi.delivery_date) as delay_days,
IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay, IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay,
soi.qty, soi.delivered_qty, soi.qty, soi.delivered_qty,
(soi.qty - soi.delivered_qty) AS pending_qty, (soi.qty - soi.delivered_qty) AS pending_qty,

View File

@ -854,7 +854,7 @@ class EmailDigest(Document):
sql_po = """select {fields} from `tabPurchase Order Item` sql_po = """select {fields} from `tabPurchase Order Item`
left join `tabPurchase Order` on `tabPurchase Order`.name = `tabPurchase Order Item`.parent left join `tabPurchase Order` on `tabPurchase Order`.name = `tabPurchase Order Item`.parent
where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and curdate() > `tabPurchase Order Item`.schedule_date where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and CURRENT_DATE > `tabPurchase Order Item`.schedule_date
and received_qty < qty order by `tabPurchase Order Item`.parent DESC, and received_qty < qty order by `tabPurchase Order Item`.parent DESC,
`tabPurchase Order Item`.schedule_date DESC""".format( `tabPurchase Order Item`.schedule_date DESC""".format(
fields=fields_po fields=fields_po
@ -862,7 +862,7 @@ class EmailDigest(Document):
sql_poi = """select {fields} from `tabPurchase Order Item` sql_poi = """select {fields} from `tabPurchase Order Item`
left join `tabPurchase Order` on `tabPurchase Order`.name = `tabPurchase Order Item`.parent left join `tabPurchase Order` on `tabPurchase Order`.name = `tabPurchase Order Item`.parent
where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and curdate() > `tabPurchase Order Item`.schedule_date where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and CURRENT_DATE > `tabPurchase Order Item`.schedule_date
and received_qty < qty order by `tabPurchase Order Item`.idx""".format( and received_qty < qty order by `tabPurchase Order Item`.idx""".format(
fields=fields_poi fields=fields_poi
) )

View File

@ -335,7 +335,7 @@ def get_batches(item_code, warehouse, qty=1, throw=False, serial_no=None):
on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no ) on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )
where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s
and `tabStock Ledger Entry`.is_cancelled = 0 and `tabStock Ledger Entry`.is_cancelled = 0
and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL) {0} and (`tabBatch`.expiry_date >= CURRENT_DATE or `tabBatch`.expiry_date IS NULL) {0}
group by batch_id group by batch_id
order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC
""".format( """.format(

View File

@ -24,7 +24,7 @@ class TestLandedCostVoucher(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
get_multiple_items=True, get_multiple_items=True,
get_taxes_and_charges=True, get_taxes_and_charges=True,
) )
@ -195,7 +195,7 @@ class TestLandedCostVoucher(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
get_multiple_items=True, get_multiple_items=True,
get_taxes_and_charges=True, get_taxes_and_charges=True,
do_not_submit=True, do_not_submit=True,
@ -280,7 +280,7 @@ class TestLandedCostVoucher(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
do_not_save=True, do_not_save=True,
) )
pr.items[0].cost_center = "Main - TCP1" pr.items[0].cost_center = "Main - TCP1"

View File

@ -276,7 +276,7 @@ class TestPurchaseReceipt(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
get_multiple_items=True, get_multiple_items=True,
get_taxes_and_charges=True, get_taxes_and_charges=True,
) )
@ -486,13 +486,13 @@ class TestPurchaseReceipt(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
) )
return_pr = make_purchase_receipt( return_pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
is_return=1, is_return=1,
return_against=pr.name, return_against=pr.name,
qty=-2, qty=-2,
@ -573,13 +573,13 @@ class TestPurchaseReceipt(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
) )
return_pr = make_purchase_receipt( return_pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
is_return=1, is_return=1,
return_against=pr.name, return_against=pr.name,
qty=-5, qty=-5,
@ -615,7 +615,7 @@ class TestPurchaseReceipt(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
qty=2, qty=2,
rejected_qty=2, rejected_qty=2,
rejected_warehouse=rejected_warehouse, rejected_warehouse=rejected_warehouse,
@ -624,7 +624,7 @@ class TestPurchaseReceipt(FrappeTestCase):
return_pr = make_purchase_receipt( return_pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
is_return=1, is_return=1,
return_against=pr.name, return_against=pr.name,
qty=-2, qty=-2,
@ -951,7 +951,7 @@ class TestPurchaseReceipt(FrappeTestCase):
cost_center=cost_center, cost_center=cost_center,
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
) )
stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse) stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse)
@ -975,7 +975,7 @@ class TestPurchaseReceipt(FrappeTestCase):
pr = make_purchase_receipt( pr = make_purchase_receipt(
company="_Test Company with perpetual inventory", company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
supplier_warehouse="Work in Progress - TCP1", supplier_warehouse="Work In Progress - TCP1",
) )
stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse) stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse)

View File

@ -11,6 +11,8 @@ from frappe.core.utils import get_parent_doc
from frappe.email.inbox import link_communication_to_document from frappe.email.inbox import link_communication_to_document
from frappe.model.document import Document from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe.query_builder import Interval
from frappe.query_builder.functions import Now
from frappe.utils import date_diff, get_datetime, now_datetime, time_diff_in_seconds from frappe.utils import date_diff, get_datetime, now_datetime, time_diff_in_seconds
from frappe.utils.user import is_website_user from frappe.utils.user import is_website_user
@ -190,15 +192,17 @@ def auto_close_tickets():
frappe.db.get_value("Support Settings", "Support Settings", "close_issue_after_days") or 7 frappe.db.get_value("Support Settings", "Support Settings", "close_issue_after_days") or 7
) )
issues = frappe.db.sql( table = frappe.qb.DocType("Issue")
""" select name from tabIssue where status='Replied' and issues = (
modified<DATE_SUB(CURDATE(), INTERVAL %s DAY) """, frappe.qb.from_(table)
(auto_close_after_days), .select(table.name)
as_dict=True, .where(
) (table.modified < (Now() - Interval(days=auto_close_after_days))) & (table.status == "Replied")
)
).run(pluck=True)
for issue in issues: for issue in issues:
doc = frappe.get_doc("Issue", issue.get("name")) doc = frappe.get_doc("Issue", issue)
doc.status = "Closed" doc.status = "Closed"
doc.flags.ignore_permissions = True doc.flags.ignore_permissions = True
doc.flags.ignore_mandatory = True doc.flags.ignore_mandatory = True