Commit feae40d8 by 夏超

[fix] 修改需求

parent 9369d724
from . import inherit_roke_work_order from . import inherit_roke_work_order
from . import inherit_production_task from . import inherit_production_task
from . import inherit_roke_routing_line from . import inherit_roke_routing
from . import inherit_roke_product from . import inherit_roke_product
...@@ -11,16 +11,51 @@ from odoo.exceptions import ValidationError ...@@ -11,16 +11,51 @@ from odoo.exceptions import ValidationError
class InheritProductionTask(models.Model): class InheritProductionTask(models.Model):
_inherit = "roke.production.task" _inherit = "roke.production.task"
_order = "main_task_code desc, id"
file_ids = fields.Many2many("ir.attachment", "roke_production_task_ir_attachment", "pro_id", "att_id") file_ids = fields.Many2many("ir.attachment", "roke_production_task_ir_attachment", "pro_id", "att_id")
work_order_hours = fields.Float(string="总报工时", compute="_compute_work_order_hours") work_order_hours = fields.Float(string="总报工时", compute="_compute_work_order_hours")
task_type = fields.Selection([
('main', '主任务'),
('sub', '子任务'),
('repair', '返修任务'),
('replenish', '补件任务')
], string='任务类型', compute='_compute_task_type', store=True)
main_task_code = fields.Char(string='主任务编号', compute='_compute_main_task_code', store=True, index=True)
@api.depends('work_order_ids') @api.depends('work_order_ids')
def _compute_work_order_hours(self): def _compute_work_order_hours(self):
for record in self: for record in self:
record.work_order_hours = sum(record.work_order_ids.mapped("work_hours")) record.work_order_hours = sum(record.work_order_ids.mapped("work_hours"))
@api.depends('parent_id', 'type')
def _compute_task_type(self):
for record in self:
if record.type == '返修':
record.task_type = 'repair'
elif record.type == '补件':
record.task_type = 'replenish'
elif record.parent_id:
record.task_type = 'sub'
else:
record.task_type = 'main'
@api.depends('task_type', 'code', 'parent_id')
def _compute_main_task_code(self):
for record in self:
# 对于子任务、返修任务和补件任务,获取主任务的编号
if record.type == "返修":
record.main_task_code = record.repair_order_id.wr_id.work_order_id.task_id.code
elif record.type == '补件':
record.main_task_code = record.scrap_order_id.wr_id.work_order_id.task_id.code
elif record.parent_id:
record.main_task_code = record.parent_id.code
else:
record.main_task_code = record.code
def write(self, vals): def write(self, vals):
res = super(InheritProductionTask, self).write(vals) res = super(InheritProductionTask, self).write(vals)
if vals.get('file_ids'): if vals.get('file_ids'):
......
...@@ -8,6 +8,22 @@ class InheritRokeRoutingLine(models.Model): ...@@ -8,6 +8,22 @@ class InheritRokeRoutingLine(models.Model):
special_process = fields.Selection([('是', '是'), ('否', '否')], string="特殊工序", default='否') special_process = fields.Selection([('是', '是'), ('否', '否')], string="特殊工序", default='否')
class InheritRokeRouting(models.Model):
_inherit = "roke.routing"
def get_routing_line_value(self, line):
"""
获取工艺明细内容
:param process:
:return:
"""
res = super(InheritRokeRouting, self).get_routing_line_value(line)
res.update({
"special_process": line.special_process
})
return res
class InheritRokeProcess(models.Model): class InheritRokeProcess(models.Model):
_inherit = "roke.process" _inherit = "roke.process"
......
...@@ -17,4 +17,16 @@ ...@@ -17,4 +17,16 @@
</xpath> </xpath>
</field> </field>
</record> </record>
<record id="inherit_view_roke_production_task_tree" model="ir.ui.view">
<field name="name">inherit.roke.production.tree.view</field>
<field name="model">roke.production.task</field>
<field name="inherit_id" ref="roke_mes_production.view_roke_production_task_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='routing_id']" position="after">
<field name="task_type"/>
<field name="main_task_code" invisible="1"/>
</xpath>
</field>
</record>
</odoo> </odoo>
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