mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-02 16:13:22 +00:00
Add in transaction.js, cleanups
This commit is contained in:
@@ -38,7 +38,7 @@ frappe.ui.form.on("Delivery Note", {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
frm.set_query('expense_account', 'items', function(doc, cdt, cdn) {
|
||||
if (erpnext.is_perpetual_inventory_enabled(doc.company)) {
|
||||
return {
|
||||
@@ -61,7 +61,7 @@ frappe.ui.form.on("Delivery Note", {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$.extend(frm.cscript, new erpnext.stock.DeliveryNoteController({frm: frm}));
|
||||
},
|
||||
@@ -83,43 +83,6 @@ frappe.ui.form.on("Delivery Note Item", {
|
||||
cost_center: function(frm, dt, dn) {
|
||||
var d = locals[dt][dn];
|
||||
frm.update_in_all_rows('items', 'cost_center', d.cost_center);
|
||||
},
|
||||
item_code: function(frm, dt, dn) {
|
||||
var d = locals[dt][dn];
|
||||
if(d.item_code) {
|
||||
var args = {
|
||||
'item_code': d.item_code,
|
||||
};
|
||||
frappe.call({
|
||||
doc: frm.doc,
|
||||
method: "get_batched_serialized_details",
|
||||
args: args,
|
||||
callback: function(r) {
|
||||
if(r.message) {
|
||||
$.each(r.message, function(k, v) {
|
||||
d[k] = v;
|
||||
});
|
||||
let opts = {
|
||||
frm: frm,
|
||||
item: d,
|
||||
warehouse_details: {
|
||||
type: "From Warehouse",
|
||||
name: d.warehouse
|
||||
},
|
||||
}
|
||||
if(d && d.has_batch_no && !d.batch_no) {
|
||||
opts.has_batch = 1;
|
||||
} else if(d && d.has_serial_no && !d.serial_no) {
|
||||
opts.has_batch = 0;
|
||||
}
|
||||
if(opts.hasOwnProperty("has_batch")) {
|
||||
let serial_no_batch_selector = new erpnext.SerialNoBatchSelector(opts);
|
||||
}
|
||||
refresh_field("items");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -272,7 +235,7 @@ frappe.ui.form.on('Delivery Note', {
|
||||
company: function(frm) {
|
||||
frm.trigger("unhide_account_head");
|
||||
},
|
||||
|
||||
|
||||
unhide_account_head: function(frm) {
|
||||
// unhide expense_account and cost_center if perpetual inventory is enabled in the company
|
||||
var aii_enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company)
|
||||
|
||||
@@ -301,24 +301,6 @@ class DeliveryNote(SellingController):
|
||||
|
||||
self.load_from_db()
|
||||
|
||||
def get_batched_serialized_details(self, item_code):
|
||||
item = frappe.db.sql("""
|
||||
select
|
||||
has_serial_no,
|
||||
has_batch_no
|
||||
from
|
||||
`tabItem`
|
||||
where
|
||||
name = %s""",
|
||||
(item_code), as_dict = 1)
|
||||
|
||||
item = item[0]
|
||||
|
||||
return frappe._dict({
|
||||
'has_serial_no' : item.has_serial_no,
|
||||
'has_batch_no' : item.has_batch_no
|
||||
})
|
||||
|
||||
def update_billed_amount_based_on_so(so_detail, update_modified=True):
|
||||
# Billed against Sales Order directly
|
||||
billed_against_so = frappe.db.sql("""select sum(amount) from `tabSales Invoice Item`
|
||||
|
||||
@@ -564,21 +564,14 @@ erpnext.stock.select_batch_and_serial_no = (frm, item) => {
|
||||
}
|
||||
}
|
||||
|
||||
let opts = {
|
||||
if(item && item.has_serial_no
|
||||
&& frm.doc.purpose === 'Material Receipt') {
|
||||
return;
|
||||
}
|
||||
|
||||
let serial_no_batch_selector = new erpnext.SerialNoBatchSelector({
|
||||
frm: frm,
|
||||
item: item,
|
||||
warehouse_details: get_warehouse_type_and_name(item),
|
||||
}
|
||||
|
||||
if(item && item.has_batch_no && !item.batch_no) {
|
||||
opts.has_batch = 1;
|
||||
} else if(item && item.has_serial_no && !item.serial_no
|
||||
&& frm.doc.purpose !== 'Material Receipt') {
|
||||
|
||||
opts.has_batch = 0;
|
||||
}
|
||||
|
||||
if(opts.hasOwnProperty("has_batch")) {
|
||||
let serial_no_batch_selector = new erpnext.SerialNoBatchSelector(opts);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ def get_item_details(args):
|
||||
|
||||
out.update(get_pricing_rule_for_item(args))
|
||||
|
||||
if (args.get("doctype") == "Delivery Note" or
|
||||
if (args.get("doctype") == "Delivery Note" or
|
||||
(args.get("doctype") == "Sales Invoice" and args.get('update_stock'))) \
|
||||
and out.warehouse and out.stock_qty > 0:
|
||||
|
||||
|
||||
if out.has_serial_no:
|
||||
out.serial_no = get_serial_no(out)
|
||||
|
||||
@@ -96,6 +96,16 @@ def get_item_details(args):
|
||||
|
||||
return out
|
||||
|
||||
# print(frappe._dict({
|
||||
# 'has_serial_no' : out.has_serial_no,
|
||||
# 'has_batch_no' : out.has_batch_no
|
||||
# }))
|
||||
|
||||
# return frappe._dict({
|
||||
# 'has_serial_no' : out.has_serial_no,
|
||||
# 'has_batch_no' : out.has_batch_no
|
||||
# })
|
||||
|
||||
def process_args(args):
|
||||
if isinstance(args, basestring):
|
||||
args = json.loads(args)
|
||||
|
||||
Reference in New Issue
Block a user