1、新增功能刀具拆解模型及其前端的tree、form视图,新增扫码录入需要拆解的功能刀具功能;

This commit is contained in:
yuxianghui
2024-04-19 20:12:32 +08:00
parent 1a860a5eb9
commit 857d5d8916
5 changed files with 309 additions and 31 deletions

View File

@@ -423,7 +423,8 @@ class FunctionalToolAssembly(models.Model):
def _compute_integral_product_id(self):
for item in self:
if item.integral_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.integral_freight_barcode)])
location = self.env['sf.shelf.location'].sudo().search(
[('barcode', '=', item.integral_freight_barcode)])
if location:
item.integral_product_id = location.product_id.id
else:
@@ -442,7 +443,7 @@ class FunctionalToolAssembly(models.Model):
@api.depends('blade_freight_barcode')
def _compute_blade_product_id(self):
for item in self:
if item.integral_freight_barcode:
if item.blade_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)])
if location:
item.blade_product_id = location.product_id.id
@@ -462,7 +463,7 @@ class FunctionalToolAssembly(models.Model):
@api.depends('bar_freight_barcode')
def _compute_bar_product_id(self):
for item in self:
if item.integral_freight_barcode:
if item.bar_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)])
if location:
item.bar_product_id = location.product_id.id
@@ -482,7 +483,7 @@ class FunctionalToolAssembly(models.Model):
@api.depends('pad_freight_barcode')
def _compute_pad_product_id(self):
for item in self:
if item.integral_freight_barcode:
if item.pad_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)])
if location:
item.pad_product_id = location.product_id.id
@@ -523,7 +524,7 @@ class FunctionalToolAssembly(models.Model):
@api.depends('chuck_freight_barcode')
def _compute_chuck_product_id(self):
for item in self:
if item.integral_freight_barcode:
if item.chuck_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)])
if location:
item.chuck_product_id = location.product_id.id
@@ -631,3 +632,120 @@ class FunctionalToolAssembly(models.Model):
code = self._get_code(obj.loading_task_source)
obj.assembly_order_code = code
return obj
class FunctionalToolDismantle(models.Model):
_name = 'sf.functional.tool.dismantle'
_inherit = ["barcodes.barcode_events_mixin"]
_description = '功能刀具拆解'
def on_barcode_scanned(self, barcode):
"""
扫码
"""
tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', barcode)])
if tool_id:
self.functional_tool_id = tool_id.id
else:
pass
name = fields.Char('名称', related='functional_tool_id.name')
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
domain=[('functional_tool_status', '!=', '已拆除')])
tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
compute='_compute_functional_tool_num')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True)
diameter = fields.Integer(string='刀具直径(mm)', compute='_compute_functional_tool_num', store=True)
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_functional_tool_num', store=True)
rfid = fields.Char('Rfid', compute='_compute_functional_tool_num', store=True)
dismantle_cause = fields.Selection(
[('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'),
('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True)
dismantle_data = fields.Datetime('拆解日期', readonly=True)
dismantle_person = fields.Char('拆解人', readonly=True)
image = fields.Binary('图片', readonly=True)
scrap_id = fields.Char('报废单号')
grinding_id = fields.Char('磨削单号')
# 刀柄
handle_product_id = fields.Many2one('product.product', string='刀柄', compute='_compute_functional_tool_num',
store=True)
handle_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
related='handle_product_id.cutting_tool_model_id')
handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id')
handle_rfid = fields.Char(string='刀柄Rfid')
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False)
# 整体式
integral_product_id = fields.Many2one('product.product', string='整体式刀具',
compute='_compute_functional_tool_num', store=True)
integral_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
related='integral_product_id.cutting_tool_model_id')
integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
related='integral_product_id.brand_id')
integral_freight_barcode = fields.Char('整体式刀具目标货位')
# 刀片
blade_product_id = fields.Many2one('product.product', string='刀片', compute='_compute_functional_tool_num',
store=True)
blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
related='blade_product_id.cutting_tool_model_id')
blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id')
blade_freight_barcode = fields.Char('刀片目标货位')
# 刀杆
bar_product_id = fields.Many2one('product.product', string='刀杆', compute='_compute_functional_tool_num',
store=True)
bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
related='bar_product_id.cutting_tool_model_id')
bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id')
bar_freight_barcode = fields.Char('刀杆目标货位')
# 刀盘
pad_product_id = fields.Many2one('product.product', string='刀盘', compute='_compute_functional_tool_num',
store=True)
pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
related='pad_product_id.cutting_tool_model_id')
pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id')
pad_freight_barcode = fields.Char('刀盘目标货位')
# 夹头
chuck_product_id = fields.Many2one('product.product', string='夹头', compute='_compute_functional_tool_num',
store=True)
chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
related='chuck_product_id.cutting_tool_model_id')
chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id')
chuck_freight_barcode = fields.Char('夹头目标货位')
@api.depends('functional_tool_id')
def _compute_functional_tool_num(self):
for item in self:
if item.functional_tool_id:
item.tool_groups_id = item.functional_tool_id.tool_groups_id.id
item.tool_type_id = item.functional_tool_id.sf_cutting_tool_type_id.id
item.diameter = item.functional_tool_id.functional_tool_diameter
item.knife_tip_r_angle = item.functional_tool_id.knife_tip_r_angle
item.rfid = item.functional_tool_id.rfid
item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id
item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id
item.blade_product_id = item.functional_tool_id.functional_tool_name_id.blade_product_id.id
item.bar_product_id = item.functional_tool_id.functional_tool_name_id.bar_product_id.id
item.pad_product_id = item.functional_tool_id.functional_tool_name_id.pad_product_id.id
item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id
else:
item.tool_groups_id = False
item.tool_type_id = False
item.diameter = 0
item.knife_tip_r_angle = 0
item.rfid = ''
item.handle_product_id = False
item.integral_product_id = False
item.blade_product_id = False
item.bar_product_id = False
item.pad_product_id = False
item.chuck_product_id = False

View File

@@ -31,3 +31,7 @@ access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model
access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_order_user,1,0,0,0
access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0
access_sf_functional_tool_dismantle_group_sf_tool_user,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_sf_tool_user,1,1,1,0
access_sf_functional_tool_dismantle_group_plan_dispatch,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_plan_dispatch,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
31
32
33
34
35
36
37

View File

@@ -78,5 +78,13 @@
parent="menu_sf_tool_manage"
/>
<menuitem
sequence="5"
name="功能刀具拆解"
id="menu_sf_functional_tool_dismantle"
action="sf_functional_tool_dismantle_view_act"
parent="menu_sf_tool_manage"
/>
</data>
</odoo>

View File

@@ -766,5 +766,148 @@
<field name="search_view_id" ref="sf_functional_tool_assembly_search"/>
<field name="context">{'search_default_no_assemble_status':1}</field>
</record>
<!--================================================功能刀具拆解================================================-->
<record id="sf_functional_tool_dismantle_tree" model="ir.ui.view">
<field name="name">功能刀具拆解</field>
<field name="model">sf.functional.tool.dismantle</field>
<field name="arch" type="xml">
<tree create="1">
<field name="rfid"/>
<field name="functional_tool_id"/>
<field name="tool_type_id" invisible="1"/>
<field name="tool_groups_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="dismantle_cause"/>
<field name="dismantle_data"/>
<field name="dismantle_person"/>
</tree>
</field>
</record>
<record id="sf_functional_tool_dismantle_form" model="ir.ui.view">
<field name="name">功能刀具拆解</field>
<field name="model">sf.functional.tool.dismantle</field>
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_title">
<h1>
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
options="{'no_create': True}"/>
</h1>
</div>
<field name="_barcode_scanned" widget="barcode_handler"/>
<group>
<group>
<field name="rfid"/>
<field name="tool_type_id"/>
<field name="tool_groups_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="dismantle_cause" placeholder="请选择拆解原因"/>
</group>
<group>
<field name="image"/>
</group>
</group>
<notebook>
<page string="物料组装信息">
<group string="刀柄">
<group>
<field name="handle_product_id" string="名称"/>
<field name="handle_type_id" string="型号"/>
<field name="handle_brand_id" string="品牌"/>
</group>
<group>
<field name="handle_rfid" string="Rfid"/>
</group>
</group>
<group string="整体式刀具">
<group>
<field name="integral_product_id" string="名称"/>
<field name="integral_type_id" string="型号"/>
<field name="integral_brand_id" string="品牌"/>
</group>
<group>
<field name="integral_freight_barcode" string="目标货位"/>
</group>
</group>
<group string="刀片">
<group>
<field name="blade_product_id" string="名称"/>
<field name="blade_type_id" string="型号"/>
<field name="blade_brand_id" string="品牌"/>
</group>
<group>
<field name="blade_freight_barcode" string="目标货位"/>
</group>
</group>
<group string="刀杆">
<group>
<field name="bar_product_id" string="名称"/>
<field name="bar_type_id" string="型号"/>
<field name="bar_brand_id" string="品牌"/>
</group>
<group>
<field name="bar_freight_barcode" string="目标货位"/>
</group>
</group>
<group string="刀盘">
<group>
<field name="pad_product_id" string="名称"/>
<field name="pad_type_id" string="型号"/>
<field name="pad_brand_id" string="品牌"/>
</group>
<group>
<field name="pad_freight_barcode" string="目标货位"/>
</group>
</group>
<group string="夹头">
<group>
<field name="chuck_product_id" string="名称"/>
<field name="chuck_type_id" string="型号"/>
<field name="chuck_brand_id" string="品牌"/>
</group>
<group>
<field name="chuck_freight_barcode" string="目标货位"/>
</group>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="sf_functional_tool_dismantle_search" model="ir.ui.view">
<field name="model">sf.functional.tool.dismantle</field>
<field name="arch" type="xml">
<search>
<field name="functional_tool_id"/>
<searchpanel>
<field name="tool_groups_id" enable_counters="1" icon="fa-filter"/>
<field name="tool_type_id" enable_counters="1" icon="fa-filter"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_functional_tool_dismantle_view_act" model="ir.actions.act_window">
<field name="name">功能刀具拆解</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.tool.dismantle</field>
<field name="view_mode">tree,form,search</field>
<!-- <field name="search_view_id" ref="sf_functional_tool_dismantle_search"/>-->
<!-- <field name="context">{'search_default_no_assemble_status':1}</field>-->
</record>
</data>
</odoo>

View File

@@ -243,11 +243,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
@api.depends('integral_freight_barcode')
def _compute_integral_product_id(self):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
if location:
self.integral_product_id = location.product_id.id
else:
self.integral_product_id = False
if self.integral_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
if location:
self.integral_product_id = location.product_id.id
else:
self.integral_product_id = False
# ===============刀片型号====================
blade_freight_barcode = fields.Char('刀片货位')
@@ -261,11 +262,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
@api.depends('blade_freight_barcode')
def _compute_blade_product_id(self):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
if location:
self.blade_product_id = location.product_id.id
else:
self.blade_product_id = False
if self.blade_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
if location:
self.blade_product_id = location.product_id.id
else:
self.blade_product_id = False
# ====================刀杆型号==================
bar_freight_barcode = fields.Char('刀杆货位')
@@ -279,11 +281,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
@api.depends('bar_freight_barcode')
def _compute_bar_product_id(self):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
if location:
self.bar_product_id = location.product_id.id
else:
self.bar_product_id = False
if self.bar_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
if location:
self.bar_product_id = location.product_id.id
else:
self.bar_product_id = False
# ===============刀盘型号===================
pad_freight_barcode = fields.Char('刀盘货位')
@@ -297,11 +300,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
@api.depends('pad_freight_barcode')
def _compute_pad_product_id(self):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
if location:
self.pad_product_id = location.product_id.id
else:
self.pad_product_id = False
if self.pad_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
if location:
self.pad_product_id = location.product_id.id
else:
self.pad_product_id = False
# ================刀柄型号===============
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid')
@@ -335,11 +339,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
@api.depends('chuck_freight_barcode')
def _compute_chuck_product_id(self):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
if location:
self.chuck_product_id = location.product_id.id
else:
self.chuck_product_id = False
if self.chuck_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
if location:
self.chuck_product_id = location.product_id.id
else:
self.chuck_product_id = False
# ========================================