新增返工向导
This commit is contained in:
@@ -17,9 +17,10 @@
|
||||
'security/group_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/workpiece_delivery_views.xml',
|
||||
'wizard/rework_wizard_views.xml',
|
||||
'views/mrp_views_menus.xml',
|
||||
'views/stock_lot_views.xml',
|
||||
# 'views/mrp_production_addional_change.xml',
|
||||
'views/mrp_production_addional_change.xml',
|
||||
'views/mrp_routing_workcenter_view.xml',
|
||||
'views/production_line_view.xml',
|
||||
'views/mrp_workcenter_views.xml',
|
||||
|
||||
@@ -24,6 +24,7 @@ class MrpProduction(models.Model):
|
||||
work_order_state = fields.Selection([('未排', '未排'), ('已排', '已排'), ('已完成', '已完成')],
|
||||
string='工单状态', default='未排')
|
||||
|
||||
detection_result_ids = fields.One2many('sf.detection.result', 'production_id', '检测报告')
|
||||
# state = fields.Selection(selection_add=[
|
||||
# ('pending_scheduling', '待排程'),
|
||||
# ('pending_processing', '待加工'),
|
||||
@@ -34,9 +35,10 @@ class MrpProduction(models.Model):
|
||||
('confirmed', '待排程'),
|
||||
('pending_cam', '待加工'),
|
||||
('progress', '加工中'),
|
||||
('rework', '返工'),
|
||||
('to_close', 'To Close'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Cancelled')], string='State',
|
||||
('cancel', '报废')], string='State',
|
||||
compute='_compute_state', copy=False, index=True, readonly=True,
|
||||
store=True, tracking=True,
|
||||
help=" * Draft: The MO is not confirmed yet.\n"
|
||||
@@ -683,3 +685,34 @@ class MrpProduction(models.Model):
|
||||
'view_mode': 'tree,form',
|
||||
})
|
||||
return action
|
||||
|
||||
# 返工
|
||||
def button_rework(self):
|
||||
return True
|
||||
|
||||
# 报废
|
||||
def button_scrap_new(self):
|
||||
return True
|
||||
|
||||
# 更新程序
|
||||
def button_update_program(self):
|
||||
return True
|
||||
|
||||
|
||||
class sf_detection_result(models.Model):
|
||||
_name = 'sf.detection.result'
|
||||
_description = "检测结果"
|
||||
|
||||
production_id = fields.Many2one('mrp.production')
|
||||
processing_panel = fields.Char('加工面')
|
||||
routing_type = fields.Selection([
|
||||
('装夹预调', '装夹预调'),
|
||||
('CNC加工', 'CNC加工')], string="工序类型")
|
||||
|
||||
rework_reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果", tracking=True)
|
||||
test_report = fields.Binary('检测报告', readonly=True)
|
||||
|
||||
@@ -200,8 +200,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False)
|
||||
is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False)
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
|
||||
# is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False)
|
||||
@@ -460,6 +460,21 @@ class ResMrpWorkOrder(models.Model):
|
||||
else:
|
||||
raise UserError(_("该工单暂未完成,无法进行工件配送"))
|
||||
|
||||
def button_rework_pre(self):
|
||||
# production_ids |= self.production_id
|
||||
return {
|
||||
'name': _('返工'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.rework.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_workorder_id': self.id,
|
||||
'default_production_ids': [(6, 0, [self.production_id.id])],
|
||||
}}
|
||||
|
||||
|
||||
|
||||
# 拼接工单对象属性值
|
||||
def json_workorder_str(self, k, production, route, item):
|
||||
# 计算预计时长duration_expected
|
||||
|
||||
@@ -141,3 +141,6 @@ access_sf_model_type_group_sf_stock_manager,sf_model_type_group_sf_mrp_manager,m
|
||||
access_mrp_bom_byproduct_group_sf_stock_user,mrp_bom_byproduct_group_sf_stock_user,mrp.model_mrp_bom_byproduct,sf_base.group_sf_stock_user,1,0,0,0
|
||||
access_mrp_bom_byproduct_group_sf_stock_manager,mrp_bom_byproduct_group_sf_mrp_manager,mrp.model_mrp_bom_byproduct,sf_base.group_sf_stock_manager,1,0,0,0
|
||||
|
||||
access_sf_rework_wizard_group_sf_order_user,sf_rework_wizard_group_sf_order_user,model_sf_rework_wizard,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_sf_detection_result_group_sf_order_user,sf_detection_result_group_sf_order_user,model_sf_detection_result,sf_base.group_sf_order_user,1,1,1,0
|
||||
|
||||
|
||||
|
@@ -87,7 +87,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='user_id']" position="after">
|
||||
<field name="production_line_id" readonly="1"/>
|
||||
<!-- <field name="production_line_state" readonly="1"/>-->
|
||||
<!-- <field name="production_line_state" readonly="1"/>-->
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
<field name="part_drawing"/>
|
||||
</xpath>
|
||||
@@ -106,7 +106,14 @@
|
||||
<xpath expr="(//header//button[@name='button_mark_done'])[2]" position="replace">
|
||||
<button name="button_mark_done"
|
||||
attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '=', [])]}"
|
||||
string="验证" type="object" class="oe_highlight" data-hotkey="g"
|
||||
string="验证" type="object" data-hotkey="g"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
||||
<button name="button_scrap" invisible="1"/>
|
||||
<button name="button_rework" string="返工" type="object" groups="sf_base.group_sf_mrp_user"/>
|
||||
<button name="button_scrap_new" string="报废" type="object" groups="sf_base.group_sf_mrp_user"/>
|
||||
<button name="button_update_program" string="更新程序" type="object"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
<xpath expr="(//header//button[@name='button_mark_done'])[3]" position="replace">
|
||||
@@ -259,6 +266,18 @@
|
||||
[])]}
|
||||
</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet//notebook//page[@name='operations']" position="after">
|
||||
<page string="检测报告" attrs="{'invisible': [('detection_result_ids', '=', [])]}">
|
||||
<field name="detection_result_ids" string=""/>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//notebook//page[@name='components']" position="attributes">
|
||||
<attribute name="string">投料</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='components_availability']" position="attributes">
|
||||
<attribute name="string">投料状态</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -160,11 +160,9 @@
|
||||
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -->
|
||||
<button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"
|
||||
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done')]}"/>
|
||||
<!-- <button name="button_send_program_again" type="object" string="重新下发NC程序" class="btn-primary"-->
|
||||
<!-- confirm="是否确认重新下发NC程序?"-->
|
||||
<!-- groups="sf_base.group_sf_order_user,sf_base.group_sf_equipment_user"-->
|
||||
<!-- attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','in',['done', 'cancel',-->
|
||||
<!-- 'progress']),('cnc_worksheet','=',False),('is_send_program_again','=',True)]}"/>-->
|
||||
<button name="button_rework_pre" type="object" string="返工"
|
||||
class="btn-primary"
|
||||
attrs="{'invisible': [('routing_type','!=','装夹预调')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from . import workpiece_delivery_wizard
|
||||
from . import rework_wizard
|
||||
|
||||
30
sf_manufacturing/wizard/rework_wizard.py
Normal file
30
sf_manufacturing/wizard/rework_wizard.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
|
||||
import logging
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from datetime import datetime
|
||||
from odoo import models, api, fields, _
|
||||
|
||||
|
||||
class ReworkWizard(models.TransientModel):
|
||||
_name = 'sf.rework.wizard'
|
||||
_description = '返工向导'
|
||||
|
||||
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)
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
routing_type = fields.Selection([
|
||||
('装夹预调', '装夹预调'),
|
||||
('CNC加工', 'CNC加工')], string="工序类型")
|
||||
|
||||
def confirm(self):
|
||||
self.production_ids.detection_result_ids.write((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}))
|
||||
31
sf_manufacturing/wizard/rework_wizard_views.xml
Normal file
31
sf_manufacturing/wizard/rework_wizard_views.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="sf_rework_wizard_form_view">
|
||||
<field name="name">sf.rework.wizard.form.view</field>
|
||||
<field name="model">sf.rework.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="production_ids" invisible="True"/>
|
||||
<field name="workorder_id" invisible="True"/>
|
||||
<group>
|
||||
<field name="rework_reason" required="1"/>
|
||||
<field name="detailed_reason" required="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认返工"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_sf_rework_wizard" model="ir.actions.act_window">
|
||||
<field name="name">返工</field>
|
||||
<field name="res_model">sf.rework.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user