Merge pull request #7762 from mbauskar/hotfix
[minor] timestamp fixes for heatmap
This commit is contained in:
commit
e285258374
@ -7,7 +7,7 @@ import frappe
|
||||
import datetime
|
||||
from frappe import _, msgprint, scrub
|
||||
from frappe.defaults import get_user_permissions
|
||||
from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff, add_years
|
||||
from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff, add_years, get_timestamp
|
||||
from erpnext.utilities.doctype.address.address import get_address_display
|
||||
from erpnext.utilities.doctype.contact.contact import get_contact_details
|
||||
from erpnext.exceptions import PartyFrozen, InvalidCurrency, PartyDisabled, InvalidAccountCurrency
|
||||
@ -351,8 +351,17 @@ def validate_party_frozen_disabled(party_type, party_name):
|
||||
def get_timeline_data(doctype, name):
|
||||
'''returns timeline data for the past one year'''
|
||||
from frappe.desk.form.load import get_communication_data
|
||||
|
||||
out = {}
|
||||
data = get_communication_data(doctype, name,
|
||||
fields = 'unix_timestamp(date(creation)), count(name)',
|
||||
fields = 'date(creation), count(name)',
|
||||
after = add_years(None, -1).strftime('%Y-%m-%d'),
|
||||
group_by='group by date(creation)', as_dict=False)
|
||||
return dict(data)
|
||||
|
||||
timeline_items = dict(data)
|
||||
|
||||
for date, count in timeline_items.iteritems():
|
||||
timestamp = get_timestamp(date)
|
||||
out.update({ timestamp: count })
|
||||
|
||||
return out
|
@ -7,7 +7,7 @@ import erpnext
|
||||
import json
|
||||
import itertools
|
||||
from frappe import msgprint, _
|
||||
from frappe.utils import cstr, flt, cint, getdate, now_datetime, formatdate, strip
|
||||
from frappe.utils import cstr, flt, cint, getdate, now_datetime, formatdate, strip, get_timestamp
|
||||
from frappe.website.website_generator import WebsiteGenerator
|
||||
from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for, get_parent_item_groups
|
||||
from frappe.website.render import clear_cache
|
||||
@ -670,10 +670,17 @@ class Item(WebsiteGenerator):
|
||||
|
||||
def get_timeline_data(doctype, name):
|
||||
'''returns timeline data based on stock ledger entry'''
|
||||
return dict(frappe.db.sql('''select unix_timestamp(posting_date), count(*)
|
||||
out = {}
|
||||
items = dict(frappe.db.sql('''select posting_date, count(*)
|
||||
from `tabStock Ledger Entry` where item_code=%s
|
||||
and posting_date > date_sub(curdate(), interval 1 year)
|
||||
group by posting_date''', name))
|
||||
|
||||
for date, count in items.iteritems():
|
||||
timestamp = get_timestamp(date)
|
||||
out.update({ timestamp: count })
|
||||
|
||||
return out
|
||||
|
||||
def validate_end_of_life(item_code, end_of_life=None, disabled=None, verbose=1):
|
||||
if (not end_of_life) or (disabled is None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user