1、完成<工单>通用调整配置优化;2、完成<工单>后置三元检测和质检单逻辑判断及结果同步优化;3、工单新增【送检】功能按钮;
This commit is contained in:
@@ -16,3 +16,4 @@ from . import sf_production_common
|
|||||||
from . import sale_order
|
from . import sale_order
|
||||||
from . import quick_easy_order
|
from . import quick_easy_order
|
||||||
from . import purchase_order
|
from . import purchase_order
|
||||||
|
from . import quality_check
|
||||||
@@ -26,7 +26,7 @@ class ResMrpRoutingWorkcenter(models.Model):
|
|||||||
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||||
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
||||||
is_outsource = fields.Boolean('外协', default=False)
|
is_outsource = fields.Boolean('外协', default=False)
|
||||||
individuation_page = fields.Many2many('sf.work.individuation.page', string='个性化记录')
|
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录')
|
||||||
|
|
||||||
def get_no(self):
|
def get_no(self):
|
||||||
international_standards = self.search(
|
international_standards = self.search(
|
||||||
|
|||||||
@@ -1344,6 +1344,21 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
record.production_id.button_mark_done1()
|
record.production_id.button_mark_done1()
|
||||||
# record.production_id.state = 'done'
|
# record.production_id.state = 'done'
|
||||||
|
|
||||||
|
# ============工单完成,修改对应[质检单]的值=====================
|
||||||
|
if record.check_ids:
|
||||||
|
if record.test_results == '合格':
|
||||||
|
record.check_ids.write({'test_results': None})
|
||||||
|
for check_id in record.check_ids:
|
||||||
|
check_id.do_pass()
|
||||||
|
elif record.test_results in ('返工', '报废'):
|
||||||
|
record.check_ids.write({
|
||||||
|
'test_results': record.test_results,
|
||||||
|
'reason': record.reason,
|
||||||
|
'detailed_reason': record.detailed_reason})
|
||||||
|
for check_id in record.check_ids:
|
||||||
|
check_id.do_fail()
|
||||||
|
# ======================================================
|
||||||
|
|
||||||
# 解绑托盘
|
# 解绑托盘
|
||||||
def unbind_tray(self):
|
def unbind_tray(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
@@ -1466,6 +1481,53 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件')
|
move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件')
|
||||||
|
|
||||||
|
# ==============================配置化页签--个性化记录===================================
|
||||||
|
routing_workcenter_id = fields.Many2one('mrp.routing.workcenter', compute='_compute_routing_workcenter_id',
|
||||||
|
store=True)
|
||||||
|
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录', store=True,
|
||||||
|
compute='_compute_individuation_page_ids')
|
||||||
|
individuation_page_PTD = fields.Boolean('个性化记录(后置三元检测PTD)', default=False)
|
||||||
|
|
||||||
|
@api.depends('name')
|
||||||
|
def _compute_routing_workcenter_id(self):
|
||||||
|
for mw in self:
|
||||||
|
routing_workcenter_id = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
[('name', '=', mw.name), ('routing_type', '=', mw.routing_type)])
|
||||||
|
if routing_workcenter_id:
|
||||||
|
mw.routing_workcenter_id = routing_workcenter_id.id
|
||||||
|
|
||||||
|
@api.depends('routing_workcenter_id.individuation_page_ids')
|
||||||
|
def _compute_individuation_page_ids(self):
|
||||||
|
for mw in self:
|
||||||
|
if mw.routing_workcenter_id:
|
||||||
|
mw.individuation_page_ids = mw.routing_workcenter_id.individuation_page_ids.ids
|
||||||
|
# 初始化页签配置
|
||||||
|
mw.individuation_page_PTD = False
|
||||||
|
# 根据工单对应的【作业_个性化记录】配置页签
|
||||||
|
if any(item.code == 'PTD' for item in mw.routing_workcenter_id.individuation_page_ids):
|
||||||
|
mw.individuation_page_PTD = True
|
||||||
|
# =============================================================================================
|
||||||
|
|
||||||
|
is_inspect = fields.Boolean('需送检', compute='_compute_is_inspect', store=True, default=False)
|
||||||
|
|
||||||
|
@api.depends('check_ids.is_inspect')
|
||||||
|
def _compute_is_inspect(self):
|
||||||
|
for item in self:
|
||||||
|
if item.check_ids:
|
||||||
|
is_inspect = False
|
||||||
|
for check_id in item.check_ids:
|
||||||
|
if check_id.is_inspect:
|
||||||
|
is_inspect = True
|
||||||
|
break
|
||||||
|
item.is_inspect = is_inspect
|
||||||
|
|
||||||
|
def do_inspect(self):
|
||||||
|
"""送检"""
|
||||||
|
# 修改工单状态
|
||||||
|
self.write({'state': 'to be detected'})
|
||||||
|
# 若关联的【质量检查_需送检】=true,则质量检查单的状态从“等待”更新为“待处理”
|
||||||
|
self.check_ids.filtered(lambda ch: ch.is_inspect is True).write({'quality_state': 'none'})
|
||||||
|
|
||||||
|
|
||||||
class CNCprocessing(models.Model):
|
class CNCprocessing(models.Model):
|
||||||
_name = 'sf.cnc.processing'
|
_name = 'sf.cnc.processing'
|
||||||
|
|||||||
7
sf_manufacturing/models/quality_check.py
Normal file
7
sf_manufacturing/models/quality_check.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from odoo import fields, models, api
|
||||||
|
|
||||||
|
|
||||||
|
class QualityCheck(models.Model):
|
||||||
|
_inherit = "quality.check"
|
||||||
|
|
||||||
|
is_inspect = fields.Boolean('需送检')
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<field name="routing_type" required="1"/>
|
<field name="routing_type" required="1"/>
|
||||||
<field name="routing_tag" required="1" string="工序标签"/>
|
<field name="routing_tag" required="1" string="工序标签"/>
|
||||||
<field name="is_outsource"/>
|
<field name="is_outsource"/>
|
||||||
<field name="individuation_page" widget="many2many_tags" options="{'create': False}"/>
|
<field name="individuation_page_ids" widget="many2many_tags" options="{'create': False}"/>
|
||||||
<field name="is_repeat"/>
|
<field name="is_repeat"/>
|
||||||
<field name="reserved_duration"/>
|
<field name="reserved_duration"/>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -158,6 +158,7 @@
|
|||||||
<field name='is_rework' invisible="1"/>
|
<field name='is_rework' invisible="1"/>
|
||||||
<field name='is_delivery' invisible="1"/>
|
<field name='is_delivery' invisible="1"/>
|
||||||
<field name="is_trayed" invisible="1"/>
|
<field name="is_trayed" invisible="1"/>
|
||||||
|
<field name="is_inspect" invisible="1"/>
|
||||||
<!-- <field name='is_send_program_again' invisible="1"/>-->
|
<!-- <field name='is_send_program_again' invisible="1"/>-->
|
||||||
<!-- 工单form页面的开始停工按钮等 -->
|
<!-- 工单form页面的开始停工按钮等 -->
|
||||||
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
|
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
|
||||||
@@ -185,6 +186,8 @@
|
|||||||
<button name="button_unblock" type="object" string="取消阻塞"
|
<button name="button_unblock" type="object" string="取消阻塞"
|
||||||
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||||
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
|
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
|
||||||
|
<button name="do_inspect" type="object" string="送检" class="btn-success" confirm="是否确认送检"
|
||||||
|
attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('progress')), ('is_inspect', '=', False), ('routing_type','=','CNC加工')]}"/>
|
||||||
|
|
||||||
<!-- <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工" -->
|
<!-- <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工" -->
|
||||||
<!-- context="{'default_workcenter_id': workcenter_id}" class="btn-danger" -->
|
<!-- context="{'default_workcenter_id': workcenter_id}" class="btn-danger" -->
|
||||||
@@ -522,7 +525,8 @@
|
|||||||
|
|
||||||
<xpath expr="//page[1]" position="before">
|
<xpath expr="//page[1]" position="before">
|
||||||
<field name="results" invisible="1"/>
|
<field name="results" invisible="1"/>
|
||||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
<field name="individuation_page_PTD" invisible="1"/>
|
||||||
|
<page string="后置三元检测" attrs='{"invisible": [("individuation_page_PTD", "=", False)]}'>
|
||||||
<group>
|
<group>
|
||||||
<field name="test_results"
|
<field name="test_results"
|
||||||
attrs='{"readonly":[("state","!=","to be detected")],"invisible":[("results","!=",False)]}'/>
|
attrs='{"readonly":[("state","!=","to be detected")],"invisible":[("results","!=",False)]}'/>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class QualityCheck(models.Model):
|
|||||||
if self.test_results in ['返工', '报废']:
|
if self.test_results in ['返工', '报废']:
|
||||||
raise ValidationError('请重新选择【判定结果】-【检测结果】')
|
raise ValidationError('请重新选择【判定结果】-【检测结果】')
|
||||||
if self.workorder_id.state not in ['done']:
|
if self.workorder_id.state not in ['done']:
|
||||||
self.workorder_id.write({'test_results': self.test_results})
|
self.workorder_id.write({'test_results': '合格'})
|
||||||
# 2)将关联的工单状态更新为“已完成”
|
# 2)将关联的工单状态更新为“已完成”
|
||||||
self.workorder_id.button_finish()
|
self.workorder_id.button_finish()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user