From 97d760cd5625b5025e301f6e2db278a12483055b Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 23 Nov 2023 17:15:34 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=9F=BA=E4=BA=8E=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E7=9A=84=E7=A7=BB=E5=8A=A8=E5=8E=86=E5=8F=B2=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=A8=A1=E5=9E=8B=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=88=97=E8=A1=A8=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=8C=89=E9=92=AE=EF=BC=9B3=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A7=E7=9A=84=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=92=8C=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=BA=BA=E6=A8=A1=E5=9E=8B=EF=BC=9B4=E3=80=81=E6=9C=BA?= =?UTF-8?q?=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=8D=95=EF=BC=9B?= =?UTF-8?q?5=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E5=8D=95=E7=A1=AE=E8=AE=A4=E7=BB=84?= =?UTF-8?q?=E8=A3=85=E5=8A=9F=E8=83=BD=E7=9A=84=E5=88=9B=E5=BB=BA=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/model_type.py | 9 +- .../models/production_line_base.py | 7 +- sf_plan_management/__init__.py | 2 +- sf_plan_management/models/__init__.py | 2 +- sf_plan_management/models/base.py | 4 - sf_tool_management/models/base.py | 169 ++++--------- .../security/ir.model.access.csv | 2 - sf_tool_management/views/menu_view.xml | 6 +- sf_tool_management/views/tool_base_views.xml | 231 ++++-------------- sf_tool_management/wizard/wizard.py | 35 ++- 10 files changed, 110 insertions(+), 357 deletions(-) diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index cfa5bea8..48707939 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -1,7 +1,4 @@ -from odoo import fields, models,api - - - +from odoo import fields, models, api class ModelType(models.Model): @@ -42,8 +39,6 @@ class ProductModelTypeRoutingSort(models.Model): # if record: # record.routing_type = record.route_workcenter_id.routing_type - - routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') @@ -77,7 +72,6 @@ class EmbryoModelTypeRoutingSort(models.Model): # if record: # record.routing_type = record.route_workcenter_id.routing_type - routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') @@ -111,7 +105,6 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model): # if record: # record.routing_type = record.route_workcenter_id.routing_type - routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') diff --git a/sf_manufacturing/models/production_line_base.py b/sf_manufacturing/models/production_line_base.py index 2cb704f0..f0ee5338 100644 --- a/sf_manufacturing/models/production_line_base.py +++ b/sf_manufacturing/models/production_line_base.py @@ -1,4 +1,4 @@ -from odoo import models,fields +from odoo import models, fields class ProductionLine(models.Model): @@ -26,8 +26,3 @@ class ProductionLine(models.Model): name = fields.Char('生产线', size=20, required=True) code = fields.Char('编码', default=_get_code, readonly=True) remark = fields.Char('备注') - - - - - diff --git a/sf_plan_management/__init__.py b/sf_plan_management/__init__.py index 9a7e03ed..0650744f 100644 --- a/sf_plan_management/__init__.py +++ b/sf_plan_management/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/sf_plan_management/models/__init__.py b/sf_plan_management/models/__init__.py index 9a2c9000..c58a46c7 100644 --- a/sf_plan_management/models/__init__.py +++ b/sf_plan_management/models/__init__.py @@ -1,2 +1,2 @@ from . import calendar_base -from . import base \ No newline at end of file +from . import base diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py index dffc0ef6..d1eff04a 100644 --- a/sf_plan_management/models/base.py +++ b/sf_plan_management/models/base.py @@ -44,7 +44,3 @@ class ProcedureEquipmentResourceSetting(models.Model): record.working_shift_id = record.working_calendar_id.working_shift_ids else: record.working_shift_id = None - - - - diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 14f463a0..7402632f 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -112,6 +112,12 @@ class FunctionalCuttingToolEntity(models.Model): result['domain'] = [('functional_tool_name_id', '=', self.functional_tool_name_id.id)] return result + def open_stock_move_line(self): + action = self.env.ref('sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_act') + result = action.read()[0] + result['domain'] = [('lot_id', '=', self.barcode_id.id), ('qty_done', '>', 0)] + return result + class FunctionalToolWarning(models.Model): _name = 'sf.functional.tool.warning' @@ -150,9 +156,27 @@ class FunctionalToolWarning(models.Model): return categories.browse(machine_table_name_ids) +class StockMoveLine(models.Model): + _inherit = 'stock.move.line' + _description = '功能刀具出入库记录' + + functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, + group_expand='_read_group_functional_tool_type_id', + 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("刀具组装时间") + + @api.model + def _read_group_functional_tool_type_id(self, categories, domain, order): + names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) + return categories.browse(names) + + class RealTimeDistributionOfFunctionalTools(models.Model): _name = 'sf.real.time.distribution.of.functional.tools' - _description = '功能刀具实时分布' + _description = '功能刀具安全库存' functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, @@ -171,12 +195,9 @@ class RealTimeDistributionOfFunctionalTools(models.Model): if record: record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id - # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) name = fields.Char('名称', invisible=True, readonly=True) functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) - # mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - # related='functional_cutting_tool_id.mrs_cutting_tool_type_id') # 整体式刀具型号 cutting_tool_integral_model_id = fields.Many2one( @@ -266,115 +287,6 @@ class RealTimeDistributionOfFunctionalTools(models.Model): self.total = record.tool_stock_total + record.return_total -class InboundAndOutboundRecordsOfFunctionalTools(models.Model): - _name = 'sf.inbound.and.outbound.records.of.functional.tools' - _description = '功能刀具出入库记录' - - functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) - mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - group_expand='_read_mrs_cutting_tool_type_ids', - store=True, - compute='_compute_functional_cutting_tool_ids') - - @api.model - def _read_mrs_cutting_tool_type_ids(self, categories, domain, order): - mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) - return categories.browse(mrs_cutting_tool_type_ids) - - @api.depends('functional_cutting_tool_id') - def _compute_functional_cutting_tool_ids(self): - for record in self: - if record: - record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id - - # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - name = fields.Char('名称', invisible=True, readonly=True) - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) - - # 整体式刀具型号 - cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '整体式刀具')]) - - # 刀片型号 - cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀片')]) - - # 刀杆型号 - cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀杆')]) - - # 刀盘型号 - cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀盘')]) - - # 刀柄型号 - cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀柄')]) - - # 夹头型号 - cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '夹头')]) - - diameter = fields.Float('直径(mm)', readonly=True) - tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') - machining_accuracy = fields.Float('加工精度(mm)', readonly=True) - tool_length = fields.Float('装刀长(mm)', readonly=True) - blade_number = fields.Integer('刃数', readonly=True) - integral_blade_length = fields.Float('整体刃长(mm)', readonly=True) - effective_blade_length = fields.Float('有效刃长(mm)', readonly=True) - max_life = fields.Float('最大寿命值', readonly=True) - is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀', readonly=True, - compute='_compute_functional_cutting_tool_id') - applicable_range = fields.Char('适用范围', readonly=True) - image = fields.Binary('图片', readonly=True) - - @api.depends('functional_cutting_tool_id') - def _compute_functional_cutting_tool_id(self): - if self.functional_cutting_tool_id: - self.tool_grade = self.functional_cutting_tool_id.tool_grade - self.is_standard = self.functional_cutting_tool_id.is_standard - - # 功能刀具出入库记录 特有字段 - current_state = fields.Char(string='当前状态', readonly=False) - current_store_area = fields.Char(string='当前库区', readonly=False) - current_store_place = fields.Char(string='当前库位', readonly=False) - tool_install_staff = fields.Char(string='装刀人', readonly=False) - tool_install_time = fields.Datetime(string='装刀时间', readonly=False) - thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False) - # max_life_span = fields.Char(string='最大寿命值', readonly=False) - alarm_value = fields.Char(string='报警值', readonly=False) - used_value = fields.Char(string='已使用值', readonly=False) - reason_application = fields.Char(string='申请原因', readonly=False) - applicant = fields.Char(string='申请人', readonly=False) - - inbound_and_outbound_records_ids = fields.One2many('sf.inbound.and.outbound.records', - 'inbound_and_outbound_tools_id', string='出入库记录') - - remark = fields.Char(string='备注/说明', readonly=False) - - -class InboundAndOutboundRecords(models.Model): - _name = 'sf.inbound.and.outbound.records' - _description = '出入库记录' - _order = 'id DESC' - - inbound_and_outbound_tools_id = fields.Many2one('sf.inbound.and.outbound.records.of.functional.tools', - string='功能刀具出入库记录') - - name = fields.Char(string='出入库记录') - tool_state = fields.Selection([('0', '领用出库'), ('1', '归还入库')], string="出入库类别", readonly=False) - receive_equipment = fields.Char(string='领用机台', readonly=False) - receive_staff = fields.Char(string='领用人', readonly=False) - receive_time = fields.Datetime(string='领用出库时间', readonly=False) - return_staff = fields.Char(string='归还人', readonly=False) - return_time = fields.Datetime(string='归还入库时间', readonly=False) - current_store_area = fields.Char(string='库区', readonly=False) - current_store_place = fields.Char(string='库位', readonly=False) - number = fields.Integer(string='数量', readonly=False) - - class MachineTableToolChangingApply(models.Model): _name = 'sf.machine.table.tool.changing.apply' _description = '机床换刀申请' @@ -390,12 +302,14 @@ class MachineTableToolChangingApply(models.Model): machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=False, required=True, domain="[('equipment_id', '=', maintenance_equipment_id)]") - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', - domain=[('product_id.name', '=', '功能刀具')]) - functional_tool_name = fields.Char(string='功能刀具名称') - functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', - domain=[('name', '=', '功能刀具')]) + functional_tool_name = fields.Char(string='刀具名称', related='functional_tool_name_id.name', store=True) + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', store=True, + domain=[('product_id.name', '=', '功能刀具')], + related='functional_tool_name_id.barcode_id') + functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, + related='functional_tool_name_id.functional_tool_type_id') + tool_position_interface_type = fields.Selection( [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), @@ -463,7 +377,7 @@ class MachineTableToolChangingApply(models.Model): :return: """ # 更新数据到机台换刀申请界面 - if self.functional_tool_status == '报警' and self.sf_functional_tool_assembly_id == False: + if self.functional_tool_status == '报警' and not self.sf_functional_tool_assembly_id: machine_table_tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( [('maintenance_equipment_id', '=', self.maintenance_equipment_id.id), ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id) @@ -601,9 +515,9 @@ class CAMWorkOrderProgramKnifePlan(models.Model): # 将计划执行状态改为执行中 self.env['sf.cam.work.order.program.knife.plan'].search( - [('barcode_id', '=', self.barcode_id.id)]).write({ - 'plan_execute_status': '1', - 'applicant': self.env.user.name}) + [('barcode_id', '=', self.barcode_id.id)]).write( + {'plan_execute_status': '1', + 'applicant': self.env.user.name}) def revocation(self): """ @@ -616,11 +530,10 @@ class CAMWorkOrderProgramKnifePlan(models.Model): # 将计划执行状态改为待执行,同时清除申请人、功能刀具组装字段数据 self.env['sf.cam.work.order.program.knife.plan'].search( - [('barcode_id', '=', self.barcode_id.id)]).write({ - 'plan_execute_status': '0', - 'applicant': None, - 'sf_functional_tool_assembly_id': None, - }) + [('barcode_id', '=', self.barcode_id.id)]).write( + {'plan_execute_status': '0', + 'applicant': None, + 'sf_functional_tool_assembly_id': None}) class FunctionalToolAssembly(models.Model): diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index fa10d0c5..cc72f699 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -2,8 +2,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1 access_sf_functional_tool_warning,sf.functional.tool.warning,model_sf_functional_tool_warning,base.group_user,1,1,1,1 access_sf_real_time_distribution_of_functional_tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,base.group_user,1,1,1,1 -access_sf_inbound_and_outbound_records_of_functional_tools,sf.inbound.and.outbound.records.of.functional.tools,model_sf_inbound_and_outbound_records_of_functional_tools,base.group_user,1,1,1,1 -access_sf_inbound_and_outbound_records,sf.inbound.and.outbound.records,model_sf_inbound_and_outbound_records,base.group_user,1,1,1,1 access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,base.group_user,1,1,1,1 access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,base.group_user,1,1,1,1 diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index efa4feee..c1fc939b 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -25,15 +25,15 @@ /> -

@@ -416,136 +424,43 @@ 功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools + stock.move.line - - - - - - - - - - - - - + + + + + + + + + + + - - 功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools - -
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools + stock.move.line - + + - - - - - - - - - - - + + + + + + + + - + @@ -554,62 +469,13 @@ 功能刀具出入库记录 ir.actions.act_window - sf.inbound.and.outbound.records.of.functional.tools - tree,form,search - - - - - - 出入库记录 - sf.inbound.and.outbound.records - - - - - - - - - - - - - - - - - 出入库记录 - sf.inbound.and.outbound.records - -
- - - - - - - - - - - - - - - - - - -
-
-
- - - 出入库记录 - ir.actions.act_window - sf.inbound.and.outbound.records - tree,form + stock.move.line + tree,search + + + [('functional_tool_name_id', '!=', False)] @@ -624,7 +490,7 @@ - + @@ -639,9 +505,8 @@ - - +