fixes for productiojn order
This commit is contained in:
parent
b736443e3f
commit
a9b3ec180e
@ -7,6 +7,11 @@ $.extend(cur_frm.cscript, {
|
|||||||
cfn_set_fields(doc, dt, dn);
|
cfn_set_fields(doc, dt, dn);
|
||||||
|
|
||||||
this.frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date");
|
this.frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date");
|
||||||
|
|
||||||
|
return this.frm.call({
|
||||||
|
doc: this.frm.doc,
|
||||||
|
method: "set_actual_dates"
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
before_submit: function() {
|
before_submit: function() {
|
||||||
@ -60,10 +65,14 @@ $.extend(cur_frm.cscript, {
|
|||||||
bom_no: function() {
|
bom_no: function() {
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
doc: this.frm.doc,
|
doc: this.frm.doc,
|
||||||
method: "set_production_order_operations",
|
method: "set_production_order_operations"
|
||||||
callback: function(r) {
|
});
|
||||||
if(!r.exc) refresh_field("operations");
|
},
|
||||||
}
|
|
||||||
|
planned_start_date: function() {
|
||||||
|
return this.frm.call({
|
||||||
|
doc: this.frm.doc,
|
||||||
|
method: "plan_operations"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -175,16 +175,17 @@ class ProductionOrder(Document):
|
|||||||
self.calculate_operating_cost()
|
self.calculate_operating_cost()
|
||||||
|
|
||||||
def plan_operations(self):
|
def plan_operations(self):
|
||||||
scheduled_datetime = self.planned_start_date
|
if self.planned_start_date:
|
||||||
for d in self.get('operations'):
|
scheduled_datetime = self.planned_start_date
|
||||||
while getdate(scheduled_datetime) in self.get_holidays(d.workstation):
|
for d in self.get('operations'):
|
||||||
scheduled_datetime = get_datetime(scheduled_datetime) + relativedelta(days=1)
|
while getdate(scheduled_datetime) in self.get_holidays(d.workstation):
|
||||||
|
scheduled_datetime = get_datetime(scheduled_datetime) + relativedelta(days=1)
|
||||||
|
|
||||||
d.planned_start_time = scheduled_datetime
|
d.planned_start_time = scheduled_datetime
|
||||||
scheduled_datetime = get_datetime(scheduled_datetime) + relativedelta(minutes=d.time_in_mins)
|
scheduled_datetime = get_datetime(scheduled_datetime) + relativedelta(minutes=d.time_in_mins)
|
||||||
d.planned_end_time = scheduled_datetime
|
d.planned_end_time = scheduled_datetime
|
||||||
|
|
||||||
self.planned_end_date = scheduled_datetime
|
self.planned_end_date = scheduled_datetime
|
||||||
|
|
||||||
|
|
||||||
def get_holidays(self, workstation):
|
def get_holidays(self, workstation):
|
||||||
@ -208,7 +209,16 @@ class ProductionOrder(Document):
|
|||||||
d.status = "Completed"
|
d.status = "Completed"
|
||||||
else:
|
else:
|
||||||
frappe.throw(_("Completed Qty can not be greater than 'Qty to Manufacture'"))
|
frappe.throw(_("Completed Qty can not be greater than 'Qty to Manufacture'"))
|
||||||
|
|
||||||
|
def set_actual_dates(self):
|
||||||
|
if self.get("operations"):
|
||||||
|
actual_date = frappe.db.sql("""select min(actual_start_time) as start_date, max(actual_end_time) as end_date from `tabProduction Order Operation`
|
||||||
|
where parent = %s and docstatus=1""", self.name, as_dict=1)[0]
|
||||||
|
self.actual_start_date = actual_date.start_date
|
||||||
|
self.actual_end_date = actual_date.end_date
|
||||||
|
else:
|
||||||
|
self.actual_start_date = None
|
||||||
|
self.actual_end_date = None
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_details(item):
|
def get_item_details(item):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user