1.优化工单排序2.新增调取cloud编程单的状态方法3.制造订单添加状态为返工及编程状态为"已编程",“已编程未下发”的过滤条件4,新增返工且编程中的制造订单定时获取Cloud编程单状态的定时器
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record model="ir.cron" id="ir_cron_mrp_production">
|
||||
<field name="name">返工且编程中的制造订单定时获取Cloud编程单状态</field>
|
||||
<field name="model_id" ref="model_mrp_production"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._cron_get_programming_state()</field>
|
||||
<field name="interval_number">3</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
</record>
|
||||
|
||||
<record id="sequence_routing_workcenter" model="ir.sequence">
|
||||
<field name="name">工序编码规则</field>
|
||||
<field name="code">mrp.routing.workcenter</field>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import base64
|
||||
import logging
|
||||
import json
|
||||
import re
|
||||
import requests
|
||||
from itertools import groupby
|
||||
@@ -53,10 +54,12 @@ class MrpProduction(models.Model):
|
||||
programming_no = fields.Char('编程单号')
|
||||
work_state = fields.Char('业务状态')
|
||||
programming_state = fields.Selection(
|
||||
[('编程中', '编程中'), ('已编程', '已编程')], string='编程状态', tracking=True)
|
||||
[('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发')], string='编程状态',
|
||||
tracking=True)
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
production_line_id = fields.Many2one('sf.production.line', string='生产线', tracking=True)
|
||||
plan_start_processing_time = fields.Datetime('计划开始加工时间')
|
||||
is_rework = fields.Boolean(string='是否返工', default=False)
|
||||
# production_line_state = fields.Selection(
|
||||
# [('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
||||
# string='上/下产线', default='待上产线', tracking=True)
|
||||
@@ -156,20 +159,49 @@ class MrpProduction(models.Model):
|
||||
for production in self:
|
||||
production.maintenance_count = len(production.request_ids)
|
||||
|
||||
# 获取cloud编程单的状态
|
||||
def _cron_get_programming_state(self):
|
||||
try:
|
||||
reproduction = self.search([('state', '=', 'rework'), ('programming_state', '=', '编程中')])
|
||||
if reproduction:
|
||||
programming_no = [item.programming_no for item in reproduction]
|
||||
programming_no_str = ','.join(programming_no)
|
||||
res = {'programming_no': programming_no_str}
|
||||
logging.info('res=%s:' % res)
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/intelligent_programming/get_state'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
ret = requests.post(config_url, json=res, data=None, headers=config_header)
|
||||
ret = ret.json()
|
||||
result = json.loads(ret['result'])
|
||||
logging.info('cron_get_programming_state-ret:%s' % result)
|
||||
if result['status'] == 1:
|
||||
for item in result['programming_list']:
|
||||
production = self.search(
|
||||
[('state', '=', 'rework'), ('programming_no', '=', item['programming_no'])])
|
||||
if production:
|
||||
production.write({'programming_state': '已编程未下发'})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
except Exception as e:
|
||||
logging.info('cron_get_programming_state error:%s' % e)
|
||||
|
||||
# 编程单更新
|
||||
def update_programming_state(self):
|
||||
try:
|
||||
res = {'programming_no': self.programming_no}
|
||||
res = {'programming_no': self.programming_no, 'manufacturing_type': 'rework'}
|
||||
logging.info('res=%s:' % res)
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/intelligent_programming/reset_state_again'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
||||
ret = requests.post(config_url, json=res, data=None, headers=config_header)
|
||||
ret = ret.json()
|
||||
logging.info('update_programming_state-ret:%s' % ret)
|
||||
if ret['status'] == 1:
|
||||
self.write({'work_state': '已编程'})
|
||||
result = json.loads(ret['result'])
|
||||
logging.info('update_programming_state-ret:%s' % result)
|
||||
if result['status'] == 1:
|
||||
self.write({'is_rework': True})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
except Exception as e:
|
||||
@@ -200,7 +232,7 @@ class MrpProduction(models.Model):
|
||||
'material_type_code': self.env['sf.materials.model'].search(
|
||||
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
||||
'machining_processing_panel': cnc.product_id.model_processing_panel,
|
||||
'machining_precision': cnc.product_id.model_machining_precision,
|
||||
'machining_precision': '',
|
||||
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
||||
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
||||
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
||||
@@ -523,11 +555,13 @@ class MrpProduction(models.Model):
|
||||
|
||||
def _reset_work_order_sequence(self):
|
||||
for rec in self:
|
||||
sequence_list = {}
|
||||
workorder_ids = rec.workorder_ids.filtered(lambda item: item.state in ('返工', 'rework'))
|
||||
# 产品模型类型
|
||||
model_type_id = rec.product_id.product_model_type_id
|
||||
# 产品加工面板
|
||||
model_processing_panel = rec.product_id.model_processing_panel
|
||||
if not workorder_ids:
|
||||
sequence_list = {}
|
||||
if model_type_id:
|
||||
if model_processing_panel:
|
||||
tmpl_num = 1
|
||||
@@ -568,7 +602,6 @@ class MrpProduction(models.Model):
|
||||
tmpl_num += 1
|
||||
else:
|
||||
raise ValidationError('该产品【加工面板】为空!')
|
||||
|
||||
else:
|
||||
raise ValidationError('该产品没有选择【模版类型】!')
|
||||
|
||||
@@ -583,10 +616,29 @@ class MrpProduction(models.Model):
|
||||
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||
else:
|
||||
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||
# if work.name == '获取CNC加工程序':
|
||||
# work.button_start()
|
||||
# #work.fetchCNC()
|
||||
# work.button_finish()
|
||||
# 当单个面触发返工时,将新生成的工单插入到返工工单下方,并且后面的所以工单工序重排
|
||||
elif rec.workorder_ids.filtered(lambda item: item.sequence == 0):
|
||||
# 获取新增的返工工单
|
||||
work_ids = rec.workorder_ids.filtered(lambda item: item.sequence == 0)
|
||||
# 获取当前返工面最后一个工单工序
|
||||
sequence_max = sorted(
|
||||
rec.workorder_ids.filtered(lambda item: item.processing_panel == work_ids[0].processing_panel),
|
||||
key=lambda item: item.sequence, reverse=True)[0].sequence
|
||||
# 对当前返工工单之后的工单工序进行重排
|
||||
work_order_ids = rec.workorder_ids.filtered(lambda item: item.sequence > sequence_max)
|
||||
for work_id in work_order_ids:
|
||||
work_id.sequence = work_id.sequence + 3
|
||||
# 生成新增的返工工单的工序
|
||||
# 成品工序
|
||||
panel_sequence_list = {}
|
||||
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
|
||||
if product_routing_tmpl_ids:
|
||||
for tmpl_id in product_routing_tmpl_ids:
|
||||
sequence_max += 1
|
||||
panel_sequence_list.update({tmpl_id.route_workcenter_id.name: sequence_max})
|
||||
for work_id in work_ids:
|
||||
if panel_sequence_list.get(work_id.name):
|
||||
work_id.sequence = panel_sequence_list[work_id.name]
|
||||
|
||||
# 创建工单并进行排序
|
||||
def _create_workorder(self, item):
|
||||
|
||||
@@ -1,63 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<menuitem action="mrp.mrp_production_action"
|
||||
id="mrp_production_action"
|
||||
sequence="1" active="False"/>
|
||||
|
||||
<!-- <record id="mrp_production_action_sf" model="ir.actions.act_window">-->
|
||||
<!-- <field name="name">Manufacturing Orders</field>-->
|
||||
<!-- <field name="type">ir.actions.act_window</field>-->
|
||||
<!-- <field name="res_model">mrp.production</field>-->
|
||||
<!-- <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>-->
|
||||
<!-- <field name="search_view_id" ref="mrp.view_mrp_production_filter"/>-->
|
||||
<!-- <!– <field name="context">{'search_default_todo': True, 'default_company_id': allowed_company_ids[0]}</field>–>-->
|
||||
<!-- <field name="domain">[('picking_type_id.active', '=', True)]</field>-->
|
||||
<!-- </record>-->
|
||||
<!-- <menuitem action="mrp_production_action_sf"-->
|
||||
<!-- id="menu_mrp_production_action_sf"-->
|
||||
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
||||
<!-- sequence="2"-->
|
||||
<!-- string="制造订单"/>-->
|
||||
<!-- <record id="mrp_production_action_sf" model="ir.actions.act_window">-->
|
||||
<!-- <field name="name">Manufacturing Orders</field>-->
|
||||
<!-- <field name="type">ir.actions.act_window</field>-->
|
||||
<!-- <field name="res_model">mrp.production</field>-->
|
||||
<!-- <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>-->
|
||||
<!-- <field name="view_id" eval="False"/>-->
|
||||
<!-- <field name="search_view_id" ref="mrp.view_mrp_production_filter"/>-->
|
||||
<!-- <field name="context">{'search_default_todo': True, 'default_company_id':-->
|
||||
<!-- allowed_company_ids[0]}-->
|
||||
<!-- </field>-->
|
||||
<!-- <field name="domain">[('picking_type_id.active', '=', True)]</field>-->
|
||||
<!--<!– <!– <field name="help" type="html">–>,'search_default_filter_rework': 1,–>-->
|
||||
<!--<!– 'search_default_filter_programming': 1–>-->
|
||||
<!-- <!– <p class="o_view_nocontent_smiling_face">–>-->
|
||||
<!-- <!– No manufacturing order found. Let's create one.–>-->
|
||||
<!-- <!– </p>–>-->
|
||||
<!-- <!– <p>–>-->
|
||||
<!-- <!– Consume <a name="%(product.product_template_action)d" type='action' tabindex="-1">components</a> and–>-->
|
||||
<!-- <!– build finished products using–>-->
|
||||
<!-- <!– <a name="%(mrp_bom_form_action)d" type='action' tabindex="-1">bills of materials</a>–>-->
|
||||
<!-- <!– </p>–>-->
|
||||
<!-- <!– </field>–>-->
|
||||
<!-- </record>-->
|
||||
|
||||
|
||||
<!-- <menuitem action="mrp_production_action_sf"-->
|
||||
<!-- id="sf_manufacturing.menu_mrp_production_action_sf"-->
|
||||
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
||||
<!-- sequence="3" string="制造订单"/>-->
|
||||
|
||||
<menuitem action="mrp.mrp_production_action"
|
||||
id="mrp_production_action"
|
||||
sequence="1" active="False"/>
|
||||
|
||||
<record id="custom_mrp_production_tree_view" model="ir.ui.view">
|
||||
<field name="name">custom.mrp.production.tree</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='do_unreserve']" position="after">
|
||||
<!-- <button name="do_unreserve" type="object" string="更新程序"/>-->
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='product_id']" position="replace"/>
|
||||
<xpath expr="//field[@name='product_qty']" position="replace"/>
|
||||
<xpath expr="//field[@name='product_uom_id']" position="replace"/>
|
||||
@@ -129,8 +81,10 @@
|
||||
<xpath expr="//sheet//group//group//div[3]" position="after">
|
||||
<field name="manual_quotation" readonly="1"/>
|
||||
<field name="programming_no" readonly="1"/>
|
||||
<field name="programming_state" readonly="1" decoration-success="programming_state == '已编程'"
|
||||
decoration-warning="programming_state =='编程中'"/>
|
||||
<field name="programming_state" readonly="1"
|
||||
decoration-success="programming_state == '已编程'"
|
||||
decoration-warning="programming_state =='编程中'"
|
||||
decoration-danger="programming_state =='已编程未下发'"/>
|
||||
<field name="work_state" invisible="1"/>
|
||||
<field name="schedule_state" invisible='1'/>
|
||||
</xpath>
|
||||
@@ -364,6 +318,16 @@
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_editable_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//tree" position="attributes">
|
||||
<attribute name="default_order">sequence</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='state']" position="replace">
|
||||
<field name="state" widget="badge" decoration-warning="state == 'progress'"
|
||||
decoration-success="state == 'done'" decoration-danger="state in ('cancel','rework')"
|
||||
decoration-muted="state == 'to be detected'"
|
||||
decoration-info="state not in ('progress', 'done', 'cancel','rework','to be detected')"
|
||||
attrs="{'invisible': [('production_state', '=', 'draft')], 'column_invisible': [('parent.state', '=', 'draft')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//tree//button[@name='button_start']" position="replace">
|
||||
<field name="routing_type" invisible="True"/>
|
||||
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始?"
|
||||
@@ -481,17 +445,19 @@
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp.view_mrp_production_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<!-- <xpath expr="//filter[@name='filter_in_progress']" position="before">-->
|
||||
<!-- <filter string="返工" name="filter_rework" domain="[('state', '=', 'rework')]"/>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- <xpath expr="//filter[@name='planning_issues']" position="before">-->
|
||||
<!-- <separator/>-->
|
||||
<!-- <filter name="filter_programming" string="编程中"-->
|
||||
<!-- domain="[('programming_state', 'in', ['编程中'])]"/>-->
|
||||
<!-- <filter name="filter_programmed" string="已编程"-->
|
||||
<!-- domain="[('programming_state', 'in', ['已编程'])]"/>-->
|
||||
<!-- <separator/>-->
|
||||
<!-- </xpath>-->
|
||||
<xpath expr="//filter[@name='filter_in_progress']" position="before">
|
||||
<filter string="返工" name="filter_rework" domain="[('state', '=', 'rework')]"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='planning_issues']" position="before">
|
||||
<separator/>
|
||||
<filter name="filter_programming" string="编程中"
|
||||
domain="[('programming_state', '=', '编程中')]"/>
|
||||
<filter name="filter_programmed" string="已编程"
|
||||
domain="[('programming_state', '=', '已编程')]"/>
|
||||
<filter name="filter_programmed_not_delivered" string="已编程未下发"
|
||||
domain="[('programming_state', '=', '已编程未下发')]"/>
|
||||
<separator/>
|
||||
</xpath>
|
||||
<xpath expr="//search" position="inside">
|
||||
<searchpanel class="account_root">
|
||||
<field name="state" icon="fa-filter" enable_counters="1"/>
|
||||
@@ -596,5 +562,52 @@
|
||||
<field name="res_model">sf.detection.result</field>
|
||||
<field name="view_mode">form</field>
|
||||
</record>
|
||||
<!-- <menuitem action="mrp.mrp_production_action"-->
|
||||
<!-- id="mrp_production_action"-->
|
||||
<!-- sequence="1" active="False"/>-->
|
||||
|
||||
<!-- <!– <record id="mrp_production_action_sf" model="ir.actions.act_window">–>-->
|
||||
<!-- <!– <field name="name">Manufacturing Orders</field>–>-->
|
||||
<!-- <!– <field name="type">ir.actions.act_window</field>–>-->
|
||||
<!-- <!– <field name="res_model">mrp.production</field>–>-->
|
||||
<!-- <!– <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>–>-->
|
||||
<!-- <!– <field name="search_view_id" ref="mrp.view_mrp_production_filter"/>–>-->
|
||||
<!-- <!– <!– <field name="context">{'search_default_todo': True, 'default_company_id': allowed_company_ids[0]}</field>–>–>-->
|
||||
<!-- <!– <field name="domain">[('picking_type_id.active', '=', True)]</field>–>-->
|
||||
<!-- <!– </record>–>-->
|
||||
<!-- <!– <menuitem action="mrp_production_action_sf"–>-->
|
||||
<!-- <!– id="menu_mrp_production_action_sf"–>-->
|
||||
<!-- <!– parent="mrp.menu_mrp_manufacturing"–>-->
|
||||
<!-- <!– sequence="2"–>-->
|
||||
<!-- <!– string="制造订单"/>–>-->
|
||||
<!-- <record id="mrp_production_action_sf" model="ir.actions.act_window">-->
|
||||
<!-- <field name="name">Manufacturing Orders</field>-->
|
||||
<!-- <field name="type">ir.actions.act_window</field>-->
|
||||
<!-- <field name="res_model">mrp.production</field>-->
|
||||
<!-- <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>-->
|
||||
<!-- <field name="view_id" eval="False"/>-->
|
||||
<!-- <field name="search_view_id" ref="mrp.view_mrp_production_filter"/>-->
|
||||
<!-- <field name="context">{'search_default_todo': True, 'default_company_id':-->
|
||||
<!-- allowed_company_ids[0],'search_default_filter_rework':1,'search_default_filter_programmed':1}-->
|
||||
<!-- </field>-->
|
||||
<!-- <field name="domain">[('picking_type_id.active', '=', True)]</field>-->
|
||||
<!-- <!– <!– <field name="help" type="html">–>,'search_default_filter_rework': 1,–>-->
|
||||
<!-- <!– 'search_default_filter_programming': 1–>-->
|
||||
<!-- <!– <p class="o_view_nocontent_smiling_face">–>-->
|
||||
<!-- <!– No manufacturing order found. Let's create one.–>-->
|
||||
<!-- <!– </p>–>-->
|
||||
<!-- <!– <p>–>-->
|
||||
<!-- <!– Consume <a name="%(product.product_template_action)d" type='action' tabindex="-1">components</a> and–>-->
|
||||
<!-- <!– build finished products using–>-->
|
||||
<!-- <!– <a name="%(mrp_bom_form_action)d" type='action' tabindex="-1">bills of materials</a>–>-->
|
||||
<!-- <!– </p>–>-->
|
||||
<!-- <!– </field>–>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <menuitem action="sf_manufacturing.mrp_production_action_sf"-->
|
||||
<!-- id="mrp_production_action"-->
|
||||
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
||||
<!-- sequence="1"/>-->
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -7,7 +7,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="replace">
|
||||
<field name="is_subcontract" invisible="1"/>
|
||||
|
||||
<field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/>
|
||||
</field>
|
||||
<field name="name" position="before">
|
||||
|
||||
@@ -43,7 +43,8 @@ class ReworkWizard(models.TransientModel):
|
||||
self.env['mrp.workorder'].json_workorder_str(self.processing_panel_id.name,
|
||||
self.production_id, route, False))
|
||||
if workorders_values:
|
||||
self.production_id.write({'workorder_ids': workorders_values, 'programming_state': '编程中'})
|
||||
self.production_id.write(
|
||||
{'workorder_ids': workorders_values, 'programming_state': '编程中', 'work_state': '编程中'})
|
||||
self.production_id._reset_work_order_sequence()
|
||||
self.production_id.update_programming_state()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user