mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 05:39:12 +00:00
chore: release v14 (#42023)
* fix(Sales Order): only show permitted actions (cherry picked from commitc29d955371) # Conflicts: # erpnext/selling/doctype/sales_order/sales_order.js * fix(Delivery Note): only show permitted actions (cherry picked from commit418bdc1dcc) # Conflicts: # erpnext/stock/doctype/delivery_note/delivery_note.js * fix: consistent query field name in item wise purchase register with item wise sales register * chore: resolve conflicts * refactor: remove use of can_create for Payment Request (#41647) (cherry picked from commit47bc5691a1) * fix: incorrect against_account upon reposting (cherry picked from commit20c4098399) * fix: asset value correction in fixed asset register (#41943) * fix: timeout while cancelling LCV (#42030) fix: timeout while canelling LCV --------- Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com> Co-authored-by: ljain112 <ljain112@gmail.com> Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com> Co-authored-by: ruthra kumar <ruthra@erpnext.com> Co-authored-by: Khushi Rawat <142375893+khushi8112@users.noreply.github.com>
This commit is contained in:
@@ -413,7 +413,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
validate_account_head(item.idx, item.expense_account, self.company, "Expense")
|
validate_account_head(item.idx, item.expense_account, self.company, "Expense")
|
||||||
|
|
||||||
def set_against_expense_account(self):
|
def set_against_expense_account(self, force=False):
|
||||||
against_accounts = []
|
against_accounts = []
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.expense_account and (item.expense_account not in against_accounts):
|
if item.expense_account and (item.expense_account not in against_accounts):
|
||||||
@@ -421,6 +421,10 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
self.against_expense_account = ",".join(against_accounts)
|
self.against_expense_account = ",".join(against_accounts)
|
||||||
|
|
||||||
|
def force_set_against_expense_account(self):
|
||||||
|
self.set_against_expense_account()
|
||||||
|
frappe.db.set_value(self.doctype, self.name, "against_expense_account", self.against_expense_account)
|
||||||
|
|
||||||
def po_required(self):
|
def po_required(self):
|
||||||
if frappe.db.get_value("Buying Settings", None, "po_required") == "Yes":
|
if frappe.db.get_value("Buying Settings", None, "po_required") == "Yes":
|
||||||
if frappe.get_value(
|
if frappe.get_value(
|
||||||
|
|||||||
@@ -149,6 +149,10 @@ def start_repost(account_repost_doc=str) -> None:
|
|||||||
doc.make_gl_entries_on_cancel()
|
doc.make_gl_entries_on_cancel()
|
||||||
|
|
||||||
doc.docstatus = 1
|
doc.docstatus = 1
|
||||||
|
if doc.doctype == "Sales Invoice":
|
||||||
|
doc.force_set_against_income_account()
|
||||||
|
else:
|
||||||
|
doc.force_set_against_expense_account()
|
||||||
doc.make_gl_entries()
|
doc.make_gl_entries()
|
||||||
|
|
||||||
elif doc.doctype in ["Payment Entry", "Journal Entry", "Expense Claim"]:
|
elif doc.doctype in ["Payment Entry", "Journal Entry", "Expense Claim"]:
|
||||||
|
|||||||
@@ -768,6 +768,10 @@ class SalesInvoice(SellingController):
|
|||||||
against_acc.append(d.income_account)
|
against_acc.append(d.income_account)
|
||||||
self.against_income_account = ",".join(against_acc)
|
self.against_income_account = ",".join(against_acc)
|
||||||
|
|
||||||
|
def force_set_against_income_account(self):
|
||||||
|
self.set_against_income_account()
|
||||||
|
frappe.db.set_value(self.doctype, self.name, "against_income_account", self.against_income_account)
|
||||||
|
|
||||||
def add_remarks(self):
|
def add_remarks(self):
|
||||||
if not self.remarks:
|
if not self.remarks:
|
||||||
if self.po_no and self.po_date:
|
if self.po_no and self.po_date:
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ def get_items(filters, additional_table_columns):
|
|||||||
.left_join(Item)
|
.left_join(Item)
|
||||||
.on(pii.item_code == Item.name)
|
.on(pii.item_code == Item.name)
|
||||||
.select(
|
.select(
|
||||||
pii.name.as_("pii_name"),
|
pii.name,
|
||||||
pii.parent,
|
pii.parent,
|
||||||
pi.posting_date,
|
pi.posting_date,
|
||||||
pi.credit_to,
|
pi.credit_to,
|
||||||
|
|||||||
@@ -125,9 +125,10 @@ def get_data(filters):
|
|||||||
if assets_linked_to_fb and asset.calculate_depreciation and asset.asset_id not in assets_linked_to_fb:
|
if assets_linked_to_fb and asset.calculate_depreciation and asset.asset_id not in assets_linked_to_fb:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
asset_value = get_asset_value_after_depreciation(
|
depreciation_amount = depreciation_amount_map.get(asset.asset_id) or 0.0
|
||||||
asset.asset_id, finance_book
|
asset_value = (
|
||||||
) or get_asset_value_after_depreciation(asset.asset_id)
|
asset.gross_purchase_amount - asset.opening_accumulated_depreciation - depreciation_amount
|
||||||
|
)
|
||||||
|
|
||||||
row = {
|
row = {
|
||||||
"asset_id": asset.asset_id,
|
"asset_id": asset.asset_id,
|
||||||
@@ -139,7 +140,7 @@ def get_data(filters):
|
|||||||
or pi_supplier_map.get(asset.purchase_invoice),
|
or pi_supplier_map.get(asset.purchase_invoice),
|
||||||
"gross_purchase_amount": asset.gross_purchase_amount,
|
"gross_purchase_amount": asset.gross_purchase_amount,
|
||||||
"opening_accumulated_depreciation": asset.opening_accumulated_depreciation,
|
"opening_accumulated_depreciation": asset.opening_accumulated_depreciation,
|
||||||
"depreciated_amount": depreciation_amount_map.get(asset.asset_id) or 0.0,
|
"depreciated_amount": depreciation_amount,
|
||||||
"available_for_use_date": asset.available_for_use_date,
|
"available_for_use_date": asset.available_for_use_date,
|
||||||
"location": asset.location,
|
"location": asset.location,
|
||||||
"asset_category": asset.asset_category,
|
"asset_category": asset.asset_category,
|
||||||
|
|||||||
@@ -265,7 +265,11 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
}
|
}
|
||||||
|
|
||||||
const me = this;
|
const me = this;
|
||||||
if (!this.frm.is_new() && this.frm.doc.docstatus === 0) {
|
if (
|
||||||
|
!this.frm.is_new()
|
||||||
|
&& this.frm.doc.docstatus === 0
|
||||||
|
&& frappe.model.can_create("Quality Inspection")
|
||||||
|
) {
|
||||||
this.frm.add_custom_button(__("Quality Inspection(s)"), () => {
|
this.frm.add_custom_button(__("Quality Inspection(s)"), () => {
|
||||||
me.make_quality_inspection();
|
me.make_quality_inspection();
|
||||||
}, __("Create"));
|
}, __("Create"));
|
||||||
|
|||||||
@@ -48,8 +48,13 @@ frappe.ui.form.on("Sales Order", {
|
|||||||
frm.set_df_property('packed_items', 'cannot_delete_rows', true);
|
frm.set_df_property('packed_items', 'cannot_delete_rows', true);
|
||||||
},
|
},
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if(frm.doc.docstatus === 1 && frm.doc.status !== 'Closed'
|
if(
|
||||||
&& flt(frm.doc.per_delivered, 6) < 100 && flt(frm.doc.per_billed, 6) < 100) {
|
frm.doc.docstatus === 1
|
||||||
|
&& frm.doc.status !== "Closed"
|
||||||
|
&& flt(frm.doc.per_delivered, 6) < 100
|
||||||
|
&& flt(frm.doc.per_billed, 6) < 100
|
||||||
|
&& frm.has_perm("write")
|
||||||
|
) {
|
||||||
frm.add_custom_button(__('Update Items'), () => {
|
frm.add_custom_button(__('Update Items'), () => {
|
||||||
erpnext.utils.update_child_items({
|
erpnext.utils.update_child_items({
|
||||||
frm: frm,
|
frm: frm,
|
||||||
@@ -66,6 +71,10 @@ frappe.ui.form.on("Sales Order", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get_items_from_internal_purchase_order(frm) {
|
get_items_from_internal_purchase_order(frm) {
|
||||||
|
if (!frappe.model.can_read("Purchase Order")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frm.add_custom_button(__('Purchase Order'), () => {
|
frm.add_custom_button(__('Purchase Order'), () => {
|
||||||
erpnext.utils.map_current_doc({
|
erpnext.utils.map_current_doc({
|
||||||
method: 'erpnext.buying.doctype.purchase_order.purchase_order.make_inter_company_sales_order',
|
method: 'erpnext.buying.doctype.purchase_order.purchase_order.make_inter_company_sales_order',
|
||||||
@@ -227,7 +236,11 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flt(doc.per_picked, 6) < 100 && flt(doc.per_delivered, 6) < 100) {
|
if (
|
||||||
|
flt(doc.per_picked, 6) < 100
|
||||||
|
&& flt(doc.per_delivered, 6) < 100
|
||||||
|
&& frappe.model.can_create("Pick List")
|
||||||
|
) {
|
||||||
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
|
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,45 +250,105 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
const order_is_a_custom_sale = ["Sales", "Shopping Cart", "Maintenance"].indexOf(doc.order_type) === -1;
|
const order_is_a_custom_sale = ["Sales", "Shopping Cart", "Maintenance"].indexOf(doc.order_type) === -1;
|
||||||
|
|
||||||
// delivery note
|
// delivery note
|
||||||
if(flt(doc.per_delivered, 6) < 100 && (order_is_a_sale || order_is_a_custom_sale) && allow_delivery) {
|
if(
|
||||||
this.frm.add_custom_button(__('Delivery Note'), () => this.make_delivery_note_based_on_delivery_date(), __('Create'));
|
flt(doc.per_delivered, 6) < 100
|
||||||
this.frm.add_custom_button(__('Work Order'), () => this.make_work_order(), __('Create'));
|
&& (order_is_a_sale || order_is_a_custom_sale)
|
||||||
|
&& allow_delivery
|
||||||
|
) {
|
||||||
|
if (frappe.model.can_create("Delivery Note")) {
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__("Delivery Note"),
|
||||||
|
() => this.make_delivery_note_based_on_delivery_date(),
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (frappe.model.can_create("Work Order")) {
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__("Work Order"),
|
||||||
|
() => this.make_work_order(),
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sales invoice
|
// sales invoice
|
||||||
if(flt(doc.per_billed, 6) < 100) {
|
if(flt(doc.per_billed, 6) < 100 && frappe.model.can_create("Sales Invoice")) {
|
||||||
this.frm.add_custom_button(__('Sales Invoice'), () => me.make_sales_invoice(), __('Create'));
|
this.frm.add_custom_button(
|
||||||
|
__("Sales Invoice"),
|
||||||
|
() => me.make_sales_invoice(),
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// material request
|
// material request
|
||||||
if(!doc.order_type || (order_is_a_sale || order_is_a_custom_sale) && flt(doc.per_delivered, 6) < 100) {
|
if (
|
||||||
this.frm.add_custom_button(__('Material Request'), () => this.make_material_request(), __('Create'));
|
(
|
||||||
this.frm.add_custom_button(__('Request for Raw Materials'), () => this.make_raw_material_request(), __('Create'));
|
!doc.order_type
|
||||||
|
|| (order_is_a_sale || order_is_a_custom_sale)
|
||||||
|
&& flt(doc.per_delivered, 6) < 100
|
||||||
|
)
|
||||||
|
&& frappe.model.can_create("Material Request")
|
||||||
|
) {
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__('Material Request'),
|
||||||
|
() => this.make_material_request(),
|
||||||
|
__('Create')
|
||||||
|
);
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__('Request for Raw Materials'),
|
||||||
|
() => this.make_raw_material_request(),
|
||||||
|
__('Create')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make Purchase Order
|
// Make Purchase Order
|
||||||
if (!this.frm.doc.is_internal_customer) {
|
if (!this.frm.doc.is_internal_customer && frappe.model.can_create("Purchase Order")) {
|
||||||
this.frm.add_custom_button(__('Purchase Order'), () => this.make_purchase_order(), __('Create'));
|
this.frm.add_custom_button(
|
||||||
|
__('Purchase Order'),
|
||||||
|
() => this.make_purchase_order(),
|
||||||
|
__('Create')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// maintenance
|
// maintenance
|
||||||
if(flt(doc.per_delivered, 2) < 100 && (order_is_maintenance || order_is_a_custom_sale)) {
|
if(flt(doc.per_delivered, 2) < 100 && (order_is_maintenance || order_is_a_custom_sale)) {
|
||||||
this.frm.add_custom_button(__('Maintenance Visit'), () => this.make_maintenance_visit(), __('Create'));
|
if(frappe.model.can_create("Maintenance Visit")) {
|
||||||
this.frm.add_custom_button(__('Maintenance Schedule'), () => this.make_maintenance_schedule(), __('Create'));
|
this.frm.add_custom_button(
|
||||||
|
__('Maintenance Visit'),
|
||||||
|
() => this.make_maintenance_visit(),
|
||||||
|
__('Create')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(frappe.model.can_create("Maintenance Schedule")) {
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__('Maintenance Schedule'),
|
||||||
|
() => this.make_maintenance_schedule(),
|
||||||
|
__('Create')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// project
|
// project
|
||||||
if(flt(doc.per_delivered, 2) < 100) {
|
if(flt(doc.per_delivered, 2) < 100 && frappe.model.can_create("Project")) {
|
||||||
this.frm.add_custom_button(__('Project'), () => this.make_project(), __('Create'));
|
this.frm.add_custom_button(__('Project'), () => this.make_project(), __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doc.auto_repeat) {
|
if(!doc.auto_repeat && frappe.model.can_create("Auto Repeat")) {
|
||||||
this.frm.add_custom_button(__('Subscription'), function() {
|
this.frm.add_custom_button(
|
||||||
erpnext.utils.make_subscription(doc.doctype, doc.name)
|
__('Subscription'),
|
||||||
}, __('Create'))
|
function() {
|
||||||
|
erpnext.utils.make_subscription(doc.doctype, doc.name)
|
||||||
|
},
|
||||||
|
__('Create')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc.docstatus === 1 && !doc.inter_company_order_reference) {
|
if (
|
||||||
|
doc.docstatus === 1 &&
|
||||||
|
!doc.inter_company_order_reference &&
|
||||||
|
frappe.model.can_create("Purchase Order")
|
||||||
|
) {
|
||||||
let me = this;
|
let me = this;
|
||||||
let internal = me.frm.doc.is_internal_customer;
|
let internal = me.frm.doc.is_internal_customer;
|
||||||
if (internal) {
|
if (internal) {
|
||||||
@@ -290,14 +363,25 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
}
|
}
|
||||||
// payment request
|
// payment request
|
||||||
if(flt(doc.per_billed, precision('per_billed', doc)) < 100 + frappe.boot.sysdefaults.over_billing_allowance) {
|
if(flt(doc.per_billed, precision('per_billed', doc)) < 100 + frappe.boot.sysdefaults.over_billing_allowance) {
|
||||||
this.frm.add_custom_button(__('Payment Request'), () => this.make_payment_request(), __('Create'));
|
this.frm.add_custom_button(
|
||||||
this.frm.add_custom_button(__('Payment'), () => this.make_payment_entry(), __('Create'));
|
__("Payment Request"),
|
||||||
|
() => this.make_payment_request(),
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (frappe.model.can_create("Payment Entry")) {
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__("Payment"),
|
||||||
|
() => this.make_payment_entry(),
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.frm.page.set_inner_btn_group_as_primary(__('Create'));
|
this.frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.frm.doc.docstatus===0) {
|
if (this.frm.doc.docstatus===0 && frappe.model.can_read("Quotation")) {
|
||||||
this.frm.add_custom_button(__('Quotation'),
|
this.frm.add_custom_button(__('Quotation'),
|
||||||
function() {
|
function() {
|
||||||
let d = erpnext.utils.map_current_doc({
|
let d = erpnext.utils.map_current_doc({
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ frappe.ui.form.on("Delivery Note", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100 && frappe.model.can_create("Sales Invoice")) {
|
||||||
frm.add_custom_button(__('Credit Note'), function() {
|
frm.add_custom_button(__('Credit Note'), function() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||||
@@ -96,7 +96,11 @@ frappe.ui.form.on("Delivery Note", {
|
|||||||
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.docstatus == 1 && !frm.doc.inter_company_reference) {
|
if (
|
||||||
|
frm.doc.docstatus == 1 &&
|
||||||
|
!frm.doc.inter_company_reference &&
|
||||||
|
frappe.model.can_create("Purchase Receipt")
|
||||||
|
) {
|
||||||
let internal = frm.doc.is_internal_customer;
|
let internal = frm.doc.is_internal_customer;
|
||||||
if (internal) {
|
if (internal) {
|
||||||
let button_label = (frm.doc.company === frm.doc.represents_company) ? "Internal Purchase Receipt" :
|
let button_label = (frm.doc.company === frm.doc.represents_company) ? "Internal Purchase Receipt" :
|
||||||
@@ -135,64 +139,88 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn
|
|||||||
refresh(doc, dt, dn) {
|
refresh(doc, dt, dn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
super.refresh();
|
super.refresh();
|
||||||
if ((!doc.is_return) && (doc.status!="Closed" || this.frm.is_new())) {
|
if (
|
||||||
if (this.frm.doc.docstatus===0) {
|
!doc.is_return
|
||||||
this.frm.add_custom_button(__('Sales Order'),
|
&& (doc.status!="Closed" || this.frm.is_new())
|
||||||
function() {
|
&& this.frm.has_perm("write")
|
||||||
if (!me.frm.doc.customer) {
|
&& frappe.model.can_read("Sales Order")
|
||||||
frappe.throw({
|
&& this.frm.doc.docstatus===0
|
||||||
title: __("Mandatory"),
|
) {
|
||||||
message: __("Please Select a Customer")
|
this.frm.add_custom_button(
|
||||||
});
|
__('Sales Order'),
|
||||||
|
function() {
|
||||||
|
if (!me.frm.doc.customer) {
|
||||||
|
frappe.throw({
|
||||||
|
title: __("Mandatory"),
|
||||||
|
message: __("Please Select a Customer")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
erpnext.utils.map_current_doc({
|
||||||
|
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||||
|
source_doctype: "Sales Order",
|
||||||
|
target: me.frm,
|
||||||
|
setters: {
|
||||||
|
customer: me.frm.doc.customer,
|
||||||
|
},
|
||||||
|
get_query_filters: {
|
||||||
|
docstatus: 1,
|
||||||
|
status: ["not in", ["Closed", "On Hold"]],
|
||||||
|
per_delivered: ["<", 99.99],
|
||||||
|
company: me.frm.doc.company,
|
||||||
|
project: me.frm.doc.project || undefined,
|
||||||
}
|
}
|
||||||
erpnext.utils.map_current_doc({
|
})
|
||||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
|
},
|
||||||
source_doctype: "Sales Order",
|
__("Get Items From")
|
||||||
target: me.frm,
|
);
|
||||||
setters: {
|
|
||||||
customer: me.frm.doc.customer,
|
|
||||||
},
|
|
||||||
get_query_filters: {
|
|
||||||
docstatus: 1,
|
|
||||||
status: ["not in", ["Closed", "On Hold"]],
|
|
||||||
per_delivered: ["<", 99.99],
|
|
||||||
company: me.frm.doc.company,
|
|
||||||
project: me.frm.doc.project || undefined,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, __("Get Items From"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doc.is_return && doc.status!="Closed") {
|
if (!doc.is_return && doc.status!="Closed") {
|
||||||
if(doc.docstatus == 1) {
|
if (doc.docstatus == 1 && frappe.model.can_create("Shipment")) {
|
||||||
this.frm.add_custom_button(__('Shipment'), function() {
|
this.frm.add_custom_button(__('Shipment'), function() {
|
||||||
me.make_shipment() }, __('Create'));
|
me.make_shipment() }, __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1)
|
if (
|
||||||
this.frm.add_custom_button(__('Installation Note'), function() {
|
flt(doc.per_installed, 2) < 100
|
||||||
me.make_installation_note() }, __('Create'));
|
&& doc.docstatus==1
|
||||||
|
&& frappe.model.can_create("Installation Note")
|
||||||
|
) {
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__('Installation Note'),
|
||||||
|
function() {
|
||||||
|
me.make_installation_note()
|
||||||
|
},
|
||||||
|
__('Create')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (doc.docstatus==1) {
|
if (doc.docstatus==1 && this.frm.has_perm("create")) {
|
||||||
this.frm.add_custom_button(__('Sales Return'), function() {
|
this.frm.add_custom_button(__('Sales Return'), function() {
|
||||||
me.make_sales_return() }, __('Create'));
|
me.make_sales_return() }, __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc.docstatus==1) {
|
if (doc.docstatus==1 && frappe.model.can_create("Delivery Trip")) {
|
||||||
this.frm.add_custom_button(__('Delivery Trip'), function() {
|
this.frm.add_custom_button(__('Delivery Trip'), function() {
|
||||||
me.make_delivery_trip() }, __('Create'));
|
me.make_delivery_trip() }, __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus==0 && !doc.__islocal) {
|
if (
|
||||||
if (doc.__onload && doc.__onload.has_unpacked_items) {
|
doc.docstatus==0
|
||||||
this.frm.add_custom_button(__('Packing Slip'), function() {
|
&& !doc.__islocal
|
||||||
|
&& frappe.model.can_create("Packing Slip")
|
||||||
|
&& (doc.__onload && doc.__onload.has_unpacked_items)
|
||||||
|
) {
|
||||||
|
this.frm.add_custom_button(
|
||||||
|
__('Packing Slip'),
|
||||||
|
function() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip",
|
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip",
|
||||||
frm: me.frm
|
frm: me.frm
|
||||||
}) }, __('Create')
|
});
|
||||||
);
|
},
|
||||||
}
|
__('Create')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doc.__islocal && doc.docstatus==1) {
|
if (!doc.__islocal && doc.docstatus==1) {
|
||||||
@@ -211,7 +239,13 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus==1 && !doc.is_return && doc.status!="Closed" && flt(doc.per_billed) < 100) {
|
if(
|
||||||
|
doc.docstatus==1
|
||||||
|
&& !doc.is_return
|
||||||
|
&& doc.status!="Closed"
|
||||||
|
&& flt(doc.per_billed) < 100
|
||||||
|
&& frappe.model.can_create("Sales Invoice")
|
||||||
|
) {
|
||||||
// show Make Invoice button only if Delivery Note is not created from Sales Invoice
|
// show Make Invoice button only if Delivery Note is not created from Sales Invoice
|
||||||
var from_sales_invoice = false;
|
var from_sales_invoice = false;
|
||||||
from_sales_invoice = me.frm.doc.items.some(function(item) {
|
from_sales_invoice = me.frm.doc.items.some(function(item) {
|
||||||
@@ -230,7 +264,12 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn
|
|||||||
}
|
}
|
||||||
erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
|
erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
|
||||||
|
|
||||||
if(doc.docstatus==1 && !doc.is_return && !doc.auto_repeat) {
|
if(
|
||||||
|
doc.docstatus==1
|
||||||
|
&& !doc.is_return
|
||||||
|
&& !doc.auto_repeat
|
||||||
|
&& frappe.model.can_create("Auto Repeat")
|
||||||
|
) {
|
||||||
cur_frm.add_custom_button(__('Subscription'), function() {
|
cur_frm.add_custom_button(__('Subscription'), function() {
|
||||||
erpnext.utils.make_subscription(doc.doctype, doc.name)
|
erpnext.utils.make_subscription(doc.doctype, doc.name)
|
||||||
}, __('Create'))
|
}, __('Create'))
|
||||||
|
|||||||
@@ -1529,6 +1529,7 @@ def get_next_stock_reco(kwargs):
|
|||||||
sle.batch_no,
|
sle.batch_no,
|
||||||
sle.actual_qty,
|
sle.actual_qty,
|
||||||
)
|
)
|
||||||
|
.force_index("item_warehouse")
|
||||||
.where(
|
.where(
|
||||||
(sle.item_code == kwargs.get("item_code"))
|
(sle.item_code == kwargs.get("item_code"))
|
||||||
& (sle.warehouse == kwargs.get("warehouse"))
|
& (sle.warehouse == kwargs.get("warehouse"))
|
||||||
|
|||||||
Reference in New Issue
Block a user