feat: allow Update Items for Subcontracted PO not having SCO created
This commit is contained in:
parent
450949cadd
commit
faf9f13215
@ -185,8 +185,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
|||||||
|
|
||||||
if(!in_list(["Closed", "Delivered"], doc.status)) {
|
if(!in_list(["Closed", "Delivered"], doc.status)) {
|
||||||
if(this.frm.doc.status !== 'Closed' && flt(this.frm.doc.per_received, 2) < 100 && flt(this.frm.doc.per_billed, 2) < 100) {
|
if(this.frm.doc.status !== 'Closed' && flt(this.frm.doc.per_received, 2) < 100 && flt(this.frm.doc.per_billed, 2) < 100) {
|
||||||
// Don't add Update Items button if the PO is following the new subcontracting flow.
|
if (!this.frm.doc.__onload || this.frm.doc.__onload.can_update_items) {
|
||||||
if (!(this.frm.doc.is_subcontracted && !this.frm.doc.is_old_subcontracting_flow)) {
|
|
||||||
this.frm.add_custom_button(__('Update Items'), () => {
|
this.frm.add_custom_button(__('Update Items'), () => {
|
||||||
erpnext.utils.update_child_items({
|
erpnext.utils.update_child_items({
|
||||||
frm: this.frm,
|
frm: this.frm,
|
||||||
|
|||||||
@ -49,9 +49,22 @@ class PurchaseOrder(BuyingController):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def can_update_items(self) -> bool:
|
||||||
|
result = True
|
||||||
|
|
||||||
|
if self.is_subcontracted and not self.is_old_subcontracting_flow:
|
||||||
|
# Check - 1: NOT ALLOWED if non-cancelled Subcontracting Order exists for this Purchase Order
|
||||||
|
if frappe.db.exists(
|
||||||
|
"Subcontracting Order", {"purchase_order": self.name, "docstatus": ["!=", 2]}
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def onload(self):
|
def onload(self):
|
||||||
supplier_tds = frappe.db.get_value("Supplier", self.supplier, "tax_withholding_category")
|
supplier_tds = frappe.db.get_value("Supplier", self.supplier, "tax_withholding_category")
|
||||||
self.set_onload("supplier_tds", supplier_tds)
|
self.set_onload("supplier_tds", supplier_tds)
|
||||||
|
self.set_onload("can_update_items", self.can_update_items())
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(PurchaseOrder, self).validate()
|
super(PurchaseOrder, self).validate()
|
||||||
|
|||||||
@ -678,6 +678,37 @@ erpnext.utils.update_child_items = function(opts) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frm.doc.doctype == 'Purchase Order' && frm.doc.is_subcontracted && !frm.doc.is_old_subcontracting_flow) {
|
||||||
|
fields.push({
|
||||||
|
fieldtype:'Link',
|
||||||
|
fieldname:'fg_item',
|
||||||
|
options: 'Item',
|
||||||
|
reqd: 1,
|
||||||
|
in_list_view: 0,
|
||||||
|
read_only: 0,
|
||||||
|
disabled: 0,
|
||||||
|
label: __('Finished Good Item'),
|
||||||
|
get_query: () => {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'is_stock_item': 1,
|
||||||
|
'is_sub_contracted_item': 1,
|
||||||
|
'default_bom': ['!=', '']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
fieldtype:'Float',
|
||||||
|
fieldname:'fg_item_qty',
|
||||||
|
reqd: 1,
|
||||||
|
default: 0,
|
||||||
|
read_only: 0,
|
||||||
|
in_list_view: 0,
|
||||||
|
label: __('Finished Good Item Qty'),
|
||||||
|
precision: get_precision('fg_item_qty')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
let dialog = new frappe.ui.Dialog({
|
let dialog = new frappe.ui.Dialog({
|
||||||
title: __("Update Items"),
|
title: __("Update Items"),
|
||||||
size: "extra-large",
|
size: "extra-large",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user