Commit 9c9e4ec3 by 夏超

[fix] 修改问题

parent 4e0f7224
...@@ -16,4 +16,4 @@ class JzjxInheritRepairOrderLine(models.Model): ...@@ -16,4 +16,4 @@ class JzjxInheritRepairOrderLine(models.Model):
repair_work_order_id = fields.Many2one("roke.work.order", string="返修工单") repair_work_order_id = fields.Many2one("roke.work.order", string="返修工单")
is_refix_auto_work_order = fields.Boolean(string="是否自动生产返修单") is_refix_auto_work_order = fields.Boolean(string="是否自动生产返修单")
reason_id = fields.Many2one("roke.scrap.reason", string="报废原因", ondelete='restrict') scrap_id = fields.Many2one("roke.scrap.reason", string="报废原因", ondelete='restrict')
...@@ -3,6 +3,8 @@ import http.client ...@@ -3,6 +3,8 @@ import http.client
import mimetypes import mimetypes
import math import math
from codecs import encode from codecs import encode
from datetime import timedelta
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
...@@ -51,6 +53,44 @@ class InheritProductionTask(models.Model): ...@@ -51,6 +53,44 @@ class InheritProductionTask(models.Model):
def _onchange_routing_id(self): def _onchange_routing_id(self):
return super(InheritProductionTask, self)._onchange_routing_id() return super(InheritProductionTask, self)._onchange_routing_id()
def change_routing_id_work_order(self):
routing = self.routing_id
product = self.product_id
plan_qty = self.plan_qty
task_type = self.type
routing_lines = self.get_create_wo_routing_lines(routing)
work_orders = [(5, 0, 0)]
date_num = (self.plan_date - self.plan_start_date).days
work_order_num = len(routing_lines)
if date_num == 0:
for routing_line in routing_lines:
date = self.plan_start_date
work_order_data = self._get_new_work_order_data(routing_line, product, plan_qty, task_type)
work_order_data['planned_start_time'] = date
work_order_data['plan_date'] = date
work_orders.append(
(0, 0, work_order_data))
else:
num = work_order_num // date_num
if num < 1:
num = 1
day = 0
circulation_num = 1
for routing_line in routing_lines:
date = self.plan_start_date + timedelta(days=day)
if circulation_num == num:
circulation_num = 1
if day + 1 <= date_num:
day += 1
else:
circulation_num += 1
work_order_data = self._get_new_work_order_data(routing_line, product, plan_qty, task_type)
work_order_data['planned_start_time'] = date
work_order_data['plan_date'] = date
work_orders.append(
(0, 0, work_order_data))
return work_orders
def _create_work_order_get_values(self, task, routing_line): def _create_work_order_get_values(self, task, routing_line):
""" """
任务生成工单获取工单数据 任务生成工单获取工单数据
...@@ -106,6 +146,9 @@ class InheritProductionTask(models.Model): ...@@ -106,6 +146,9 @@ class InheritProductionTask(models.Model):
self.write({ self.write({
"routing_id": routing_id.id, "routing_id": routing_id.id,
}) })
self.write({
"work_order_ids": self.change_routing_id_work_order()
})
elif not self.routing_id.routing_task_id or self.routing_id.routing_task_id.id != self.id: elif not self.routing_id.routing_task_id or self.routing_id.routing_task_id.id != self.id:
routing_id = self.routing_id.copy() routing_id = self.routing_id.copy()
routing_id.update({ routing_id.update({
...@@ -113,7 +156,9 @@ class InheritProductionTask(models.Model): ...@@ -113,7 +156,9 @@ class InheritProductionTask(models.Model):
"routing_task_id": self.id "routing_task_id": self.id
}) })
self.write({"routing_id": routing_id.id}) self.write({"routing_id": routing_id.id})
self._onchange_routing_id() self.write({
"work_order_ids": self.change_routing_id_work_order()
})
else: else:
routing_id = self.routing_id routing_id = self.routing_id
return { return {
......
...@@ -58,3 +58,16 @@ class InheritRokeRoutingModel(models.Model): ...@@ -58,3 +58,16 @@ class InheritRokeRoutingModel(models.Model):
"sequence": standard_item.sequence, "sequence": standard_item.sequence,
}) })
return res return res
class InheritRokeRoutingLineModel(models.Model):
_inherit = "roke.routing.line"
def write(self, vals):
res = super(InheritRokeRoutingLineModel, self).write(vals)
for v in self:
if v.routing_id.routing_task_id:
v.routing_id.routing_task_id.write({
"work_order_ids": v.routing_id.routing_task_id.change_routing_id_work_order()
})
return res
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']/tree//field[@name='wr_id']" position="after"> <xpath expr="//field[@name='line_ids']/tree//field[@name='wr_id']" position="after">
<field name="repair_work_order_id" options="{'no_create': True}"/> <field name="repair_work_order_id" options="{'no_create': True}"/>
<field name="scrap_id" options="{'no_create': True}"/>
</xpath> </xpath>
<xpath expr="//field[@name='line_ids']/tree//button[@name='execute_repair']" position="replace"> <xpath expr="//field[@name='line_ids']/tree//button[@name='execute_repair']" position="replace">
<field name="is_refix_auto_work_order" invisible="1"/> <field name="is_refix_auto_work_order" invisible="1"/>
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after"> <xpath expr="//field[@name='product_id']" position="after">
<field name="repair_work_order_id" options="{'no_create': True}"/> <field name="repair_work_order_id" options="{'no_create': True}"/>
<field name="scrap_id" options="{'no_create': True}"/>
</xpath> </xpath>
<xpath expr="//button[@name='execute_repair']" position="replace"> <xpath expr="//button[@name='execute_repair']" position="replace">
<field name="is_refix_auto_work_order" invisible="1"/> <field name="is_refix_auto_work_order" invisible="1"/>
...@@ -44,6 +46,7 @@ ...@@ -44,6 +46,7 @@
<field name="inherit_id" ref="roke_mes_quality.view_roke_repair_order_line_tree"/> <field name="inherit_id" ref="roke_mes_quality.view_roke_repair_order_line_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//button[@name='execute_repair']" position="replace"> <xpath expr="//button[@name='execute_repair']" position="replace">
<field name="scrap_id"/>
<field name="is_refix_auto_work_order" invisible="1"/> <field name="is_refix_auto_work_order" invisible="1"/>
<button name="execute_repair" type="object" string="执行返修" class="oe_highlight" <button name="execute_repair" type="object" string="执行返修" class="oe_highlight"
attrs="{'invisible': ['|', ('allow_qty', '&lt;=', 0), ('is_refix_auto_work_order', '=', True)]}"/> attrs="{'invisible': ['|', ('allow_qty', '&lt;=', 0), ('is_refix_auto_work_order', '=', True)]}"/>
......
...@@ -49,7 +49,10 @@ class InheritRokeCreateWorkRecordWizard(models.TransientModel): ...@@ -49,7 +49,10 @@ class InheritRokeCreateWorkRecordWizard(models.TransientModel):
"repair_line_id": v.id, "repair_line_id": v.id,
"type": "返修" "type": "返修"
}) })
scrap_id = self.scrap_detail_ids.reason_id.ids[0] if self.scrap_detail_ids and \
self.scrap_detail_ids.reason_id else False
data = { data = {
"scrap_id": scrap_id,
"repair_work_order_id": repair_work_order_id, "repair_work_order_id": repair_work_order_id,
"is_refix_auto_work_order": refix_params == "True" or refix_params is True "is_refix_auto_work_order": refix_params == "True" or refix_params is True
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment