From 0fb751ebbeff511915eb9cd94005f3e00fd334ff Mon Sep 17 00:00:00 2001 From: gqh Date: Tue, 25 Oct 2022 17:19:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=98=E7=9B=98=E7=BB=91=E5=AE=9A=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=EF=BC=8C=E6=89=98=E7=9B=98=E7=94=9F=E6=88=90=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/sf_common.py | 4 +- sf_base/views/mrs_common_view.xml | 24 ++++---- sf_route_workcenter/__init__.py | 2 + sf_route_workcenter/__manifest__.py | 25 ++++++++ sf_route_workcenter/models/__init__.py | 2 + sf_route_workcenter/models/workcenter.py | 70 ++++++++++++++++++++++ sf_route_workcenter/views/sf_tray_view.xml | 28 +++++++++ sf_route_workcenter/views/sf_workorder.xml | 21 +++++++ 8 files changed, 164 insertions(+), 12 deletions(-) create mode 100644 sf_route_workcenter/__init__.py create mode 100644 sf_route_workcenter/__manifest__.py create mode 100644 sf_route_workcenter/models/__init__.py create mode 100644 sf_route_workcenter/models/workcenter.py create mode 100644 sf_route_workcenter/views/sf_tray_view.xml create mode 100644 sf_route_workcenter/views/sf_workorder.xml diff --git a/sf_base/models/sf_common.py b/sf_base/models/sf_common.py index 0d86e593..b1abf43b 100644 --- a/sf_base/models/sf_common.py +++ b/sf_base/models/sf_common.py @@ -72,9 +72,9 @@ class Tray(models.Model): _name = 'sf.tray' _description = '托盘' - code = fields.Char('编码') + code = fields.Char('编码',copy=False) name = fields.Char('名称') state = fields.Selection( [("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")], - default=" ", string="状态") + default="空闲", string="状态") active = fields.Boolean('有效', default=True) diff --git a/sf_base/views/mrs_common_view.xml b/sf_base/views/mrs_common_view.xml index 1877de05..4f9374e1 100644 --- a/sf_base/views/mrs_common_view.xml +++ b/sf_base/views/mrs_common_view.xml @@ -281,14 +281,18 @@ sf.tray.search sf.tray - - - - - - - - + + + + + + + + + + + + @@ -308,11 +312,11 @@ sf.tray.form sf.tray +
- + - diff --git a/sf_route_workcenter/__init__.py b/sf_route_workcenter/__init__.py new file mode 100644 index 00000000..c081ee06 --- /dev/null +++ b/sf_route_workcenter/__init__.py @@ -0,0 +1,2 @@ +# -*-coding:utf-8-*- +from . import models diff --git a/sf_route_workcenter/__manifest__.py b/sf_route_workcenter/__manifest__.py new file mode 100644 index 00000000..8a4dffd0 --- /dev/null +++ b/sf_route_workcenter/__manifest__.py @@ -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, +} diff --git a/sf_route_workcenter/models/__init__.py b/sf_route_workcenter/models/__init__.py new file mode 100644 index 00000000..94d72e99 --- /dev/null +++ b/sf_route_workcenter/models/__init__.py @@ -0,0 +1,2 @@ +# -*-coding:utf-8-*- +from . import workcenter \ No newline at end of file diff --git a/sf_route_workcenter/models/workcenter.py b/sf_route_workcenter/models/workcenter.py new file mode 100644 index 00000000..eae2f56c --- /dev/null +++ b/sf_route_workcenter/models/workcenter.py @@ -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 = "制造订单" diff --git a/sf_route_workcenter/views/sf_tray_view.xml b/sf_route_workcenter/views/sf_tray_view.xml new file mode 100644 index 00000000..05cb382a --- /dev/null +++ b/sf_route_workcenter/views/sf_tray_view.xml @@ -0,0 +1,28 @@ + + + + 托盘二维码生成 + sf.tray + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sf_route_workcenter/views/sf_workorder.xml b/sf_route_workcenter/views/sf_workorder.xml new file mode 100644 index 00000000..c5b24711 --- /dev/null +++ b/sf_route_workcenter/views/sf_workorder.xml @@ -0,0 +1,21 @@ + + + + + 装夹工序工单 + mrp.workorder + + + + + + + + + + + + + + + \ No newline at end of file