Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Feb 20, 2017
2 parents 1b59b62 + 66b3730 commit f8cff12
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 115 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe

__version__ = '7.2.21'
__version__ = '7.2.22'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
15 changes: 12 additions & 3 deletions erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions erpnext/controllers/buying_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ def create_raw_materials_supplied(self, raw_material_table):
for item in self.get("items"):
item.rm_supp_cost = 0.0

if self.is_subcontracted == "No" and self.get("supplied_items"):
self.set('supplied_items', [])

def update_raw_materials_supplied(self, item, raw_material_table):
bom_items = self.get_items_from_bom(item.item_code, item.bom)
raw_materials_cost = 0
Expand Down
3 changes: 2 additions & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,5 @@ erpnext.patches.v7_2.update_website_for_variant
erpnext.patches.v7_2.update_doctype_status
erpnext.patches.v7_2.update_salary_slips
erpnext.patches.v7_2.set_null_value_to_fields
erpnext.patches.v7_2.update_abbr_in_salary_slips
erpnext.patches.v7_2.update_abbr_in_salary_slips
erpnext.patches.v7_2.empty_supplied_items_for_non_subcontracted
14 changes: 14 additions & 0 deletions erpnext/patches/v7_2/empty_supplied_items_for_non_subcontracted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe

def execute():
for doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt"]:
child_table = 'Purchase Receipt Item Supplied' if doctype != 'Purchase Order' else 'Purchase Order Item Supplied'
for data in frappe.db.sql(""" select distinct `tab{doctype}`.name from `tab{doctype}` , `tab{child_table}`
where `tab{doctype}`.name = `tab{child_table}`.parent and `tab{doctype}`.docstatus != 2
and `tab{doctype}`.is_subcontracted = 'No' """.format(doctype = doctype, child_table = child_table), as_dict=1):
frappe.db.sql(""" delete from `tab{child_table}`
where parent = %s and parenttype = %s""".format(child_table= child_table), (data.name, doctype))
7 changes: 6 additions & 1 deletion erpnext/public/js/setup_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ function load_erpnext_slides() {
fy = ["01-01", "12-31"];
next_year = current_year;
}


var year_start_date = current_year + "-" + fy[0];
if(year_start_date > get_today()) {
next_year = current_year
current_year -= 1;
}
slide.get_field("fy_start_date").set_input(current_year + "-" + fy[0]);
slide.get_field("fy_end_date").set_input(next_year + "-" + fy[1]);
}
Expand Down
2 changes: 1 addition & 1 deletion erpnext/schools/doctype/assessment/assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def validate_overlap(self):
validate_overlap_for(self, "Assessment", "student_group")

validate_overlap_for(self, "Assessment", "room")
validate_overlap_for(self, "Assessment", "supervisor", self.instructor)
validate_overlap_for(self, "Assessment", "supervisor", self.supervisor)


def get_assessment_list(doctype, txt, filters, limit_start, limit_page_length=20):
Expand Down
53 changes: 32 additions & 21 deletions erpnext/stock/doctype/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
frappe.provide("erpnext.item");

frappe.ui.form.on("Item", {
setup: function(frm) {
frm.add_fetch('attribute', 'numeric_values', 'numeric_values');
frm.add_fetch('attribute', 'from_range', 'from_range');
frm.add_fetch('attribute', 'to_range', 'to_range');
frm.add_fetch('attribute', 'increment', 'increment');
frm.add_fetch('tax_type', 'tax_rate', 'tax_rate');
},
onload: function(frm) {
erpnext.item.setup_queries(frm);
if (frm.doc.variant_of){
Expand All @@ -16,7 +23,6 @@ frappe.ui.form.on("Item", {
},

refresh: function(frm) {

if(frm.doc.is_stock_item) {
frm.add_custom_button(__("Balance"), function() {
frappe.route_options = {
Expand Down Expand Up @@ -54,9 +60,9 @@ frappe.ui.form.on("Item", {
}, __("View"));

frm.add_custom_button(__("Variant"), function() {
erpnext.item.make_variant()
erpnext.item.make_variant(frm);
}, __("Make"));
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
frm.page.set_inner_btn_group_as_primary(__("Make"));
}
if (frm.doc.variant_of) {
frm.set_intro(__("This Item is a Variant of {0} (Template). Attributes will be copied over from the template unless 'No Copy' is set", [frm.doc.variant_of]), true);
Expand All @@ -79,6 +85,17 @@ frappe.ui.form.on("Item", {

frm.toggle_enable("is_fixed_asset", (frm.doc.__islocal || (!frm.doc.is_stock_item &&
((frm.doc.__onload && frm.doc.__onload.asset_exists) ? false : true))));

frm.add_custom_button(__('Duplicate'), function() {
var new_item = frappe.model.copy_doc(frm.doc);
if(new_item.item_name===new_item.item_code) {
new_item.item_name = null;
}
if(new_item.description===new_item.description) {
new_item.description = null;
}
frappe.set_route('Form', 'Item', new_item.name);
});
},

validate: function(frm){
Expand All @@ -88,13 +105,13 @@ frappe.ui.form.on("Item", {
image: function(frm) {
refresh_field("image_view");
},

is_fixed_asset: function(frm) {
if (frm.doc.is_fixed_asset) {
frm.set_value("is_stock_item", 0);
}
},

page_name: frappe.utils.warn_page_name_change,

item_code: function(frm) {
Expand Down Expand Up @@ -191,15 +208,15 @@ $.extend(erpnext.item, {

frm.fields_dict.reorder_levels.grid.get_field("warehouse").get_query = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];

var filters = {
"is_group": 0
}

if (d.parent_warehouse) {
filters.extend({"parent_warehouse": d.warehouse_group})
}

return {
filters: filters
}
Expand All @@ -212,7 +229,8 @@ $.extend(erpnext.item, {
return;

frappe.require('assets/js/item-dashboard.min.js', function() {
var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;"><a href="#stock-balance">Stock Levels</a></h5>');
var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;">\
<a href="#stock-balance">Stock Levels</a></h5>');
erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({
parent: section,
item_code: frm.doc.name
Expand All @@ -234,12 +252,12 @@ $.extend(erpnext.item, {
}
},

make_variant: function(doc) {
make_variant: function(frm) {
var fields = []

for(var i=0;i< cur_frm.doc.attributes.length;i++){
for(var i=0;i< frm.doc.attributes.length;i++){
var fieldtype, desc;
var row = cur_frm.doc.attributes[i];
var row = frm.doc.attributes[i];
if (row.numeric_values){
fieldtype = "Float";
desc = "Min Value: "+ row.from_range +" , Max Value: "+ row.to_range +", in Increments of: "+ row.increment
Expand Down Expand Up @@ -268,7 +286,7 @@ $.extend(erpnext.item, {
frappe.call({
method:"erpnext.controllers.item_variant.get_variant",
args: {
"template": cur_frm.doc.name,
"template": frm.doc.name,
"args": d.get_values()
},
callback: function(r) {
Expand All @@ -290,7 +308,7 @@ $.extend(erpnext.item, {
frappe.call({
method:"erpnext.controllers.item_variant.create_variant",
args: {
"item": cur_frm.doc.name,
"item": frm.doc.name,
"args": d.get_values()
},
callback: function(r) {
Expand Down Expand Up @@ -358,10 +376,3 @@ $.extend(erpnext.item, {
frm.fields_dict.attributes.grid.toggle_enable("attribute_value", !frm.doc.variant_of);
}
});


cur_frm.add_fetch('attribute', 'numeric_values', 'numeric_values');
cur_frm.add_fetch('attribute', 'from_range', 'from_range');
cur_frm.add_fetch('attribute', 'to_range', 'to_range');
cur_frm.add_fetch('attribute', 'increment', 'increment');
cur_frm.add_fetch('tax_type', 'tax_rate', 'tax_rate');
8 changes: 4 additions & 4 deletions erpnext/stock/doctype/item/item.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"in_standard_filter": 0,
"label": "Item Code",
"length": 0,
"no_copy": 1,
"no_copy": 0,
"oldfieldname": "item_code",
"oldfieldtype": "Data",
"permlevel": 0,
Expand Down Expand Up @@ -134,7 +134,7 @@
},
{
"allow_on_submit": 0,
"bold": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "item_name",
Expand All @@ -156,7 +156,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
Expand Down Expand Up @@ -2713,7 +2713,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
"modified": "2017-01-18 17:43:20.262925",
"modified": "2017-02-17 04:00:38.825621",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
Expand Down
20 changes: 15 additions & 5 deletions erpnext/stock/doctype/item/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down Expand Up @@ -63,6 +63,9 @@ def after_insert(self):
def validate(self):
super(Item, self).validate()

if not self.item_name:
self.item_name = self.item_code

if not self.description:
self.description = self.item_name

Expand Down Expand Up @@ -470,12 +473,12 @@ def cant_change(self):
def check_if_linked_document_exists(self, key):
linked_doctypes = ["Delivery Note Item", "Sales Invoice Item", "Purchase Receipt Item",
"Purchase Invoice Item", "Stock Entry Detail", "Stock Reconciliation Item"]
# For "Is Stock Item", following doctypes is important

# For "Is Stock Item", following doctypes is important
# because reserved_qty, ordered_qty and requested_qty updated from these doctypes
if key == "is_stock_item":
linked_doctypes += ["Sales Order Item", "Purchase Order Item", "Material Request Item"]

for doctype in linked_doctypes:
if frappe.db.get_value(doctype, filters={"item_code": self.name, "docstatus": 1}) or \
frappe.db.get_value("Production Order",
Expand Down Expand Up @@ -667,10 +670,17 @@ def validate_variant_attributes(self):

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):
Expand Down
Loading

0 comments on commit f8cff12

Please sign in to comment.