托盘绑定工单,托盘生成二维码
This commit is contained in:
@@ -72,9 +72,9 @@ class Tray(models.Model):
|
|||||||
_name = 'sf.tray'
|
_name = 'sf.tray'
|
||||||
_description = '托盘'
|
_description = '托盘'
|
||||||
|
|
||||||
code = fields.Char('编码')
|
code = fields.Char('编码',copy=False)
|
||||||
name = fields.Char('名称')
|
name = fields.Char('名称')
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
[("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")],
|
[("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")],
|
||||||
default=" ", string="状态")
|
default="空闲", string="状态")
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|||||||
@@ -281,14 +281,18 @@
|
|||||||
<field name="name">sf.tray.search</field>
|
<field name="name">sf.tray.search</field>
|
||||||
<field name="model">sf.tray</field>
|
<field name="model">sf.tray</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="托盘">
|
<!-- <group>-->
|
||||||
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
|
|
||||||
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
|
|
||||||
<!-- <field name="state" string="状态" filter_domain="[('state','ilike',self)]"/>-->
|
<search string="托盘">
|
||||||
</search>
|
<field name="name" string="名称" filter_domain="[('name','like',self)]"/>
|
||||||
<group string="分组">
|
<field name="code" string="编码" filter_domain="[('code','like',self)]"/>
|
||||||
<filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
|
|
||||||
</group>
|
</search>
|
||||||
|
<group string="分组">
|
||||||
|
<filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
|
||||||
|
</group>
|
||||||
|
<!-- </group>-->
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -308,11 +312,11 @@
|
|||||||
<field name="name">sf.tray.form</field>
|
<field name="name">sf.tray.form</field>
|
||||||
<field name="model">sf.tray</field>
|
<field name="model">sf.tray</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<header><field name = 'state' widget="radio" options="{'horizontal': True}"/></header>
|
||||||
<form string="托盘">
|
<form string="托盘">
|
||||||
<group string="基本信息">
|
<group string="基本信息" name="group1">
|
||||||
<group>
|
<group>
|
||||||
<field name="code" required="1"/>
|
<field name="code" required="1"/>
|
||||||
<field name="state" required="1"/>
|
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="name" required="1"/>
|
<field name="name" required="1"/>
|
||||||
|
|||||||
2
sf_route_workcenter/__init__.py
Normal file
2
sf_route_workcenter/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*-coding:utf-8-*-
|
||||||
|
from . import models
|
||||||
25
sf_route_workcenter/__manifest__.py
Normal file
25
sf_route_workcenter/__manifest__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
{
|
||||||
|
'name': '机企猫藏智能工厂 工序',
|
||||||
|
'version': '1.0',
|
||||||
|
'summary': '智能工厂工作中心工序',
|
||||||
|
'sequence': 1,
|
||||||
|
'description': """
|
||||||
|
在本模块,同步资源库
|
||||||
|
""",
|
||||||
|
'category': 'YZ',
|
||||||
|
'website': 'https://www.sf.cs.jikimo.com',
|
||||||
|
'depends': ['mrp', 'sf_base'],
|
||||||
|
'data': [
|
||||||
|
'views/sf_tray_view.xml',
|
||||||
|
'views/sf_workorder.xml',
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
],
|
||||||
|
'qweb': [
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'application': False,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
||||||
2
sf_route_workcenter/models/__init__.py
Normal file
2
sf_route_workcenter/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*-coding:utf-8-*-
|
||||||
|
from . import workcenter
|
||||||
70
sf_route_workcenter/models/workcenter.py
Normal file
70
sf_route_workcenter/models/workcenter.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of SmartGo. See LICENSE file for full copyright and licensing details.
|
||||||
|
import base64
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import qrcode
|
||||||
|
|
||||||
|
from io import BytesIO
|
||||||
|
from odoo import api, fields, models
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Tray(models.Model):
|
||||||
|
_inherit = 'sf.tray'
|
||||||
|
_description = '托盘'
|
||||||
|
|
||||||
|
production_id = fields.Many2one('mrp.production', string='制造订单',
|
||||||
|
related='workorder_id.production_id')
|
||||||
|
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||||
|
qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image')
|
||||||
|
|
||||||
|
@api.depends('code')
|
||||||
|
def compute_qr_image(self):
|
||||||
|
for item in self:
|
||||||
|
if not item.code:
|
||||||
|
item.qr_image = False
|
||||||
|
continue
|
||||||
|
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()
|
||||||
|
temp = BytesIO()
|
||||||
|
img.save(temp, format='PNG')
|
||||||
|
qr_image = base64.b64encode(temp.getvalue())
|
||||||
|
item.qr_image = qr_image
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
工单绑定托盘信息
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
class MrpWorkOrder(models.Model):
|
||||||
|
_inherit = 'mrp.workorder'
|
||||||
|
_description = '工单'
|
||||||
|
|
||||||
|
tray_id = fields.Many2one('sf.tray', string="托盘")
|
||||||
|
tray_code = fields.Char(
|
||||||
|
string='托盘编码',
|
||||||
|
related='tray_id.code')
|
||||||
|
tray_state = fields.Selection(
|
||||||
|
string='托盘状态',
|
||||||
|
related='tray_id.state')
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
制造订单绑定托盘信息
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
class MrpProduction(models.Model):
|
||||||
|
_inherit = 'mrp.production'
|
||||||
|
_description = "制造订单"
|
||||||
28
sf_route_workcenter/views/sf_tray_view.xml
Normal file
28
sf_route_workcenter/views/sf_tray_view.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<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" />
|
||||||
|
<field name = 'production_id' default="production_id.name" />
|
||||||
|
<field name = 'workorder_id' default="workorder_id.name"/>
|
||||||
|
|
||||||
|
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
21
sf_route_workcenter/views/sf_workorder.xml
Normal file
21
sf_route_workcenter/views/sf_workorder.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="sf_install_the_tray_workorder_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">装夹工序工单</field>
|
||||||
|
<field name="model">mrp.workorder</field>
|
||||||
|
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//page[last()]" position="before">
|
||||||
|
<page string="托盘参数" >
|
||||||
|
<group>
|
||||||
|
<field name="tray_id" domain="[('state', '!=', '占用'),('state', '!=', '报损')]"/>
|
||||||
|
<field name="tray_code"/>
|
||||||
|
<field name="tray_state"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user