Merge pull request #1867 from nabinhait/v4-hotfix

Multiple fixes
This commit is contained in:
Anand Doshi 2014-06-30 13:20:49 +05:30
commit 8ac4643fd7
7 changed files with 23 additions and 18 deletions

View File

@ -131,6 +131,8 @@ def get_pricing_rule_for_item(args):
if not (args.item_group and args.brand): if not (args.item_group and args.brand):
args.item_group, args.brand = frappe.db.get_value("Item", args.item_code, ["item_group", "brand"]) args.item_group, args.brand = frappe.db.get_value("Item", args.item_code, ["item_group", "brand"])
if not args.item_group:
frappe.throw(_("Item Group not mentioned in item master for item {0}").format(args.item_code))
if args.customer and not (args.customer_group and args.territory): if args.customer and not (args.customer_group and args.territory):
args.customer_group, args.territory = frappe.db.get_value("Customer", args.customer, args.customer_group, args.territory = frappe.db.get_value("Customer", args.customer,
@ -188,12 +190,15 @@ def get_pricing_rules(args):
conditions += """ and %(transaction_date)s between ifnull(valid_from, '2000-01-01') conditions += """ and %(transaction_date)s between ifnull(valid_from, '2000-01-01')
and ifnull(valid_upto, '2500-12-31')""" and ifnull(valid_upto, '2500-12-31')"""
item_group_condition = _get_tree_conditions("Item Group", False)
if item_group_condition: item_group_condition = " or " + item_group_condition
return frappe.db.sql("""select * from `tabPricing Rule` return frappe.db.sql("""select * from `tabPricing Rule`
where (item_code=%(item_code)s or {item_group_condition} or brand=%(brand)s) where (item_code=%(item_code)s {item_group_condition} or brand=%(brand)s)
and docstatus < 2 and ifnull(disable, 0) = 0 and docstatus < 2 and ifnull(disable, 0) = 0
and ifnull({transaction_type}, 0) = 1 {conditions} and ifnull({transaction_type}, 0) = 1 {conditions}
order by priority desc, name desc""".format( order by priority desc, name desc""".format(
item_group_condition=_get_tree_conditions("Item Group", False), item_group_condition=item_group_condition,
transaction_type=args.transaction_type, conditions=conditions), args, as_dict=1) transaction_type=args.transaction_type, conditions=conditions), args, as_dict=1)
def filter_pricing_rules(args, pricing_rules): def filter_pricing_rules(args, pricing_rules):

View File

@ -262,7 +262,7 @@ class SalesInvoice(SellingController):
"""Validate Fixed Asset and whether Income Account Entered Exists""" """Validate Fixed Asset and whether Income Account Entered Exists"""
for d in self.get('entries'): for d in self.get('entries'):
item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem` item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem`
where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now())""", d.item_code) where name = %s""", d.item_code)
acc = frappe.db.sql("""select account_type from `tabAccount` acc = frappe.db.sql("""select account_type from `tabAccount`
where name = %s and docstatus != 2""", d.income_account) where name = %s and docstatus != 2""", d.income_account)
if item and item[0][1] == 'Yes' and acc and acc[0][0] != 'Fixed Asset': if item and item[0][1] == 'Yes' and acc and acc[0][0] != 'Fixed Asset':

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.utils import flt from frappe.utils import flt
from frappe.utils.nestedset import NestedSet from frappe.utils.nestedset import NestedSet

View File

@ -169,13 +169,9 @@ cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query =
} }
cur_frm.cscript.copy_from_item_group = function(doc) { cur_frm.cscript.copy_from_item_group = function(doc) {
frappe.model.with_doc("Item Group", doc.item_group, function(name, r) { return cur_frm.call({
$.each((r.docs[0].item_website_specifications || []), function(i, d) { doc: doc,
var n = frappe.model.add_child(doc, "Item Website Specification", "item_website_specifications"); method: "copy_specification_from_item_group"
n.label = d.label;
n.description = d.description;
});
cur_frm.refresh();
}); });
} }

View File

@ -270,6 +270,15 @@ class Item(WebsiteGenerator):
frappe.db.get_value("Stock Settings", None, "allow_negative_stock")) frappe.db.get_value("Stock Settings", None, "allow_negative_stock"))
frappe.db.auto_commit_on_many_writes = 0 frappe.db.auto_commit_on_many_writes = 0
def copy_specification_from_item_group(self):
self.set("item_website_specifications", [])
if self.item_group:
for label, desc in frappe.db.get_values("Item Website Specification",
{"parent": self.item_group}, ["label", "description"]):
row = self.append("item_website_specifications")
row.label = label
row.description = desc
def validate_end_of_life(item_code, end_of_life=None, verbose=1): def validate_end_of_life(item_code, end_of_life=None, verbose=1):
if not end_of_life: if not end_of_life:
end_of_life = frappe.db.get_value("Item", item_code, "end_of_life") end_of_life = frappe.db.get_value("Item", item_code, "end_of_life")

View File

@ -213,11 +213,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
if(!r.exc) { if(!r.exc) {
var jv_name = frappe.model.make_new_doc_and_get_name('Journal Voucher'); var jv_name = frappe.model.make_new_doc_and_get_name('Journal Voucher');
var jv = locals["Journal Voucher"][jv_name]; var jv = locals["Journal Voucher"][jv_name];
$.extend(jv, r.message[0]); $.extend(jv, r.message);
$.each(r.message.slice(1), function(i, jvd) {
var child = frappe.model.add_child(jv, "Journal Voucher Detail", "entries");
$.extend(child, jvd);
});
loaddoc("Journal Voucher", jv_name); loaddoc("Journal Voucher", jv_name);
} }
} }

View File

@ -40,9 +40,8 @@ class MaintenanceSchedule(TransactionBase):
child.idx = count child.idx = count
count = count + 1 count = count + 1
child.sales_person = d.sales_person child.sales_person = d.sales_person
child.save(1)
self.on_update() self.save()
def on_submit(self): def on_submit(self):
if not self.get('maintenance_schedule_detail'): if not self.get('maintenance_schedule_detail'):