Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/权限去掉继承

This commit is contained in:
jinling.yang
2023-12-11 14:47:34 +08:00
parent e300ca1822
commit 6bf3df0ef4
18 changed files with 996 additions and 441 deletions

View File

@@ -1,3 +1,20 @@
# -*-coding:utf-8-*-
from . import models
from . import wizard
# from odoo import api, SUPERUSER_ID
# import logging
# _logger = logging.getLogger(__name__)
#
#
# def _sf_tool_management_post_install(cr, registry):
# # 这里执行你想要在安装模块时执行的操作,包括调用和执行模型的方法
# env = api.Environment(cr, SUPERUSER_ID, {})
#
# # 获取需要执行方法的模型
# model_obj = env['sf.machine.table.tool.changing.apply']
# logging.info('post_install方法执行了')
# print('post_install方法执行了')
#
# # 调用模型方法
# model_obj.create_tool_change_application()

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- <record model="sf.machine.table.tool.changing.apply" id="sf_create_tool_change_application">-->
<!-- </record>-->
</data>
</odoo>

View File

@@ -1,2 +1,4 @@
from . import base
from . import tool_material_search
from . import maintenance_equipment

View File

@@ -41,13 +41,10 @@ class FunctionalCuttingToolEntity(models.Model):
def _compute_current_location_id(self):
for record in self:
if record.barcode_id.quant_ids:
print(record.barcode_id.quant_ids)
for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0:
print(quant_id)
record.current_location_id = quant_id.location_id
record.current_location = quant_id.location_id.name
print(record.current_location_id)
if record.current_location_id:
record.get_location_num()
else:
@@ -161,7 +158,7 @@ class FunctionalToolWarning(models.Model):
production_line_id = fields.Many2one('sf.production.line', string='生产线',
group_expand='_read_group_machine_table_name_ids')
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床')
machine_tool_code = fields.Char(string='机台号')
machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name')
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号',
domain="[('equipment_id', '=', maintenance_equipment_id)]")
@@ -222,7 +219,7 @@ class StockMoveLine(models.Model):
related='functional_tool_name_id.functional_tool_type_id')
diameter = fields.Integer(string='刀具直径(mm)', related='functional_tool_name_id.functional_tool_diameter')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle')
install_tool_time = fields.Datetime("刀具组装时间")
install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time')
@api.model
def _read_group_functional_tool_type_id(self, categories, domain, order):
@@ -339,7 +336,7 @@ class MachineTableToolChangingApply(models.Model):
group_expand='_read_group_names')
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True,
compute='_compute_machine_table_type_id')
machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True)
machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True,
required=True, domain="[('equipment_id', '=', maintenance_equipment_id)]")
# 功能刀具信息
@@ -355,7 +352,7 @@ class MachineTableToolChangingApply(models.Model):
[('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'),
('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'),
('直装固定式', '直装固定式')], string='刀位接口型号')
diameter = fields.Integer(string='刀具直径(mm)', )
diameter = fields.Integer(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
max_lifetime_value = fields.Integer(string='最大寿命值(min)')
alarm_value = fields.Integer(string='报警值(min)')
@@ -479,6 +476,9 @@ class MachineTableToolChangingApply(models.Model):
self.env['sf.machine.table.tool.changing.apply'].search(
[('name', '=', self.name.id)]).write({'status': '0'})
def create_tool_change_application(self):
print("调用了create_tool_change_application()")
class CAMWorkOrderProgramKnifePlan(models.Model):
_name = 'sf.cam.work.order.program.knife.plan'
@@ -487,39 +487,49 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
name = fields.Char(string='工单任务编号', readonly=False)
cam_procedure_code = fields.Char(string='CAM程序编号', readonly=False)
cam_cutter_spacing_code = fields.Char(string='CAM刀位号', readonly=False)
tool_position_interface_type = fields.Selection(
[('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'),
('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'),
('直装固定式', '直装固定式')], string='刀位接口型号')
production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=False,
group_expand='_read_group_names')
machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=False,
domain="[('production_line_id', '=', production_line_id)]")
machine_table_name = fields.Char(string='机台号', readonly=True, related='machine_table_name_id.name')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', required=True,
domain="[('equipment_id', '=', machine_table_name_id)]")
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True)
need_knife_time = fields.Datetime(string='用刀时间', readonly=False)
applicant = fields.Char(string='申请人', readonly=True)
applicant_time = fields.Datetime(string='申请时间', readonly=True)
reason_for_applying = fields.Char(string='申请原因', readonly=False)
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号',
domain=[('product_id.name', '=', '功能刀具')])
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称',
domain=[('name', '=', '功能刀具')])
functional_tool_name = fields.Char(string='功能刀具名称', required=True)
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False)
machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=False,
group_expand='_read_group_machine_table_name_ids')
diameter = fields.Integer(string='刀具直径(mm)', readonly=False)
tool_included_angle = fields.Float(string='刀尖R角(mm)', readonly=False)
tool_loading_length = fields.Float(string='装刀长(mm)', readonly=False)
extension_length = fields.Float(string='伸出长(mm)')
effective_length = fields.Float(string='有效长(mm)')
new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', readonly=False, default='0')
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], default='3',
string='粗/中/精', readonly=False)
L_D = fields.Float(string='L/D值', readonly=False)
clearance_length = fields.Float(string='避空长(mm)', readonly=False)
required_cutting_time = fields.Integer(string='需切削时长', readonly=False)
@api.model
def _read_group_machine_table_name_ids(self, categories, domain, order):
machine_table_name_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(machine_table_name_ids)
machine_tool_cutter_spacing_code = fields.Char(string='机床刀位号', readonly=False)
diameter = fields.Char(string='直径(程式)(mm)', readonly=False)
tool_loading_length = fields.Char(string='装刀长(mm)', readonly=False)
clearance_length = fields.Char(string='避空长(mm)', readonly=False)
tool_included_angle = fields.Char(string='刀尖角R角', readonly=False)
L_D = fields.Char(string='L/D', readonly=False)
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], string='粗/中/精', readonly=False,
default='2')
required_cutting_time = fields.Char(string='需切削时长', readonly=False)
whether_standard_tool = fields.Selection([('1', ''), ('0', '')], string='是否标准刀', readonly=False,
default='1')
need_knife_time = fields.Datetime(string='需要用刀时间', readonly=False)
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
string='计划执行状态', default='0', readonly=False)
applicant = fields.Char(string='申请人', readonly=True)
reason_for_applying = fields.Char(string='申请原因', readonly=False)
remark = fields.Char(string='备注说明', readonly=False)
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
@api.model
def _read_group_names(self, categories, domain, order):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(names)
def apply_for_tooling(self):
"""
申请装刀

View File

@@ -0,0 +1,15 @@
from odoo import models, api
class SfMaintenanceEquipmentTool(models.Model):
_inherit = 'maintenance.equipment.tool'
@api.model_create_multi
def create(self, vals_list):
tools = super().create(vals_list)
for tool in tools:
self.env['sf.machine.table.tool.changing.apply'].sudo().create({
'maintenance_equipment_id': tool.equipment_id.id,
'cutter_spacing_code_id': tool.id
})
return tools

View File

@@ -347,11 +347,13 @@
</group>
<group>
<group string="走刀方向">
<field name="cutting_direction_ids" string="" widget="custom_many2many_checkboxes" readonly="1"
<field name="cutting_direction_ids" string="" widget="custom_many2many_checkboxes"
readonly="1"
domain="[('id','in',cutting_direction_ids)]"/>
</group>
<group string="适合冷却液">
<field name="suitable_coolant_ids" string="" widget="custom_many2many_checkboxes" readonly="1"
<field name="suitable_coolant_ids" string="" widget="custom_many2many_checkboxes"
readonly="1"
domain="[('id','in',suitable_coolant_ids)]"/>
</group>
</group>
@@ -478,7 +480,7 @@
<tree create="0" delete="0">
<field name="name" invisible="1"/>
<field name="production_line_id" invisible="1"/>
<field name="maintenance_equipment_id"/>
<field name="maintenance_equipment_id" invisible="1"/>
<field name="machine_tool_code"/>
<field name="cutter_spacing_code_id"/>
<field name="functional_tool_name_id"/>
@@ -531,7 +533,7 @@
'default_replacement_extension_length': extension_length,
'default_replacement_effective_length': effective_length,
}"
attrs="{'invisible': [('status', '!=', '0')]}"
attrs="{'invisible': ['|',('status', '!=', '0'), ('functional_tool_name_id', '=', False)]}"
class="btn-primary"
/>
<button string="转移"
@@ -557,7 +559,7 @@
'default_effective_length': effective_length,
}"
class="btn-primary"
attrs="{'invisible': [('status', '!=', '0')]}"
attrs="{'invisible': ['|',('status', '!=', '0'), ('functional_tool_name_id', '=', False)]}"
/>
<button string="撤回换刀申请" name="revocation_1" type="object" class="btn-primary"
attrs="{'invisible': [('status', '!=', '1')]}" confirm="是否确认撤回换刀申请"/>
@@ -605,7 +607,7 @@
'default_replacement_extension_length': extension_length,
'default_replacement_effective_length': effective_length,
}"
attrs="{'invisible': [('status', '!=', '0')]}"
attrs="{'invisible': ['|',('status', '!=', '0'), ('functional_tool_name_id', '=', False)]}"
class="btn-primary"
/>
<button string="转移"
@@ -631,7 +633,7 @@
'default_effective_length': effective_length,
}"
class="btn-primary"
attrs="{'invisible': [('status', '!=', '0')]}"/>
attrs="{'invisible': ['|',('status', '!=', '0'),('functional_tool_name_id', '=', False)]}"/>
<button string="撤回换刀申请" name="revocation_1" type="object" class="btn-primary"
attrs="{'invisible': [('status', '!=', '1')]}" confirm="是否确认撤回换刀申请"/>
<button string="撤回转移" name="revocation_2" type="object" class="btn-primary"
@@ -663,7 +665,8 @@
<group>
<group>
<field name="barcode_id"/>
<field name="functional_tool_name_id"/>
<field name="functional_tool_name_id"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="functional_tool_type_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
@@ -727,20 +730,23 @@
<field name="model">sf.cam.work.order.program.knife.plan</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="name" string="工单编码"/>
<field name="cam_procedure_code"/>
<field name="cam_cutter_spacing_code"/>
<field name="machine_table_name_id"/>
<field name="functional_tool_name_id"/>
<field name="functional_tool_type_id"/>
<field name="machine_tool_cutter_spacing_code"/>
<field name="production_line_id" invisible="1"/>
<field name="machine_table_name_id" invisible="1"/>
<field name="machine_table_name"/>
<field name="functional_tool_name"/>
<field name="diameter"/>
<field name="tool_included_angle"/>
<field name="need_knife_time"/>
<field name="applicant"/>
<field name="remark" optional="hide"/>
<field name="plan_execute_status" invisible="True"/>
<button string="申请装刀" name="apply_for_tooling" type="object" class="btn-primary"
attrs="{'invisible': [('plan_execute_status', '!=', '0')]}" confirm="是否确认申请装刀"/>
<button string="撤回" name="revocation" type="object" class="btn-primary"
attrs="{'invisible': [('plan_execute_status', '!=', '1')]}" confirm="是否确认撤回装刀"/>
<field name="applicant_time"/>
<field name="plan_execute_status" invisible="0"/>
<!-- <button string="申请装刀" name="apply_for_tooling" type="object" class="btn-primary"-->
<!-- attrs="{'invisible': [('plan_execute_status', '!=', '0')]}" confirm="是否确认申请装刀"/>-->
<!-- <button string="撤回" name="revocation" type="object" class="btn-primary"-->
<!-- attrs="{'invisible': [('plan_execute_status', '!=', '1')]}" confirm="是否确认撤回装刀"/>-->
</tree>
</field>
</record>
@@ -750,13 +756,13 @@
<field name="model">sf.cam.work.order.program.knife.plan</field>
<field name="arch" type="xml">
<form>
<header>
<button string="申请装刀" name="apply_for_tooling" type="object" class="btn-primary"
attrs="{'invisible': [('plan_execute_status', '!=', '0')]}" confirm="是否确认申请装刀"/>
<button string="撤回" name="revocation" type="object" class="btn-primary"
attrs="{'invisible': [('plan_execute_status', '!=', '1')]}" confirm="是否确认撤回装刀"/>
<field name="plan_execute_status" widget="statusbar" statusbar_visible="0,1,2"/>
</header>
<!-- <header>-->
<!-- <button string="申请装刀" name="apply_for_tooling" type="object" class="btn-primary"-->
<!-- attrs="{'invisible': [('plan_execute_status', '!=', '0')]}" confirm="是否确认申请装刀"/>-->
<!-- <button string="撤回" name="revocation" type="object" class="btn-primary"-->
<!-- attrs="{'invisible': [('plan_execute_status', '!=', '1')]}" confirm="是否确认撤回装刀"/>-->
<!-- <field name="plan_execute_status" widget="statusbar" statusbar_visible="0,1,2"/>-->
<!-- </header>-->
<sheet>
<div class="oe_title">
@@ -768,44 +774,34 @@
<group>
<field name="cam_procedure_code"/>
<field name="cam_cutter_spacing_code"/>
<field name="tool_position_interface_type" placeholder="请选择"/>
<field name="production_line_id" placeholder="请选择"/>
<field name="machine_table_name_id" placeholder="请选择"/>
<field name="machine_tool_cutter_spacing_code"/>
<field name="machine_table_name"/>
<field name="cutter_spacing_code_id" placeholder="请选择"/>
<field name="whether_standard_knife"/>
<field name="need_knife_time"/>
<field name="applicant"/>
<field name="applicant_time"/>
<field name="reason_for_applying"/>
<field name="sf_functional_tool_assembly_id" string="组装单"/>
</group>
<group>
<field name="barcode_id"/>
<field name="functional_tool_name_id" placeholder="请选择"/>
<field name="barcode_id" invisible="1"/>
<field name="functional_tool_name"/>
<field name="functional_tool_type_id" placeholder="请选择"/>
<field name="diameter"/>
<field name="tool_included_angle"/>
<field name="tool_loading_length"/>
<field name="extension_length"/>
<field name="effective_length"/>
<field name="new_former"/>
<field name="coarse_middle_thin"/>
<field name="L_D"/>
<field name="clearance_length"/>
<field name="required_cutting_time"/>
</group>
</group>
<notebook>
<page string="数据信息">
<group>
<group>
<field name="diameter"/>
<field name="tool_loading_length"/>
<field name="clearance_length"/>
<field name="tool_included_angle"/>
<field name="L_D"/>
<field name="coarse_middle_thin"/>
</group>
<group>
<field name="need_knife_time" placeholder="请选择"/>
<field name="required_cutting_time"/>
<field name="whether_standard_tool"/>
<field name="applicant"/>
<field name="reason_for_applying"/>
</group>
</group>
</page>
<page string="其他">
<group>
<group>
<field name="remark"/>
</group>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
@@ -815,15 +811,21 @@
<field name="model">sf.cam.work.order.program.knife.plan</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="name" string="工单编码"/>
<field name="cam_procedure_code"/>
<field name="cam_cutter_spacing_code"/>
<field name="machine_table_name_id"/>
<field name="functional_tool_name_id"/>
<field name="functional_tool_type_id"/>
<field name="machine_tool_cutter_spacing_code"/>
<field name="machine_table_name_id" invisible="1"/>
<field name="production_line_id" invisible="1"/>
<field name="machine_table_name"/>
<field name="functional_tool_name"/>
<field name="diameter"/>
<field name="tool_included_angle"/>
<field name="need_knife_time"/>
<field name="applicant"/>
<field name="applicant_time"/>
<field name="plan_execute_status" invisible="0"/>
<searchpanel>
<field name="production_line_id" string="生产线" enable_counters="1" icon="fa-filter"/>
<field name="machine_table_name_id" string="CNC机床" enable_counters="1" icon="fa-filter"/>
</searchpanel>
</search>

View File

@@ -378,7 +378,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 创建功能刀具批次/序列号记录
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly)
# 创建刀具组装入库单
self.create_stocking_picking(stock_lot)
self.create_stocking_picking(stock_lot, functional_tool_assembly)
# 刀具物料出库
if self.integral_code_id:
product_id.tool_material_stock_moves(self.integral_code_id)
@@ -436,7 +436,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
if not self.bar_code_id and not self.pad_code_id:
raise ValidationError('【刀盘】和【刀杆】必须填写一个!')
def create_stocking_picking(self, stock_lot):
def create_stocking_picking(self, stock_lot, functional_tool_assembly):
"""
创建刀具组装入库单
"""
@@ -450,7 +450,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
self.env['stock.move.line'].create({
'picking_id': picking_id.id,
'product_id': stock_lot.product_id.id,
'lot_id': stock_lot.id
'lot_id': stock_lot.id,
'functional_tool_name_id': functional_tool_assembly.id
})
# 将刀具组装入库单的状态更改为就绪
picking_id.action_confirm()
@@ -572,7 +573,6 @@ class ProductProduct(models.Model):
"""
# 获取位置对象
location_inventory_id = tool_material.quant_ids.location_id[-1]
print(location_inventory_id)
stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None)

View File

@@ -36,7 +36,8 @@
<group string="待换功能刀具信息">
<group>
<field name="replacement_tool_name" string="功能刀具名称"/>
<field name="replacement_tool_type_id" string="功能刀具类型"/>
<field name="replacement_tool_type_id" string="功能刀具类型"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="replacement_diameter" string="刀具直径(mm)"/>
<field name="replacement_knife_tip_r_angle" string="刀尖R角(mm)"/>
<field name="replacement_tool_setting_length" string="装刀长(mm)"/>
@@ -335,7 +336,8 @@
<group>
<field name="barcode_id" readonly="True"/>
<field name="after_assembly_functional_tool_name" string="功能刀具名称"/>
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型"/>
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)"/>
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"/>
<field name="after_assembly_new_former" string="新/旧"/>