Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化制造订单报废流程

# Conflicts:
#	sf_manufacturing/models/mrp_production.py
This commit is contained in:
jinling.yang
2024-06-03 15:43:57 +08:00
168 changed files with 6425 additions and 42 deletions

View File

@@ -466,7 +466,6 @@ class Manufacturing_Connect(http.Controller):
order='id asc')
if workpiece_delivery:
for wd in workpiece_delivery:
logging.info('wd.production_id:%s' % wd.production_id.name)
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
logging.info(
'wd.production_line_state:%s' % wd.production_id.production_line_state)
@@ -519,7 +518,6 @@ class Manufacturing_Connect(http.Controller):
order='id asc')
if workpiece_delivery:
for wd in workpiece_delivery:
logging.info('wd.production_id:%s' % wd.production_id.name)
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
logging.info(
'wd.production_line_state:%s' % wd.production_id.production_line_state)

View File

@@ -408,12 +408,12 @@ class MrpProduction(models.Model):
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route))
production.workorder_ids = workorders_values
if is_fetchcnc is False and scrap_production:
production.write({'programming_no': scrap_production.programming_no,
'programming_state': '已编程'})
if production_programming.programming_state == '已编程':
logging.info("production_programming: %s" % production_programming.name)
production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').write({
'cnc_ids': scrap_production.workorder_ids.filtered(
lambda t1: t1.routing_type == 'CNC加工').cnc_ids})
'cnc_ids': production_programming.workorder_ids.filtered(
lambda
t1: t1.routing_type == 'CNC加工').cnc_ids})
for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected()
@@ -507,8 +507,7 @@ class MrpProduction(models.Model):
def _reset_work_order_sequence(self):
for rec in self:
product_routing_sequence_list = {} # 成品
embryo_routing_sequence_list = {} # 坯料
sequence_list = {}
model_type_id = rec.product_id.product_model_type_id
if model_type_id:
tmpl_num = 1
@@ -516,7 +515,7 @@ class MrpProduction(models.Model):
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
if product_routing_tmpl_ids:
for tmpl_id in product_routing_tmpl_ids:
product_routing_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1
# 表面工艺工序
# 模型类型的表面工艺工序模版
@@ -527,7 +526,6 @@ class MrpProduction(models.Model):
if model_process_parameters_ids:
for process_parameters_id in model_process_parameters_ids:
process_id = process_parameters_id.process_id
surface_tmpl_name = ''
for surface_tmpl_id in surface_tmpl_ids:
if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id:
surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name
@@ -535,30 +533,23 @@ class MrpProduction(models.Model):
surface_tmpl_name, process_parameters_id.name)})
process_list = sorted(process_dict.keys())
for process_num in process_list:
product_routing_sequence_list.update({process_dict.get(process_num): tmpl_num})
sequence_list.update({process_dict.get(process_num): tmpl_num})
tmpl_num += 1
# 坯料工序
tmpl_num = 1
embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids
if embryo_routing_tmpl_ids:
for tmpl_id in embryo_routing_tmpl_ids:
embryo_routing_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1
else:
raise ValidationError('该产品没有选择【模版类型】!')
if rec.product_id.categ_id.name == '成品':
for work in rec.workorder_ids:
if product_routing_sequence_list.get(work.name):
work.sequence = product_routing_sequence_list[work.name]
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
elif rec.product_id.categ_id.name == '坯料':
for work in rec.workorder_ids:
if embryo_routing_sequence_list.get(work.name):
work.sequence = embryo_routing_sequence_list[work.name]
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
for work in rec.workorder_ids:
if sequence_list.get(work.name):
work.sequence = sequence_list[work.name]
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
# if work.name == '获取CNC加工程序':
# work.button_start()
# #work.fetchCNC()

View File

@@ -1348,9 +1348,18 @@ class WorkPieceDelivery(models.Model):
def create(self, vals):
if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/'
else:
vals['type'] = '运送空料架'
obj = super(WorkPieceDelivery, self).create(vals)
return obj
@api.constrains('name')
def _check_name(self):
if self.type == '运送空料架':
wd = self.sudo().search([('name', '=', self.name), ('id', '!=', self.id)])
if wd:
raise UserError("该名称已存在")
def action_delivery_history(self):
return {
'name': _('配送历史'),
@@ -1531,7 +1540,7 @@ class WorkPieceDelivery(models.Model):
'task_delivery_time': fields.Datetime.now(),
'status': '待配送'
})
if delivery_item == "上产线":
if delivery_item.type == "上产线":
delivery_item.workorder_id.write({'is_delivery': True})
else:
raise UserError(ret['message'])

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
# Part of SmartGo. See LICENSE file for full copyright and licensing details.
import base64
from io import BytesIO
from odoo import api, fields, models, SUPERUSER_ID, _
from pystrich.code128 import Code128Encoder
class Tray(models.Model):
_inherit = 'sf.tray'
_description = '托盘'
qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image')
production_id = fields.Many2one('mrp.production', string='制造订单',
related='workorder_id.production_id'
)
workorder_id = fields.Many2one('mrp.workorder', string="工单"
)
@api.onchange('production_id')
def updateTrayState(self):
if self.workorder_id != False and self.create_date != False:
self.state = '占用'
else:
self.state = '空闲'
def unclamp(self):
self.workorder_id = False
self.production_id = False
self.state = '空闲'
@api.depends('code')
def compute_qr_image(self):
for item in self:
if not item.code:
item.qr_image = False
continue
# 根据code动态生成二维码图片
# qr = qrcode.QRCode(
# version=1,
# error_correction=qrcode.constants.ERROR_CORRECT_L,
# box_size=10,
# border=4,
# )
# qr.add_data(item.code)
# qr.make(fit=True)
# img = qr.make_image()
# 生成条形码文件
# bar = barcode.get("ean13", "123456789102", writer=ImageWriter())
# a = bar.get_fullcode()
# b = bar.save('occ')
# 生成条形码图片
partner_encoder = Code128Encoder(item.code)
# 转换bytes流
temp = BytesIO()
partner_encoder.save(temp)
# img.save(temp, format='PNG')
qr_image = base64.b64encode(temp.getvalue())
item.qr_image = qr_image

View File

@@ -0,0 +1,74 @@
<odoo>
<data>
<!-- 托盘码打印尺寸-->
<record id="sf_tray1" model="report.paperformat">
<field name="name">Dymo Label Sheet</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">100</field>
<field name="page_width">60</field>
<field name="orientation">Landscape</field>
<field name="margin_top">0</field>
<field name="margin_bottom">0</field>
<field name="margin_left">0</field>
<field name="margin_right">0</field>
<field name="disable_shrinking" eval="True"/>
<field name="dpi">96</field>
</record>
<!-- 托盘码打印动作-->
<record id="label_sf_tray_code" model="ir.actions.report">
<field name="name">打印条形码</field>
<field name="model">sf.tray</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">sf_manufacturing.sf_tray_template</field>
<field name="report_file">sf_manufacturing.sf_tray_template</field>
<field name="binding_model_id" ref="model_sf_tray"/>
<field name="binding_type">report</field>
<field name="paperformat_id" ref="sf_manufacturing.sf_tray1"/>
</record>
<!-- 托盘码打印模板-->
<template id="sf_tray_template">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<t t-foreach="docs" t-as="o">
<div class="page">
<div t-field="o.code"
t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:350px;height:60px'}"/>
<div t-field="o.code" style="text-align: center"/>
</div>
</t>
</t>
</t>
</template>
<!-- 产品信息打印动作-->
<record id="label_sf_tray_code1" model="ir.actions.report">
<field name="name">打印产品信息</field>
<field name="model">mrp.workorder</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">sf_manufacturing.sf_tray_template1</field>
<field name="report_file">sf_manufacturing.sf_tray_template1</field>
<field name="binding_model_id" ref="model_mrp_workorder"/>
<field name="binding_type">report</field>
<field name="paperformat_id" ref="sf_manufacturing.sf_tray1"/>
</record>
<!-- 产品信息打印模板-->
<template id="sf_tray_template1">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<t t-foreach="docs" t-as="o">
<div class="page">
<div t-field="o.production_id.name"
t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:350px;height:60px'}"/>
<div t-field="o.production_id" style="text-align: center"/>
</div>
</t>
</t>
</t>
</template>
</data>
</odoo>

View File

@@ -36,7 +36,7 @@
<tree editable="bottom">
<field name="name" required="1"/>
<field name="type" readonly="1" string="任务类型"/>
<field name="route_type" string="类型"/>
<field name="route_type" string="类型" required="1"/>
<field name="start_site_id" required="1" options="{'no_create': True}" string="起点接驳站"/>
<field name="end_site_id" required="1" options="{'no_create': True}" string="终点接驳站"/>
<field name="destination_production_line_id" required="1" options="{'no_create': True}"/>

View File

@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="maintenance_equipment_view_form_inherit_mrp" model="ir.ui.view">
<field name="name">maintenance.equipment.view.form.inherit.mrp</field>
<field name="model">maintenance.equipment</field>
<field name="inherit_id" ref="maintenance.hr_equipment_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button name="button_mrp_workcenter" type="object" class="oe_stat_button"
icon="fa-cogs" string="Work Center" attrs="{'invisible': [('workcenter_id', '=', False)]}"
groups="mrp.group_mrp_routings">
</button>
</xpath>
<xpath expr="//field[@name='location']" position="after">
<field name="workcenter_id" context="{'default_company_id':company_id}"
groups="mrp.group_mrp_routings"/>
</xpath>
<xpath expr="//group[@name='maintenance']" position="after">
<group name="statistics">
<label for="expected_mtbf" string="Expected Mean Time Between Failure"/>
<div class="o_row">
<field name="expected_mtbf"/>
days
</div>
<label for="mtbf" string="Mean Time Between Failure"/>
<div class="o_row">
<field name="mtbf"/>
days
</div>
<label for="estimated_next_failure" string="Estimated Next Failure"/>
<div class="o_row">
<field name="estimated_next_failure"/>
</div>
<field name="latest_failure_date" string="Latest Failure"/>
<label for="mttr" string="Mean Time To Repair"/>
<div class="o_row">
<field name="mttr"/>
days
</div>
</group>
</xpath>
</field>
</record>
<record id="maintenance_request_view_form_inherit_mrp" model="ir.ui.view">
<field name="name">maintenance.request.view.form.inherit.mrp</field>
<field name="model">maintenance.request</field>
<field name="inherit_id" ref="maintenance.hr_equipment_request_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='maintenance_type']" position="after">
<field name="production_company_id" invisible="1"/>
<field name="workorder_id" invisible="1"/>
<field name="production_id" options="{'no_create': True, 'no_open': True}"/>
<field name="workorder_id" attrs="{'invisible': [('production_id', '=', False)]}"
options="{'no_create': True, 'no_open': True}" domain="[('production_id', '=', production_id)]"
groups="mrp.group_mrp_routings"/>
<!-- <field name="repair_id"/> -->
</xpath>
<xpath expr="//div[hasclass('oe_chatter')]" position="after">
<div invisible="not context.get('discard_on_footer_button', False)">
<footer class="oe_edit_only">
<button special="save" data-hotkey="v" string="Save" class="oe_highlight"/>
<button string="Discard" special="cancel" data-hotkey="z"/>
</footer>
</div>
</xpath>
<field name="equipment_id" position="attributes">
<attribute name="domain">['|', (not workorder_id and 1 or 0, '=', 1), '|', ('workcenter_id', '=',
False), ('workcenter_id.order_ids', 'in', workorder_id)]
</attribute>
</field>
</field>
</record>
<record id="maintenance_request_view_search_inherit_mrp" model="ir.ui.view">
<field name="name">maintenence.request.view.search.inherit.mrp</field>
<field name="model">maintenance.request</field>
<field name="inherit_id" ref="maintenance.hr_equipment_request_view_search"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='maintenance_team_id']" position="after">
<field name="production_id" string="Operation"
filter_domain="['|', ('production_id', 'ilike', self), ('workorder_id', 'ilike', self)]"/>
</xpath>
</field>
</record>
<menuitem
id="maintenance.menu_equipment_form"
name="Equipments"
parent="maintenance.menu_maintenance_title"
groups="maintenance.group_equipment_manager,base.group_user"
sequence="2"/>
<menuitem id="menu_workcenter_tree"
action="mrp.mrp_workcenter_action"
groups="mrp.group_mrp_routings"
parent="maintenance.menu_equipment_form"
sequence="1"/>
<menuitem
id="menu_equipment_dashboard"
name="Machines &amp; Tools"
parent="maintenance.menu_equipment_form"
action="maintenance.hr_equipment_action"
sequence="2"/>
</odoo>

View File

@@ -623,7 +623,6 @@
<field name="route_id" options="{'no_create': True}"
domain="[('route_type','in',['上产线','下产线'])]"/>
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
<field name="is_cnc_program_down" readonly="1"/>
<!-- <field name="rfid_code"/>-->
@@ -673,14 +672,18 @@
<field name="name">空料架配送</field>
<field name="model">sf.workpiece.delivery</field>
<field name="arch" type="xml">
<tree string="工件配送" class="center" create="0" edit="0" delete="0">
<tree string="工件配送" editable="bottom" class="center" delete="0" create="1">
<header>
<button name="button_delivery" type="object" string="配送" class="oe_highlight"/>
</header>
<field name="name" string="路线名称" readonly="1"/>
<field name="route_id" options="{'no_create': True}"/>
<field name="feeder_station_start_id" readonly="1"/>
<field name="feeder_station_destination_id" readonly="1"/>
<field name="name" string="路线名称" attrs="{'readonly': [('id', '!=', False)]}"
placeholder="例如:运送空料架路线:G01-A01" required="1" force_save="1"/>
<field name="route_id" options="{'no_create': True}" required="1"
attrs="{'readonly': [('id', '!=', False)]}" domain="[('route_type', '=', '运送空料架')]"
force_save="1"/>
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
<!-- <field name="type" readonly="1"/>-->
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
<button name="action_delivery_history" type="object" class="btn btn-link text-info" icon="fa-history"
string="历史"/>
</tree>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="sf_tray_form_inherit" model="ir.ui.view">
<field name="name">托盘条形码生成</field>
<field name="model">sf.tray</field>
<field name="inherit_id" ref="sf_base.sf_tray_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='group1']" position="after">
<notebook>
<page string="生成条形码">
<field name='qr_image' widget="image"/>
<group>
<field name='production_id' readonly="1"
attrs='{"invisible": [("production_id","=",False)]}'/>
<field name="workorder_id"/>
</group>
<div class="col
-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="unclamp" string="解除装夹"
attrs='{"invisible": [("state","=","空闲")]}'/>
</div>
</page>
</notebook>
</xpath>
</field>
</record>
</data>
</odoo>