优化cnc工单

This commit is contained in:
jinling.yang
2024-07-04 15:38:43 +08:00
parent a7a8e73616
commit 050e82673a
5 changed files with 73 additions and 14 deletions

View File

@@ -716,3 +716,17 @@ class sf_detection_result(models.Model):
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
string="检测结果", tracking=True)
test_report = fields.Binary('检测报告', readonly=True)
# 查看检测报告
def button_look_test_report(self):
return {
'res_model': 'sf.detection.result',
'type': 'ir.actions.act_window',
'res_id': self.id,
'views': [(self.env.ref('sf_manufacturing.sf_test_report_form').id, 'form')],
# 'view_mode': 'form',
# 'context': {
# 'default_id': self.id
# },
'target': 'new'
}

View File

@@ -47,6 +47,7 @@ class ResMrpWorkOrder(models.Model):
('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型")
results = fields.Char('结果')
state = fields.Selection(selection_add=[('to be detected', "待检测")])
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@@ -196,13 +197,14 @@ class ResMrpWorkOrder(models.Model):
production_line_state = fields.Selection(
[('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线', tracking=True)
detection_report = fields.Binary('检测报告', readonly=True)
detection_report = fields.Binary('检测报告', readonly=False)
is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False)
is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False)
reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("operate computer", "操机"),
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
detailed_reason = fields.Text('详细原因')
is_rework = fields.Boolean(string='是否返工', default=False)
# is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False)
@@ -473,8 +475,6 @@ class ResMrpWorkOrder(models.Model):
'default_production_ids': [(6, 0, [self.production_id.id])],
}}
# 拼接工单对象属性值
def json_workorder_str(self, k, production, route, item):
# 计算预计时长duration_expected
@@ -956,6 +956,15 @@ class ResMrpWorkOrder(models.Model):
record.process_state = '待解除装夹'
# record.write({'process_state': '待加工'})
record.production_id.process_state = '待解除装夹'
if record.test_results in ['返工']:
record.production_id.state = 'rework'
record.production_id.write({'detection_result_ids': [(0, 0, {
'rework_reason': record.reason,
'detailed_reason': record.detailed_reason,
'processing_panel': record.processing_panel,
'routing_type': record.routing_type,
'test_results': record.test_results,
'test_report': record.detection_report})]})
if record.routing_type == '解除装夹':
'''
记录结束时间

View File

@@ -269,7 +269,20 @@
<xpath expr="//sheet//notebook//page[@name='operations']" position="after">
<page string="检测报告" attrs="{'invisible': [('detection_result_ids', '=', [])]}">
<field name="detection_result_ids" string=""/>
<field name="detection_result_ids" string="" readonly="1">
<tree sample="1">
<field name="production_id" invisible="1"/>
<field name="processing_panel"/>
<field name="routing_type"/>
<field name="rework_reason"/>
<field name="detailed_reason"/>
<field name="test_results"/>
<field name="test_report" invisible="1"/>
<button name="button_look_test_report" string="查看测试报告" type="object"
attrs="{'invisible': [('test_report', '=', False)]}"
class="btn btn-primary me-1"/>
</tree>
</field>
</page>
</xpath>
<xpath expr="//sheet//notebook//page[@name='components']" position="attributes">
@@ -501,5 +514,24 @@
</field>
</record>
<record model="ir.ui.view" id="sf_test_report_form">
<field name="name">sf.detection.result</field>
<field name="model">sf.detection.result</field>
<field name="arch" type="xml">
<form>
<group>
<field name="test_report" readonly="1" widget="pdf_viewer"/>
</group>
</form>
</field>
</record>
<record id="action_test_report_form" model="ir.actions.act_window">
<field name="name">检测报告</field>
<field name="res_model">sf.detection.result</field>
<field name="view_mode">form</field>
</record>
</data>
</odoo>

View File

@@ -123,6 +123,7 @@
<xpath expr="//field[@name='state']" position="before">
<field name='user_permissions' invisible="1"/>
<field name='name' invisible="1"/>
<field name='is_rework' invisible="1"/>
<field name='is_delivery' invisible="1"/>
<!-- <field name='is_send_program_again' invisible="1"/>-->
<!-- 工单form页面的开始停工按钮等 -->
@@ -162,7 +163,7 @@
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done')]}"/>
<button name="button_rework_pre" type="object" string="返工"
class="btn-primary"
attrs="{'invisible': [('routing_type','!=','装夹预调')]}"/>
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('state','!=','progress'),('is_rework','=',True)]}"/>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>
@@ -483,10 +484,11 @@
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>-->
<!-- <field name="is_fetchcnc"-->
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>-->
<!-- <field name="reason"-->
<!-- attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>-->
<!-- <field name="detailed_reason" attrs='{"invisible":[("test_results","=","合格")]}'/>-->
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>-->
<field name="reason"
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>
<field name="detailed_reason"
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>-->
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
widget="pdf_viewer"/>
</group>

View File

@@ -13,18 +13,20 @@ class ReworkWizard(models.TransientModel):
workorder_id = fields.Many2one('mrp.workorder', string='工单')
production_ids = fields.Many2many('mrp.production', string='制造订单号')
rework_reason = fields.Selection(
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
("operate computer", "操机"),
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
detailed_reason = fields.Text('详细原因')
routing_type = fields.Selection([
('装夹预调', '装夹预调'),
('CNC加工', 'CNC加工')], string="工序类型")
def confirm(self):
self.production_ids.detection_result_ids.write((0, 0, {
self.workorder_id.is_rework = True
self.production_ids.write({'detection_result_ids': [(0, 0, {
'rework_reason': self.rework_reason,
'detailed_reason': self.detailed_reason,
'processing_panel': self.workorder_id.processing_panel,
'routing_type': self.workorder_id.routing_type,
'test_results': self.workorder_id.test_results,
'test_report': self.workorder_id.detection_report}))
'test_report': self.workorder_id.detection_report})]})