移除托盘对象 并清除所有关联关系
This commit is contained in:
@@ -124,16 +124,16 @@ class MrsProcessingOrder(models.Model):
|
||||
production_process_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||
|
||||
|
||||
class Tray(models.Model):
|
||||
_name = 'sf.tray'
|
||||
_description = '托盘'
|
||||
|
||||
code = fields.Char('编码', copy=False)
|
||||
name = fields.Char('名称')
|
||||
state = fields.Selection(
|
||||
[("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")],
|
||||
default="空闲", string="状态")
|
||||
active = fields.Boolean('有效', default=True)
|
||||
# class Tray(models.Model):
|
||||
# _name = 'sf.tray'
|
||||
# _description = '托盘'
|
||||
#
|
||||
# code = fields.Char('编码', copy=False)
|
||||
# name = fields.Char('名称')
|
||||
# state = fields.Selection(
|
||||
# [("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")],
|
||||
# default="空闲", string="状态")
|
||||
# active = fields.Boolean('有效', default=True)
|
||||
|
||||
|
||||
class SupplierSort(models.Model):
|
||||
|
||||
@@ -9,7 +9,6 @@ access_sf_production_process,sf_production_process,model_sf_production_process,b
|
||||
access_sf_production_materials,sf_production_materials,model_sf_production_materials,base.group_user,1,1,1,1
|
||||
access_sf_materials_model,sf_materials_model,model_sf_materials_model,base.group_user,1,1,1,1
|
||||
access_sf_processing_technology,sf_processing_technology,model_sf_processing_technology,base.group_user,1,1,1,1
|
||||
access_sf_tray,sf_tray,model_sf_tray,base.group_user,1,1,1,1
|
||||
access_sf_supplier_sort,sf_supplier_sort,model_sf_supplier_sort,base.group_user,1,1,1,1
|
||||
access_sf_production_process_parameter,sf_production_process_parameter,model_sf_production_process_parameter,base.group_user,1,1,1,1
|
||||
access_sf_production_process_category,sf_production_process_category,model_sf_production_process_category,base.group_user,1,1,1,1
|
||||
|
||||
|
@@ -335,66 +335,66 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
#------------------托盘------------------
|
||||
<record id="action_sf_tray" model="ir.actions.act_window">
|
||||
<field name="name">托盘</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.tray</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
创建托盘吧
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
<!-- #------------------托盘-------------------->
|
||||
<!-- <record id="action_sf_tray" model="ir.actions.act_window">-->
|
||||
<!-- <field name="name">托盘</field>-->
|
||||
<!-- <field name="type">ir.actions.act_window</field>-->
|
||||
<!-- <field name="res_model">sf.tray</field>-->
|
||||
<!-- <field name="view_mode">tree,form</field>-->
|
||||
<!-- <field name="help" type="html">-->
|
||||
<!-- <p class="o_view_nocontent_smiling_face">-->
|
||||
<!-- 创建托盘吧-->
|
||||
<!-- </p>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="view_sf_tray_search" model="ir.ui.view">
|
||||
<field name="name">sf.tray.search</field>
|
||||
<field name="model">sf.tray</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="托盘">
|
||||
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
|
||||
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
|
||||
<group string="分组">
|
||||
<filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
<!-- <record id="view_sf_tray_search" model="ir.ui.view">-->
|
||||
<!-- <field name="name">sf.tray.search</field>-->
|
||||
<!-- <field name="model">sf.tray</field>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <search string="托盘">-->
|
||||
<!-- <field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>-->
|
||||
<!-- <field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>-->
|
||||
<!-- <group string="分组">-->
|
||||
<!-- <filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- </search>-->
|
||||
|
||||
</field>
|
||||
</record>
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record model="ir.ui.view" id="tree_sf_tray_view">
|
||||
<field name="name">sf.tray.tree</field>
|
||||
<field name="model">sf.tray</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="托盘">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<!-- <record model="ir.ui.view" id="tree_sf_tray_view">-->
|
||||
<!-- <field name="name">sf.tray.tree</field>-->
|
||||
<!-- <field name="model">sf.tray</field>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <tree string="托盘">-->
|
||||
<!-- <field name="code"/>-->
|
||||
<!-- <field name="name"/>-->
|
||||
<!-- <field name="state"/>-->
|
||||
<!-- </tree>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record model="ir.ui.view" id="sf_tray_form">
|
||||
<field name="name">sf.tray.form</field>
|
||||
<field name="model">sf.tray</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="托盘">
|
||||
<header>
|
||||
<field name='state' widget="radio" options="{'horizontal': True}"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group name="group1">
|
||||
<group>
|
||||
<field name="code" required="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="name" required="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<!-- <record model="ir.ui.view" id="sf_tray_form">-->
|
||||
<!-- <field name="name">sf.tray.form</field>-->
|
||||
<!-- <field name="model">sf.tray</field>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <form string="托盘">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name='state' widget="radio" options="{'horizontal': True}"/>-->
|
||||
<!-- </header>-->
|
||||
<!-- <sheet>-->
|
||||
<!-- <group name="group1">-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="code" required="1"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="name" required="1"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- </group>-->
|
||||
<!-- </sheet>-->
|
||||
<!-- </form>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -44,13 +44,13 @@
|
||||
sequence="2"
|
||||
action="action_sf_machine_tool_type"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_tray"
|
||||
parent="mrp.menu_mrp_configuration"
|
||||
name="托盘"
|
||||
sequence="8"
|
||||
action="action_sf_tray"
|
||||
/>
|
||||
<!-- <menuitem-->
|
||||
<!-- id="menu_sf_tray"-->
|
||||
<!-- parent="mrp.menu_mrp_configuration"-->
|
||||
<!-- name="托盘"-->
|
||||
<!-- sequence="8"-->
|
||||
<!-- action="action_sf_tray"-->
|
||||
<!-- />-->
|
||||
|
||||
<menuitem
|
||||
sequence="2"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='production_id']" position="before">
|
||||
<!-- <field name="name" filter_domain="['|', '|', ('明确的字段内容', 'ilike', self), ('shortdesc', 'ilike', self), ('name', 'ilike', self)]" string="Theme"/>-->
|
||||
<field name="tray_code" filter_domain="[('production_id.tray_ids.code','=',self)]"/>
|
||||
<!-- <field name="tray_code" filter_domain="[('production_id.tray_ids.code','=',self)]"/>-->
|
||||
<!-- <field name="production_id"/>-->
|
||||
</xpath>
|
||||
<!-- <xpath expr="//search//group//filter[@name='product']" position="before">-->
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
'data': [
|
||||
'security/group_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/maintenance_views.xml',
|
||||
'views/maintenance_logs_views.xml',
|
||||
'views/maintenance_views.xml',
|
||||
'views/equipment_maintenance_standards_views.xml',
|
||||
'views/maintenance_request_views.xml',
|
||||
],
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
'security/group_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/mrp_production_addional_change.xml',
|
||||
'report/tray_report.xml',
|
||||
# 'report/tray_report.xml',
|
||||
# 'views/mrp_maintenance_views.xml',
|
||||
'views/mrp_routing_workcenter_view.xml',
|
||||
'views/mrp_workcenter_views.xml',
|
||||
'views/mrp_workorder_view.xml',
|
||||
'views/production_line_view.xml',
|
||||
'views/tray_view.xml',
|
||||
# 'views/tray_view.xml',
|
||||
'views/model_type_view.xml',
|
||||
# 'views/kanban_change.xml'
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class MrpProduction(models.Model):
|
||||
_description = "制造订单"
|
||||
_order = 'create_date desc'
|
||||
|
||||
tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
||||
# tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
||||
maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests")
|
||||
request_ids = fields.One2many('maintenance.request', 'production_id')
|
||||
model_file = fields.Binary('模型文件', related='product_id.model_file')
|
||||
|
||||
@@ -99,7 +99,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果")
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工")
|
||||
tray_code = fields.Char(string="托盘")
|
||||
tray_code = fields.Char(string="托盘编码")
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
is_subcontract = fields.Boolean(string='是否外协')
|
||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||
@@ -252,32 +252,32 @@ class ResMrpWorkOrder(models.Model):
|
||||
'domain': [('workorder_id', '=', self.id)]
|
||||
}
|
||||
|
||||
tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True)
|
||||
# tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True)
|
||||
|
||||
# 扫码绑定托盘方法
|
||||
|
||||
def gettray(self):
|
||||
if self.tray_code != False:
|
||||
values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
||||
if values:
|
||||
if values.state == "占用":
|
||||
raise UserError('该托盘已占用')
|
||||
if values.state == "报损":
|
||||
raise UserError('该托盘已损坏')
|
||||
else:
|
||||
values.update({
|
||||
'workorder_id': self,
|
||||
'production_id': self.production_id,
|
||||
'state': '占用',
|
||||
})
|
||||
self.work_state = "已绑定"
|
||||
orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
for a in orders:
|
||||
a.tray_id = values
|
||||
else:
|
||||
raise UserError('该托盘编码已失效')
|
||||
else:
|
||||
raise UserError('托盘码不能为空')
|
||||
# def gettray(self):
|
||||
# if self.tray_code != False:
|
||||
# values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
||||
# if values:
|
||||
# if values.state == "占用":
|
||||
# raise UserError('该托盘已占用')
|
||||
# if values.state == "报损":
|
||||
# raise UserError('该托盘已损坏')
|
||||
# else:
|
||||
# values.update({
|
||||
# 'workorder_id': self,
|
||||
# 'production_id': self.production_id,
|
||||
# 'state': '占用',
|
||||
# })
|
||||
# self.work_state = "已绑定"
|
||||
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
# for a in orders:
|
||||
# a.tray_id = values
|
||||
# else:
|
||||
# raise UserError('该托盘编码已失效')
|
||||
# else:
|
||||
# raise UserError('托盘码不能为空')
|
||||
|
||||
# 验证坯料序列号是否正确
|
||||
def pro_code_is_ok(self, barcode):
|
||||
@@ -293,50 +293,50 @@ class ResMrpWorkOrder(models.Model):
|
||||
pro_code_ok = fields.Boolean(default=False)
|
||||
|
||||
# 托盘扫码绑定
|
||||
def gettray_auto(self, barcode):
|
||||
if barcode != False:
|
||||
values = self.env['sf.tray'].search([("code", "=", barcode)])
|
||||
|
||||
if values:
|
||||
if values.state == "占用":
|
||||
raise UserError('该托盘已占用')
|
||||
if values.state == "报损":
|
||||
raise UserError('该托盘已损坏')
|
||||
else:
|
||||
values.update({
|
||||
'workorder_id': self,
|
||||
'production_id': self.production_id,
|
||||
'state': '占用',
|
||||
})
|
||||
self.work_state = "已绑定"
|
||||
orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
for a in orders:
|
||||
a.tray_id = values
|
||||
|
||||
return values
|
||||
|
||||
# return {
|
||||
# 'name': _('New Maintenance Request'),
|
||||
# 'view_mode': 'form',
|
||||
# 'res_model': 'maintenance.request',
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# 'context': {
|
||||
# 'default_company_id': self.company_id.id,
|
||||
# 'default_production_id': self.id,
|
||||
# },
|
||||
# 'domain': [('production_id', '=', self.id)],
|
||||
# }
|
||||
else:
|
||||
raise UserError('该托盘编码已失效')
|
||||
else:
|
||||
raise UserError('托盘码不能为空')
|
||||
# def gettray_auto(self, barcode):
|
||||
# if barcode != False:
|
||||
# values = self.env['sf.tray'].search([("code", "=", barcode)])
|
||||
#
|
||||
# if values:
|
||||
# if values.state == "占用":
|
||||
# raise UserError('该托盘已占用')
|
||||
# if values.state == "报损":
|
||||
# raise UserError('该托盘已损坏')
|
||||
# else:
|
||||
# values.update({
|
||||
# 'workorder_id': self,
|
||||
# 'production_id': self.production_id,
|
||||
# 'state': '占用',
|
||||
# })
|
||||
# self.work_state = "已绑定"
|
||||
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
# for a in orders:
|
||||
# a.tray_id = values
|
||||
#
|
||||
# return values
|
||||
#
|
||||
# # return {
|
||||
# # 'name': _('New Maintenance Request'),
|
||||
# # 'view_mode': 'form',
|
||||
# # 'res_model': 'maintenance.request',
|
||||
# # 'type': 'ir.actions.act_window',
|
||||
# # 'context': {
|
||||
# # 'default_company_id': self.company_id.id,
|
||||
# # 'default_production_id': self.id,
|
||||
# # },
|
||||
# # 'domain': [('production_id', '=', self.id)],
|
||||
# # }
|
||||
# else:
|
||||
# raise UserError('该托盘编码已失效')
|
||||
# else:
|
||||
# raise UserError('托盘码不能为空')
|
||||
|
||||
# 解除托盘绑定
|
||||
def unbindtray(self):
|
||||
tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)])
|
||||
if tray:
|
||||
tray.unclamp()
|
||||
self.tray_id = False
|
||||
# def unbindtray(self):
|
||||
# tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)])
|
||||
# if tray:
|
||||
# tray.unclamp()
|
||||
# self.tray_id = False
|
||||
|
||||
# return {
|
||||
# 'name': _('New Maintenance Request'),
|
||||
@@ -682,51 +682,51 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
_name = "mrp.workorder"
|
||||
_inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"]
|
||||
|
||||
def on_barcode_scanned(self, barcode):
|
||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||
if "*" not in barcode:
|
||||
if self.routing_type == '装夹':
|
||||
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||
self.tray_code = tray_code.code
|
||||
self.tray_id = workorder.gettray_auto(barcode)
|
||||
elif self.routing_type == '前置三元定位检测':
|
||||
print('我是前置三元检测')
|
||||
logging.info('我是前置三元检测')
|
||||
elif self.routing_type == 'CNC加工':
|
||||
if barcode == 'UP-ALL':
|
||||
print("我是一键合并下发")
|
||||
logging.info('我是一键合并下发')
|
||||
self.up_merge_all()
|
||||
else:
|
||||
print('CNC加工')
|
||||
# print(barcode)
|
||||
# a = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||
# print(a)
|
||||
# # workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)], limit=1)
|
||||
# workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)])
|
||||
# e = workorder_obj.id
|
||||
# print(workorder_obj)
|
||||
# action = {
|
||||
# 'name': '工单',
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# # 'view_type': 'form',
|
||||
# 'view_mode': 'form',
|
||||
# 'res_model': 'mrp.workorder',
|
||||
# 'view_id': self.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
|
||||
# # 'res_id': workorder_obj.id,
|
||||
# 'res_id': 1023,
|
||||
# 'target': 'current',
|
||||
# # 'context': self.env.context,
|
||||
# # 'flags': {'initial_mode': 'edit'},
|
||||
# }
|
||||
# return action
|
||||
|
||||
elif self.routing_type == '后置三元质量检测':
|
||||
print('后置三元检测')
|
||||
elif self.routing_type == '解除装夹':
|
||||
print("我是解除装夹")
|
||||
else:
|
||||
pass
|
||||
|
||||
else:
|
||||
self.pro_code_ok = workorder.pro_code_is_ok(barcode)
|
||||
# def on_barcode_scanned(self, barcode):
|
||||
# workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||
# if "*" not in barcode:
|
||||
# if self.routing_type == '装夹':
|
||||
# tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||
# self.tray_code = tray_code.code
|
||||
# self.tray_id = workorder.gettray_auto(barcode)
|
||||
# elif self.routing_type == '前置三元定位检测':
|
||||
# print('我是前置三元检测')
|
||||
# logging.info('我是前置三元检测')
|
||||
# elif self.routing_type == 'CNC加工':
|
||||
# if barcode == 'UP-ALL':
|
||||
# print("我是一键合并下发")
|
||||
# logging.info('我是一键合并下发')
|
||||
# self.up_merge_all()
|
||||
# else:
|
||||
# print('CNC加工')
|
||||
# # print(barcode)
|
||||
# # a = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||
# # print(a)
|
||||
# # # workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)], limit=1)
|
||||
# # workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)])
|
||||
# # e = workorder_obj.id
|
||||
# # print(workorder_obj)
|
||||
# # action = {
|
||||
# # 'name': '工单',
|
||||
# # 'type': 'ir.actions.act_window',
|
||||
# # # 'view_type': 'form',
|
||||
# # 'view_mode': 'form',
|
||||
# # 'res_model': 'mrp.workorder',
|
||||
# # 'view_id': self.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
|
||||
# # # 'res_id': workorder_obj.id,
|
||||
# # 'res_id': 1023,
|
||||
# # 'target': 'current',
|
||||
# # # 'context': self.env.context,
|
||||
# # # 'flags': {'initial_mode': 'edit'},
|
||||
# # }
|
||||
# # return action
|
||||
#
|
||||
# elif self.routing_type == '后置三元质量检测':
|
||||
# print('后置三元检测')
|
||||
# elif self.routing_type == '解除装夹':
|
||||
# print("我是解除装夹")
|
||||
# else:
|
||||
# pass
|
||||
#
|
||||
# else:
|
||||
# self.pro_code_ok = workorder.pro_code_is_ok(barcode)
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
# -*- 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
|
||||
#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
|
||||
# # -*- 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
|
||||
# #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
|
||||
|
||||
@@ -425,16 +425,16 @@
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
|
||||
<field name="tray_id" readonly="1"/>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"
|
||||
attrs='{"invisible": ["|","|",("tray_id","=",False),("state","!=","progress"),("user_permissions","=",False)]}'/>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"
|
||||
string="打印标签"
|
||||
attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
|
||||
</div>
|
||||
<!-- <field name="tray_id" readonly="1"/>-->
|
||||
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
|
||||
<!-- <button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"-->
|
||||
<!-- attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
|
||||
<!-- <button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"-->
|
||||
<!-- string="打印标签"-->
|
||||
<!-- attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||
<!-- </div>-->
|
||||
|
||||
</page>
|
||||
</xpath>
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
<?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>
|
||||
<!--<?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>
|
||||
<!-- </page>-->
|
||||
|
||||
</notebook>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
<!-- </notebook>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
<!-- </data>-->
|
||||
<!--</odoo>-->
|
||||
Reference in New Issue
Block a user