minor fixes
This commit is contained in:
parent
0aa71a5c41
commit
139dc7b9b2
@ -73,43 +73,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
this.supplier_address();
|
this.supplier_address();
|
||||||
},
|
},
|
||||||
|
|
||||||
item_code: function(doc, cdt, cdn) {
|
|
||||||
var me = this;
|
|
||||||
var item = wn.model.get_doc(cdt, cdn);
|
|
||||||
if(item.item_code) {
|
|
||||||
if(!this.validate_company_and_party("supplier")) {
|
|
||||||
cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove();
|
|
||||||
} else {
|
|
||||||
return this.frm.call({
|
|
||||||
method: "erpnext.stock.get_item_details.get_item_details",
|
|
||||||
child: item,
|
|
||||||
args: {
|
|
||||||
args: {
|
|
||||||
item_code: item.item_code,
|
|
||||||
warehouse: item.warehouse,
|
|
||||||
doctype: me.frm.doc.doctype,
|
|
||||||
docname: me.frm.doc.name,
|
|
||||||
supplier: me.frm.doc.supplier,
|
|
||||||
conversion_rate: me.frm.doc.conversion_rate,
|
|
||||||
buying_price_list: me.frm.doc.buying_price_list,
|
|
||||||
price_list_currency: me.frm.doc.price_list_currency,
|
|
||||||
plc_conversion_rate: me.frm.doc.plc_conversion_rate,
|
|
||||||
is_subcontracted: me.frm.doc.is_subcontracted,
|
|
||||||
company: me.frm.doc.company,
|
|
||||||
currency: me.frm.doc.currency,
|
|
||||||
transaction_date: me.frm.doc.transaction_date
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(r) {
|
|
||||||
if(!r.exc) {
|
|
||||||
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
buying_price_list: function() {
|
buying_price_list: function() {
|
||||||
this.get_price_list_currency("Buying");
|
this.get_price_list_currency("Buying");
|
||||||
},
|
},
|
||||||
|
@ -90,7 +90,6 @@ class AccountsController(TransactionBase):
|
|||||||
for item in self.doclist.get({"parentfield": self.fname}):
|
for item in self.doclist.get({"parentfield": self.fname}):
|
||||||
if item.fields.get("item_code"):
|
if item.fields.get("item_code"):
|
||||||
args = item.fields.copy().update(self.doc.fields)
|
args = item.fields.copy().update(self.doc.fields)
|
||||||
args.price_list = args.selling_price_list or args.buying_price_list
|
|
||||||
ret = get_item_details(args)
|
ret = get_item_details(args)
|
||||||
for fieldname, value in ret.items():
|
for fieldname, value in ret.items():
|
||||||
if self.meta.get_field(fieldname, parentfield=self.fname) and \
|
if self.meta.get_field(fieldname, parentfield=self.fname) and \
|
||||||
|
@ -416,7 +416,7 @@ def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1):
|
|||||||
item.stock_uom,
|
item.stock_uom,
|
||||||
item.default_warehouse,
|
item.default_warehouse,
|
||||||
item.expense_account as expense_account,
|
item.expense_account as expense_account,
|
||||||
item.buying_cost_center
|
item.buying_cost_center as cost_center
|
||||||
from
|
from
|
||||||
`tab%(table)s` bom_item, `tabItem` item
|
`tab%(table)s` bom_item, `tabItem` item
|
||||||
where
|
where
|
||||||
|
@ -108,16 +108,22 @@ def execute():
|
|||||||
|
|
||||||
def reload_docs(docs):
|
def reload_docs(docs):
|
||||||
for dn in docs:
|
for dn in docs:
|
||||||
module = webnotes.conn.get_value("DocType", dn, "module").lower().replace(" ", "_")
|
webnotes.reload_doc(get_module(dn), "doctype", dn.lower().replace(" ", "_"))
|
||||||
webnotes.reload_doc(module, "doctype", dn.lower().replace(" ", "_"))
|
|
||||||
|
|
||||||
# reload all standard print formats
|
# reload all standard print formats
|
||||||
for pf in webnotes.conn.sql("""select name, module from `tabPrint Format`
|
for pf in webnotes.conn.sql("""select name, module from `tabPrint Format`
|
||||||
where ifnull(standard, 'No') = 'Yes'""", as_dict=1):
|
where ifnull(standard, 'No') = 'Yes'""", as_dict=1):
|
||||||
|
try:
|
||||||
webnotes.reload_doc(pf.module, "Print Format", pf.name)
|
webnotes.reload_doc(pf.module, "Print Format", pf.name)
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
pass
|
||||||
|
|
||||||
# reload all standard reports
|
# reload all standard reports
|
||||||
for r in webnotes.conn.sql("""select name, module from `tabReport`
|
for r in webnotes.conn.sql("""select name, ref_doctype from `tabReport`
|
||||||
where ifnull(is_standard, 'No') = 'Yes'
|
where ifnull(is_standard, 'No') = 'Yes'
|
||||||
and report_type in ('Report Builder', 'Query Report')""", as_dict=1):
|
and report_type in ('Report Builder', 'Query Report')""", as_dict=1):
|
||||||
webnotes.reload_doc(r.module, "Report", r.name)
|
webnotes.reload_doc(get_module(r.ref_doctype), "Report", r.name)
|
||||||
|
|
||||||
|
def get_module(dn):
|
||||||
|
return webnotes.conn.get_value("DocType", dn, "module").lower().replace(" ", "_")
|
@ -111,6 +111,50 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
item_code: function(doc, cdt, cdn) {
|
||||||
|
var me = this;
|
||||||
|
var item = wn.model.get_doc(cdt, cdn);
|
||||||
|
if(item.item_code || item.barcode || item.serial_no) {
|
||||||
|
if(!this.validate_company_and_party()) {
|
||||||
|
cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove();
|
||||||
|
} else {
|
||||||
|
return this.frm.call({
|
||||||
|
method: "erpnext.stock.get_item_details.get_item_details",
|
||||||
|
child: item,
|
||||||
|
args: {
|
||||||
|
args: {
|
||||||
|
item_code: item.item_code,
|
||||||
|
barcode: item.barcode,
|
||||||
|
serial_no: item.serial_no,
|
||||||
|
warehouse: item.warehouse,
|
||||||
|
doctype: me.frm.doc.doctype,
|
||||||
|
docname: me.frm.doc.name,
|
||||||
|
customer: me.frm.doc.customer,
|
||||||
|
supplier: me.frm.doc.supplier,
|
||||||
|
currency: me.frm.doc.currency,
|
||||||
|
conversion_rate: me.frm.doc.conversion_rate,
|
||||||
|
price_list: me.frm.doc.selling_price_list ||
|
||||||
|
me.frm.doc.buying_price_list,
|
||||||
|
price_list_currency: me.frm.doc.price_list_currency,
|
||||||
|
plc_conversion_rate: me.frm.doc.plc_conversion_rate,
|
||||||
|
company: me.frm.doc.company,
|
||||||
|
order_type: me.frm.doc.order_type,
|
||||||
|
is_pos: cint(me.frm.doc.is_pos),
|
||||||
|
is_subcontracted: me.frm.doc.is_subcontracted,
|
||||||
|
transaction_date: me.frm.doc.transaction_date
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if(!r.exc) {
|
||||||
|
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
serial_no: function(doc, cdt, cdn) {
|
serial_no: function(doc, cdt, cdn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var item = wn.model.get_doc(cdt, cdn);
|
var item = wn.model.get_doc(cdt, cdn);
|
||||||
@ -455,26 +499,19 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
</table></div>';
|
</table></div>';
|
||||||
},
|
},
|
||||||
|
|
||||||
_validate_before_fetch: function(fieldname) {
|
validate_company_and_party: function() {
|
||||||
var me = this;
|
|
||||||
if(!me.frm.doc[fieldname]) {
|
|
||||||
return (wn._("Please specify") + ": " +
|
|
||||||
wn.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) +
|
|
||||||
". " + wn._("It is needed to fetch Item Details."));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
validate_company_and_party: function(party_field) {
|
|
||||||
var me = this;
|
var me = this;
|
||||||
var valid = true;
|
var valid = true;
|
||||||
var msg = "";
|
|
||||||
$.each(["company", party_field], function(i, fieldname) {
|
$.each(["company", "customer", "supplier"], function(i, fieldname) {
|
||||||
var msg_for_fieldname = me._validate_before_fetch(fieldname);
|
if(wn.meta.has_field(me.frm.doc.doctype, fieldname)) {
|
||||||
if(msg_for_fieldname) {
|
if (!me.frm.doc[fieldname]) {
|
||||||
msgprint(msg_for_fieldname);
|
msgprint(wn._("Please specify") + ": " +
|
||||||
|
wn.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) +
|
||||||
|
". " + wn._("It is needed to fetch Item Details."));
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return valid;
|
return valid;
|
||||||
},
|
},
|
||||||
|
@ -91,8 +91,8 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
|||||||
|
|
||||||
validate_company_and_party: function(party_field) {
|
validate_company_and_party: function(party_field) {
|
||||||
if(!this.frm.doc.quotation_to) {
|
if(!this.frm.doc.quotation_to) {
|
||||||
msgprint(wn._("Please select a value for" + " " + wn.meta.get_label(this.frm.doc.doctype,
|
msgprint(wn._("Please select a value for" + " " +
|
||||||
"quotation_to", this.frm.doc.name)));
|
wn.meta.get_label(this.frm.doc.doctype, "quotation_to", this.frm.doc.name)));
|
||||||
return false;
|
return false;
|
||||||
} else if (this.frm.doc.quotation_to == "Lead") {
|
} else if (this.frm.doc.quotation_to == "Lead") {
|
||||||
return true;
|
return true;
|
||||||
|
@ -119,46 +119,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
this.item_code(doc, cdt, cdn);
|
this.item_code(doc, cdt, cdn);
|
||||||
},
|
},
|
||||||
|
|
||||||
item_code: function(doc, cdt, cdn) {
|
|
||||||
var me = this;
|
|
||||||
var item = wn.model.get_doc(cdt, cdn);
|
|
||||||
if(item.item_code || item.barcode || item.serial_no) {
|
|
||||||
if(!this.validate_company_and_party("customer")) {
|
|
||||||
cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove();
|
|
||||||
} else {
|
|
||||||
return this.frm.call({
|
|
||||||
method: "erpnext.stock.get_item_details.get_item_details",
|
|
||||||
child: item,
|
|
||||||
args: {
|
|
||||||
args: {
|
|
||||||
item_code: item.item_code,
|
|
||||||
barcode: item.barcode,
|
|
||||||
serial_no: item.serial_no,
|
|
||||||
warehouse: item.warehouse,
|
|
||||||
doctype: me.frm.doc.doctype,
|
|
||||||
parentfield: item.parentfield,
|
|
||||||
customer: me.frm.doc.customer,
|
|
||||||
currency: me.frm.doc.currency,
|
|
||||||
conversion_rate: me.frm.doc.conversion_rate,
|
|
||||||
price_list: me.frm.doc.selling_price_list,
|
|
||||||
price_list_currency: me.frm.doc.price_list_currency,
|
|
||||||
plc_conversion_rate: me.frm.doc.plc_conversion_rate,
|
|
||||||
company: me.frm.doc.company,
|
|
||||||
order_type: me.frm.doc.order_type,
|
|
||||||
is_pos: cint(me.frm.doc.is_pos),
|
|
||||||
"transaction_type": "selling"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(r) {
|
|
||||||
if(!r.exc) {
|
|
||||||
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
selling_price_list: function() {
|
selling_price_list: function() {
|
||||||
this.get_price_list_currency("Selling");
|
this.get_price_list_currency("Selling");
|
||||||
},
|
},
|
||||||
|
@ -578,7 +578,7 @@ class DocType(StockController):
|
|||||||
se_child.stock_uom = item_dict[d]["stock_uom"]
|
se_child.stock_uom = item_dict[d]["stock_uom"]
|
||||||
se_child.qty = flt(item_dict[d]["qty"])
|
se_child.qty = flt(item_dict[d]["qty"])
|
||||||
se_child.expense_account = item_dict[d]["expense_account"] or expense_account
|
se_child.expense_account = item_dict[d]["expense_account"] or expense_account
|
||||||
se_child.cost_center = item_dict[d]["buying_cost_center"] or cost_center
|
se_child.cost_center = item_dict[d]["cost_center"] or cost_center
|
||||||
|
|
||||||
# in stock uom
|
# in stock uom
|
||||||
se_child.transfer_qty = flt(item_dict[d]["qty"])
|
se_child.transfer_qty = flt(item_dict[d]["qty"])
|
||||||
|
@ -36,6 +36,9 @@ def get_item_details(args):
|
|||||||
if not args.get("transaction_type"):
|
if not args.get("transaction_type"):
|
||||||
args.transaction_type = "selling" if args.get("customer") else "buying"
|
args.transaction_type = "selling" if args.get("customer") else "buying"
|
||||||
|
|
||||||
|
if not args.get("price_list"):
|
||||||
|
args.price_list = args.get("selling_price_list") or args.get("buying_price_list")
|
||||||
|
|
||||||
if args.barcode:
|
if args.barcode:
|
||||||
args.item_code = get_item_code(barcode=args.barcode)
|
args.item_code = get_item_code(barcode=args.barcode)
|
||||||
elif not args.item_code and args.serial_no:
|
elif not args.item_code and args.serial_no:
|
||||||
@ -54,31 +57,22 @@ def get_item_details(args):
|
|||||||
out.update(get_available_qty(args.item_code, out.warehouse))
|
out.update(get_available_qty(args.item_code, out.warehouse))
|
||||||
out.update(get_projected_qty(item.name, out.warehouse))
|
out.update(get_projected_qty(item.name, out.warehouse))
|
||||||
|
|
||||||
if args.transaction_date and item.lead_time_days:
|
|
||||||
out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
|
|
||||||
item.lead_time_days)
|
|
||||||
|
|
||||||
get_price_list_rate(args, item_bean, out)
|
get_price_list_rate(args, item_bean, out)
|
||||||
|
|
||||||
# out.update(_get_item_discount(out.item_group, args.customer))
|
out.update(get_item_discount(out.item_group, args.customer))
|
||||||
|
|
||||||
if args.transaction_type == "selling" and cint(args.is_pos):
|
if args.transaction_type == "selling" and cint(args.is_pos):
|
||||||
out.update(get_pos_settings_item_details(args.company, args))
|
out.update(get_pos_settings_item_details(args.company, args))
|
||||||
|
|
||||||
if args.doctype in ("Sales Invoice", "Delivery Note"):
|
if args.get("doctype") in ("Sales Invoice", "Delivery Note"):
|
||||||
if item_bean.doc.has_serial_no == "Yes" and not args.serial_no:
|
if item_bean.doc.has_serial_no == "Yes" and not args.serial_no:
|
||||||
out.serial_no = get_serial_nos_by_fifo(args, item_bean)
|
out.serial_no = get_serial_nos_by_fifo(args, item_bean)
|
||||||
|
|
||||||
return out
|
if args.transaction_date and item.lead_time_days:
|
||||||
|
out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
|
||||||
|
item.lead_time_days)
|
||||||
|
|
||||||
def get_serial_nos_by_fifo(args, item_bean):
|
return out
|
||||||
return "\n".join(webnotes.conn.sql_list("""select name from `tabSerial No`
|
|
||||||
where item_code=%(item_code)s and warehouse=%(warehouse)s and status='Available'
|
|
||||||
order by timestamp(purchase_date, purchase_time) asc limit %(qty)s""", {
|
|
||||||
"item_code": args.item_code,
|
|
||||||
"warehouse": args.warehouse,
|
|
||||||
"qty": cint(args.qty)
|
|
||||||
}))
|
|
||||||
|
|
||||||
def get_item_code(barcode=None, serial_no=None):
|
def get_item_code(barcode=None, serial_no=None):
|
||||||
if barcode:
|
if barcode:
|
||||||
@ -101,7 +95,7 @@ def validate_item_details(args, item):
|
|||||||
|
|
||||||
if args.transaction_type == "selling":
|
if args.transaction_type == "selling":
|
||||||
# validate if sales item or service item
|
# validate if sales item or service item
|
||||||
if args.order_type == "Maintenance":
|
if args.get("order_type") == "Maintenance":
|
||||||
if item.is_service_item != "Yes":
|
if item.is_service_item != "Yes":
|
||||||
throw(_("Item") + (" %s: " % item.name) +
|
throw(_("Item") + (" %s: " % item.name) +
|
||||||
_("not a service item.") +
|
_("not a service item.") +
|
||||||
@ -115,7 +109,7 @@ def validate_item_details(args, item):
|
|||||||
if item.is_purchase_item != "Yes":
|
if item.is_purchase_item != "Yes":
|
||||||
throw(_("Item") + (" %s: " % item.name) + _("not a purchase item"))
|
throw(_("Item") + (" %s: " % item.name) + _("not a purchase item"))
|
||||||
|
|
||||||
if args.is_subcontracted == "Yes" and item.is_sub_contracted_item != "Yes":
|
if args.get("is_subcontracted") == "Yes" and item.is_sub_contracted_item != "Yes":
|
||||||
throw(_("Item") + (" %s: " % item.name) +
|
throw(_("Item") + (" %s: " % item.name) +
|
||||||
_("not a sub-contracted item.") +
|
_("not a sub-contracted item.") +
|
||||||
_("Please select a sub-contracted item or do not sub-contract the transaction."))
|
_("Please select a sub-contracted item or do not sub-contract the transaction."))
|
||||||
@ -211,22 +205,22 @@ def validate_conversion_rate(args, meta):
|
|||||||
get_field_precision(meta.get_field("plc_conversion_rate"),
|
get_field_precision(meta.get_field("plc_conversion_rate"),
|
||||||
webnotes._dict({"fields": args})))
|
webnotes._dict({"fields": args})))
|
||||||
|
|
||||||
# def _get_item_discount(item_group, customer):
|
def get_item_discount(item_group, customer):
|
||||||
# parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name
|
parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name
|
||||||
# FROM `tabItem Group` AS node, `tabItem Group` AS parent
|
FROM `tabItem Group` AS node, `tabItem Group` AS parent
|
||||||
# WHERE parent.lft <= node.lft and parent.rgt >= node.rgt and node.name = %s
|
WHERE parent.lft <= node.lft and parent.rgt >= node.rgt and node.name = %s
|
||||||
# GROUP BY parent.name
|
GROUP BY parent.name
|
||||||
# ORDER BY parent.lft desc""", (item_group,))]
|
ORDER BY parent.lft desc""", (item_group,))]
|
||||||
#
|
|
||||||
# discount = 0
|
discount = 0
|
||||||
# for d in parent_item_groups:
|
for d in parent_item_groups:
|
||||||
# res = webnotes.conn.sql("""select discount, name from `tabCustomer Discount`
|
res = webnotes.conn.sql("""select discount, name from `tabCustomer Discount`
|
||||||
# where parent = %s and item_group = %s""", (customer, d))
|
where parent = %s and item_group = %s""", (customer, d))
|
||||||
# if res:
|
if res:
|
||||||
# discount = flt(res[0][0])
|
discount = flt(res[0][0])
|
||||||
# break
|
break
|
||||||
#
|
|
||||||
# return {"discount_percentage": discount}
|
return {"discount_percentage": discount}
|
||||||
|
|
||||||
def get_party_item_code(args, item_bean, out):
|
def get_party_item_code(args, item_bean, out):
|
||||||
if args.transaction_type == "selling":
|
if args.transaction_type == "selling":
|
||||||
@ -266,6 +260,15 @@ def get_pos_settings(company):
|
|||||||
|
|
||||||
return pos_settings and pos_settings[0] or None
|
return pos_settings and pos_settings[0] or None
|
||||||
|
|
||||||
|
def get_serial_nos_by_fifo(args, item_bean):
|
||||||
|
return "\n".join(webnotes.conn.sql_list("""select name from `tabSerial No`
|
||||||
|
where item_code=%(item_code)s and warehouse=%(warehouse)s and status='Available'
|
||||||
|
order by timestamp(purchase_date, purchase_time) asc limit %(qty)s""", {
|
||||||
|
"item_code": args.item_code,
|
||||||
|
"warehouse": args.warehouse,
|
||||||
|
"qty": cint(args.qty)
|
||||||
|
}))
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_conversion_factor(item_code, uom):
|
def get_conversion_factor(item_code, uom):
|
||||||
return {"conversion_factor": webnotes.conn.get_value("UOM Conversion Detail",
|
return {"conversion_factor": webnotes.conn.get_value("UOM Conversion Detail",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user