mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
Fixes saving of Sales Order and fetching Prices frappe/frappe#478
This commit is contained in:
@@ -260,8 +260,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 = '0000-00-00'
|
where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now())""", d.item_code)
|
||||||
or end_of_life > now())""", 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 not acc:
|
if not acc:
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class AccountsController(TransactionBase):
|
|||||||
"""set missing item values"""
|
"""set missing item values"""
|
||||||
from erpnext.stock.get_item_details import get_item_details
|
from erpnext.stock.get_item_details import get_item_details
|
||||||
if hasattr(self, "fname"):
|
if hasattr(self, "fname"):
|
||||||
parent_dict = {}
|
parent_dict = {"doctype": self.doctype}
|
||||||
for fieldname in self.meta.get_valid_columns():
|
for fieldname in self.meta.get_valid_columns():
|
||||||
parent_dict[fieldname] = self.get(fieldname)
|
parent_dict[fieldname] = self.get(fieldname)
|
||||||
|
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ def make_sales_invoice(source_name, target_doc=None):
|
|||||||
def update_item(source, target, source_parent):
|
def update_item(source, target, source_parent):
|
||||||
target.amount = flt(source.amount) - flt(source.billed_amt)
|
target.amount = flt(source.amount) - flt(source.billed_amt)
|
||||||
target.base_amount = target.amount * flt(source_parent.conversion_rate)
|
target.base_amount = target.amount * flt(source_parent.conversion_rate)
|
||||||
target.qty = source.rate and target.amount / flt(source.rate) or obj.qty
|
target.qty = source.rate and target.amount / flt(source.rate) or source.qty
|
||||||
|
|
||||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||||
"Sales Order": {
|
"Sales Order": {
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
// toggle columns
|
// toggle columns
|
||||||
var item_grid = this.frm.fields_dict[this.fname].grid;
|
var item_grid = this.frm.fields_dict[this.fname].grid;
|
||||||
var show = (this.frm.doc.currency != company_currency) ||
|
var show = (this.frm.doc.currency != company_currency) ||
|
||||||
(cur_frm.doc.other_charges.filter(
|
((cur_frm.doc.other_charges || []).filter(
|
||||||
function(d) { return d.included_in_print_rate===1}).length);
|
function(d) { return d.included_in_print_rate===1}).length);
|
||||||
|
|
||||||
$.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) {
|
$.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
frappe.provide("erpnext.item");
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc) {
|
cur_frm.cscript.refresh = function(doc) {
|
||||||
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
|
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
|
||||||
// read only if any stock ledger entry exists
|
// read only if any stock ledger entry exists
|
||||||
@@ -19,8 +21,19 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
cur_frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method'],
|
cur_frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method'],
|
||||||
doc.__sle_exists=="exists" ? false : true);
|
doc.__sle_exists=="exists" ? false : true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
erpnext.item.toggle_reqd(cur_frm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
erpnext.item.toggle_reqd = function(frm) {
|
||||||
|
frm.toggle_reqd("default_warehouse", frm.doc.is_stock_item==="Yes");
|
||||||
|
};
|
||||||
|
|
||||||
|
frappe.ui.form.on("Item", "is_stock_item", function(frm) {
|
||||||
|
erpnext.item.toggle_reqd(frm);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.make_dashboard = function() {
|
cur_frm.cscript.make_dashboard = function() {
|
||||||
cur_frm.dashboard.reset();
|
cur_frm.dashboard.reset();
|
||||||
if(cur_frm.doc.__islocal)
|
if(cur_frm.doc.__islocal)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from frappe import msgprint, _
|
|||||||
from frappe.utils import cstr, flt, getdate, now_datetime, formatdate
|
from frappe.utils import cstr, flt, getdate, now_datetime, formatdate
|
||||||
from frappe.website.website_generator import WebsiteGenerator
|
from frappe.website.website_generator import WebsiteGenerator
|
||||||
|
|
||||||
class WarehouseNotSet(Exception): pass
|
class WarehouseNotSet(frappe.ValidationError): pass
|
||||||
|
|
||||||
class Item(WebsiteGenerator):
|
class Item(WebsiteGenerator):
|
||||||
def onload(self):
|
def onload(self):
|
||||||
|
|||||||
@@ -369,8 +369,8 @@ class StockEntry(StockController):
|
|||||||
arg = json.loads(arg)
|
arg = json.loads(arg)
|
||||||
item = frappe.db.sql("""select stock_uom, description, item_name,
|
item = frappe.db.sql("""select stock_uom, description, item_name,
|
||||||
expense_account, buying_cost_center from `tabItem`
|
expense_account, buying_cost_center from `tabItem`
|
||||||
where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00'
|
where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now())""",
|
||||||
or end_of_life > now())""", (arg.get('item_code')), as_dict = 1)
|
(arg.get('item_code')), as_dict = 1)
|
||||||
if not item:
|
if not item:
|
||||||
msgprint("Item is not active", raise_exception=1)
|
msgprint("Item is not active", raise_exception=1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user