优化质量检测(加工检测)及消息推送
This commit is contained in:
@@ -2,4 +2,3 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from . import controller
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
from . import workorder
|
||||
@@ -1,28 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import json
|
||||
import requests
|
||||
import logging
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from odoo.addons.sf_manufacturing.controllers.controllers import Manufacturing_Connect
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SfQualityConnect(Manufacturing_Connect):
|
||||
|
||||
@http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def AGVDownProduct(self, **kw):
|
||||
res = super(SfQualityConnect, self).AGVDownProduct(**kw)
|
||||
res = json.loads(res)
|
||||
if res.get('workorder_ids'):
|
||||
try:
|
||||
_logger.info('已下产线的工单:%s' % res.get('workorder_ids'))
|
||||
for order_id in res['workorder_ids']:
|
||||
request.env['quality.cnc.test'].sudo().create(
|
||||
{'workorder_id': order_id, 'write_uid': False, 'write_date': False})
|
||||
except Exception as e:
|
||||
_logger.info('AGV运送下产线接口:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
@@ -25,23 +25,44 @@ class SfQualityCncTest(models.Model):
|
||||
('pass', '合格'),
|
||||
('fail', '不合格')], string='判定结果')
|
||||
number = fields.Integer('数量', default=1)
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果")
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
|
||||
def submit_pass(self):
|
||||
self.write({'result': 'pass', 'test_results': '合格', 'state': 'done'})
|
||||
self.write({'result': 'pass', 'test_results': self.test_results, 'state': 'done'})
|
||||
self.workorder_id.write({'test_results': self.test_results})
|
||||
self.workorder_id.button_finish()
|
||||
|
||||
def submit_fail(self):
|
||||
if not self.reason and not self.detailed_reason:
|
||||
raise UserError(_('请填写【检测情况】里的信息'))
|
||||
if not self.reason and not self.detailed_reason and not self.test_results:
|
||||
raise UserError(_('请填写【判定结果】里的信息'))
|
||||
else:
|
||||
self.write({'result': 'fail', 'test_results': '合格', 'state': 'done'})
|
||||
self.write({'result': 'fail', 'test_results': self.test_results, 'state': 'done'})
|
||||
self.workorder_id.write(
|
||||
{'test_results': self.test_results, 'reason': self.reason, 'detailed_reason': self.detailed_reason})
|
||||
self.workorder_id.button_finish()
|
||||
|
||||
|
||||
class SfQualityWorkOrder(models.Model):
|
||||
_inherit = 'mrp.workorder'
|
||||
|
||||
def button_finish(self):
|
||||
super(SfQualityWorkOrder, self).button_finish()
|
||||
if self.routing_type == 'CNC加工':
|
||||
quality_cnc_test = self.env['quality.cnc.test'].search([('workorder_id', '=', self.id)])
|
||||
if quality_cnc_test:
|
||||
quality_cnc_test.write({'result': 'fail' if self.test_results in ['返工', '报废'] else 'pass',
|
||||
'test_results': self.test_results, 'state': 'done',
|
||||
'reason': self.reason,
|
||||
'detailed_reason': self.detailed_reason,
|
||||
'detection_report': self.detection_report})
|
||||
|
||||
def write(self, vals):
|
||||
res = super(SfQualityWorkOrder, self).write(vals)
|
||||
if self.state == 'to be detected':
|
||||
quality_cnc_test = self.env['quality.cnc.test'].search([('workorder_id', '=', self.id)])
|
||||
if not quality_cnc_test:
|
||||
self.env['quality.cnc.test'].sudo().create({'workorder_id': self.id})
|
||||
|
||||
@@ -70,5 +70,8 @@ access_stock_move_group_quality_director,stock_move_group_quality_director,stock
|
||||
access_quality_cnc_test_group_quality,quality_cnc_test_group_quality,model_quality_cnc_test,sf_base.group_quality,1,1,0,0
|
||||
access_quality_cnc_test_group_quality_director,quality_cnc_test_group_quality_director,model_quality_cnc_test,sf_base.group_quality_director,1,1,0,0
|
||||
|
||||
access_quality_cnc_test_group_sf_equipment_user,quality_cnc_test_group_sf_equipment_user,model_quality_cnc_test,sf_base.group_sf_equipment_user,1,1,0,0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -39,7 +39,7 @@
|
||||
filter_domain="[('production_id', 'ilike', self)]"/>
|
||||
<field name="product_id" string="产品"
|
||||
filter_domain="[('product_id', 'ilike', self)]"/>
|
||||
<searchpanel class="account_root">
|
||||
<searchpanel>
|
||||
<field name="state" icon="fa-filter" enable_counters="1"/>
|
||||
<field name="result" icon="fa-filter" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
@@ -96,14 +96,20 @@
|
||||
<page string="检测报告">
|
||||
<field name="detection_report" string="" widget="pdf_viewer"/>
|
||||
</page>
|
||||
<page string="检测情况">
|
||||
<page string="判定结果">
|
||||
<group>
|
||||
<field name="test_results"/>
|
||||
<field name="reason"/>
|
||||
<field name="detailed_reason"/>
|
||||
<field name="test_results" attrs="{'readonly': [('state','=', 'done')]}"/>
|
||||
<field name="reason" attrs="{'readonly': [('state','=', 'done')]}"/>
|
||||
<field name="detailed_reason" attrs="{'readonly': [('state','=', 'done')]}"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="其他">
|
||||
<page string="2D图纸">
|
||||
<!-- <field name="detection_report" string="" widget="pdf_viewer"/>-->
|
||||
</page>
|
||||
<page string="客户质量标准">
|
||||
<!-- <field name="detection_report" string="" widget="pdf_viewer"/>-->
|
||||
</page>
|
||||
<page string="其他" attrs="{'readonly': [('state','=', 'done')]}">
|
||||
<group>
|
||||
<field name="write_uid" widget='many2one_avatar_user' string="判定人" readonly="1"/>
|
||||
<field name="write_date" string="判定时间" readonly="1"/>
|
||||
@@ -115,6 +121,54 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="quality_cnc_test_view_kanban" model="ir.ui.view">
|
||||
<field name="name">quality.cnc.test.view.kanban</field>
|
||||
<field name="model">quality.cnc.test</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="oe_background_grey o_kanban_dashboard o_quality_kanban" create="0">
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click">
|
||||
<div class="add_flex">
|
||||
<div class="o_kanban_card_header">
|
||||
<div class="o_kanban_card_header_title">
|
||||
<field name="name"/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 内容 -->
|
||||
<div class="container o_kanban_card_content">
|
||||
<div>
|
||||
<field name="production_id"/>
|
||||
</div>
|
||||
<div>
|
||||
<field name="processing_panel"/>
|
||||
</div>
|
||||
<div>
|
||||
<field name="state"
|
||||
widget="label_selection"
|
||||
options="{'classes': {'waiting': 'warning', 'done': 'success'}}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="show_state" t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click-->
|
||||
<!-- ">-->
|
||||
<!-- <div t-attf-class="#{record.result.raw_value == 'pass' ? 'color_1' : ''}"></div>-->
|
||||
<!-- <div t-attf-class="#{record.result.raw_value == 'fail' ? 'color_2' : ''}"></div>-->
|
||||
<!-- <p class="o_kanban_record_bottom"-->
|
||||
<!-- t-attf-class="#{record.result.raw_value == 'pass' ? 'font_color_1' : ''}-->
|
||||
<!-- #{record.state.result == 'fail' ? 'font_color_2' : ''}}">-->
|
||||
<!-- <field name="result"/>-->
|
||||
<!-- </p>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="menu_quality_cnc_test"
|
||||
name="加工质检"
|
||||
@@ -123,4 +177,26 @@
|
||||
parent="quality_control.menu_quality_control"
|
||||
/>
|
||||
|
||||
|
||||
<record id="action_quality_cnc_test_kanban" model="ir.actions.act_window">
|
||||
<field name="name">驾驶舱</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">quality.cnc.test</field>
|
||||
<field name="view_mode">kanban,form</field>
|
||||
<field name="view_id" ref="quality_cnc_test_view_kanban"/>
|
||||
<field name="search_view_id" ref="quality_cnc_test_search"/>
|
||||
<field name="domain">[]</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
暂无加工质检单
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_quality_cnc_test_dashboard"
|
||||
name="驾驶舱"
|
||||
action="action_quality_cnc_test_kanban"
|
||||
parent="quality_control.menu_quality_root"
|
||||
sequence="5"/>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -34,36 +34,36 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- <record model="ir.ui.view" id="quality_point_view_form_inherit_sf">-->
|
||||
<!-- <field name="name">quality.point.form.inherit.sf</field>-->
|
||||
<!-- <field name="model">quality.point</field>-->
|
||||
<!-- <field name="inherit_id" ref="quality.quality_point_view_form"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!--<!– <xpath expr="//sheet//group//group//field[@name='title']" position="replace"> –>-->
|
||||
<!--<!– <field name="title" class="custom_required" required="1"/> –>-->
|
||||
<!--<!– </xpath> –>-->
|
||||
<!-- <xpath expr="//sheet//group//group//field[@name='title']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- <attribute name="required">1</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- <xpath expr="//sheet//group//group//field[@name='picking_type_ids']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- <attribute name="required">1</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
<!-- <record model="ir.ui.view" id="quality_point_view_form_inherit_sf">-->
|
||||
<!-- <field name="name">quality.point.form.inherit.sf</field>-->
|
||||
<!-- <field name="model">quality.point</field>-->
|
||||
<!-- <field name="inherit_id" ref="quality.quality_point_view_form"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!--<!– <xpath expr="//sheet//group//group//field[@name='title']" position="replace"> –>-->
|
||||
<!--<!– <field name="title" class="custom_required" required="1"/> –>-->
|
||||
<!--<!– </xpath> –>-->
|
||||
<!-- <xpath expr="//sheet//group//group//field[@name='title']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- <attribute name="required">1</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- <xpath expr="//sheet//group//group//field[@name='picking_type_ids']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- <attribute name="required">1</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record model="ir.ui.view" id="sf_quality_point_view_form_inherit_quality_control">-->
|
||||
<!-- <field name="name">sf.quality.point.form.inherit.sf</field>-->
|
||||
<!-- <field name="model">quality.point</field>-->
|
||||
<!-- <field name="inherit_id" ref="quality_control.quality_point_view_form_inherit_quality_control"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <xpath expr="//field[@name='measure_on']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- <xpath expr="//field[@name='measure_frequency_type']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
<!-- <record model="ir.ui.view" id="sf_quality_point_view_form_inherit_quality_control">-->
|
||||
<!-- <field name="name">sf.quality.point.form.inherit.sf</field>-->
|
||||
<!-- <field name="model">quality.point</field>-->
|
||||
<!-- <field name="inherit_id" ref="quality_control.quality_point_view_form_inherit_quality_control"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <xpath expr="//field[@name='measure_on']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- <xpath expr="//field[@name='measure_frequency_type']" position="attributes">-->
|
||||
<!-- <attribute name="class">custom_required</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user