fix: incorrect produced qty in the production plan (#19569)
This commit is contained in:
parent
ba8fc21594
commit
d064505ebe
@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
frappe.ui.form.on('Production Plan', {
|
frappe.ui.form.on('Production Plan', {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
|
frm.custom_make_buttons = {
|
||||||
|
'Work Order': 'Work Order',
|
||||||
|
'Material Request': 'Material Request',
|
||||||
|
};
|
||||||
|
|
||||||
frm.fields_dict['po_items'].grid.get_field('warehouse').get_query = function(doc) {
|
frm.fields_dict['po_items'].grid.get_field('warehouse').get_query = function(doc) {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
|
@ -223,7 +223,15 @@ class WorkOrder(Document):
|
|||||||
|
|
||||||
def update_production_plan_status(self):
|
def update_production_plan_status(self):
|
||||||
production_plan = frappe.get_doc('Production Plan', self.production_plan)
|
production_plan = frappe.get_doc('Production Plan', self.production_plan)
|
||||||
production_plan.run_method("update_produced_qty", self.produced_qty, self.production_plan_item)
|
produced_qty = 0
|
||||||
|
if self.production_plan_item:
|
||||||
|
total_qty = frappe.get_all("Work Order", fields = "sum(produced_qty) as produced_qty",
|
||||||
|
filters = {'docstatus': 1, 'production_plan': self.production_plan,
|
||||||
|
'production_plan_item': self.production_plan_item}, as_list=1)
|
||||||
|
|
||||||
|
produced_qty = total_qty[0][0] if total_qty else 0
|
||||||
|
|
||||||
|
production_plan.run_method("update_produced_qty", produced_qty, self.production_plan_item)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if not self.wip_warehouse:
|
if not self.wip_warehouse:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user