Accept Merge Request #719: (feature/刀具管理模块安装时更新数据 -> develop)

Merge Request: 1、新增刀具管理模块安装时根据已有机床设备存在的刀位创建机台换刀申请记录   

Created By: @禹翔辉
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/719
This commit is contained in:
禹翔辉
2023-12-11 14:48:37 +08:00
committed by Coding
3 changed files with 27 additions and 17 deletions

View File

@@ -2,19 +2,18 @@
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()
from odoo import api, SUPERUSER_ID
import logging
_logger = logging.getLogger(__name__)
def _post_install(cr, registry):
# 这里执行你想要在安装模块时执行的操作,包括调用和执行模型的方法
env = api.Environment(cr, SUPERUSER_ID, {})
# 获取需要执行方法的模型
model_obj = env['sf.machine.table.tool.changing.apply']
# 调用模型方法
model_obj.create_tool_change_application()

View File

@@ -21,6 +21,7 @@
],
'demo': [
],
'post_init_hook': '_post_install',
'assets': {
'web.assets_qweb': [

View File

@@ -477,7 +477,17 @@ class MachineTableToolChangingApply(models.Model):
[('name', '=', self.name.id)]).write({'status': '0'})
def create_tool_change_application(self):
print("调用了create_tool_change_application()")
maintenance_equipment_ids = self.env['maintenance.equipment'].sudo().search(
[('product_template_ids', '!=', False)])
tool_changing_apply = self.env['sf.machine.table.tool.changing.apply']
if maintenance_equipment_ids:
for maintenance_equipment_id in maintenance_equipment_ids:
if maintenance_equipment_id.product_template_ids:
for product_template_id in maintenance_equipment_id.product_template_ids:
tool_changing_apply.sudo().create({
'maintenance_equipment_id': product_template_id.equipment_id.id,
'cutter_spacing_code_id': product_template_id.id
})
class CAMWorkOrderProgramKnifePlan(models.Model):