diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 3aa85ceb..7977ed80 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -329,7 +329,7 @@ class ToolInventory(models.Model): blade_number = fields.Integer('刃数(个)') extension = fields.Float('伸出长度(mm)') work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料') - life_span = fields.Float('寿命(h)') + life_span = fields.Float('寿命(min)') tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组') diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index f3e156f8..4e610165 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -49,6 +49,7 @@ access_sf_functional_cutting_tool_admin,sf_functional_cutting_tool_admin,model_s access_sf_functional_cutting_tool_model,sf_functional_cutting_tool_model,model_sf_functional_cutting_tool_model,base.group_user,1,1,1,0 access_sf_functional_cutting_tool_model_admin,sf_functional_cutting_tool_model_admin,model_sf_functional_cutting_tool_model,base.group_system,1,1,1,0 access_sf_fixture_material,sf_fixture_material,model_sf_fixture_material,base.group_user,1,1,1,0 +access_sf_fixture_material_group_sf_stock_user,sf_fixture_material_group_sf_stock_user,model_sf_fixture_material,sf_warehouse.group_sf_stock_user,1,1,1,0 access_sf_fixture_material_admin,sf_fixture_material_admin,model_sf_fixture_material,base.group_system,1,1,1,0 access_sf_fixture_materials_basic_parameters,sf_fixture_materials_basic_parameters,model_sf_fixture_materials_basic_parameters,base.group_user,1,1,1,0 access_sf_fixture_materials_basic_parameters_admin,sf_fixture_materials_basic_parameters_admin,model_sf_fixture_materials_basic_parameters,base.group_system,1,1,1,0 diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py index c740869a..d755c7be 100644 --- a/sf_bf_connect/models/jd_eclp.py +++ b/sf_bf_connect/models/jd_eclp.py @@ -164,8 +164,8 @@ class JdEclp(models.Model): self.is_bill = True self.logistics_status = '1' - # 京东物流下单后,销售订单状态改为待收货 - self.env['sale.order'].search([('name', '=', self.origin)]).write({'scheduled_status': 'to receive'}) + # # 京东物流下单后,销售订单状态改为待收货 + # self.env['sale.order'].search([('name', '=', self.origin)]).write({'scheduled_status': 'to receive'}) # else: # raise UserError("选择京东物流才能下单呦") diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml index 94fc6b45..8842f8bf 100644 --- a/sf_dlm_management/views/product_template_management_view.xml +++ b/sf_dlm_management/views/product_template_management_view.xml @@ -32,6 +32,7 @@ attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}" placeholder="请选择"/> @@ -39,6 +40,7 @@ @@ -436,7 +438,7 @@ - + @@ -453,7 +455,7 @@ - + @@ -464,8 +466,8 @@ - - + @@ -553,14 +555,16 @@ - + diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index c484c9de..40c35833 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -999,7 +999,6 @@ class CNCprocessing(models.Model): def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp): cnc_processing = None for obj in ret['programming_list']: - # 暂时不注释,批次插入不需要单个workorder workorder = self.env['mrp.workorder'].search( [('production_id.name', '=', cnc_workorder.name), ('processing_panel', '=', obj['processing_panel']), @@ -1008,7 +1007,7 @@ class CNCprocessing(models.Model): if obj['program_name'] in program_path: logging.info('obj:%s' % obj['program_name']) cnc_processing = self.env['sf.cnc.processing'].create({ - # 'workorder_id': workorder.id, + 'workorder_id': workorder.id, 'sequence_number': obj['sequence_number'], 'program_name': obj['program_name'], 'cutting_tool_name': obj['cutting_tool_name'], @@ -1024,6 +1023,7 @@ class CNCprocessing(models.Model): 'program_path': program_path.replace('/tmp', '/home/ftp/ftp_root/NC') }) cnc_processing.get_cnc_processing_file(program_path_tmp, cnc_processing, program_path) + cnc_workorder.write({'programming_state': '已编程', 'work_state': '已编程'}) return cnc_processing def _json_cnc_processing(self, obj): diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index b7a396a1..39c0f4bf 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -471,6 +471,18 @@ class ProductionLot(models.Model): # 'target': 'self', # } + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get('rfid'): + lots = self.env['stock.lot'].search([('rfid', '=', vals['rfid'])]) + if lots: + for lot in lots: + raise ValidationError('Rfid【%s】已被序列号为【%s】的【%s】产品占用!' % ( + lot.rfid, lot.name, lot.product_id.name)) + records = super(ProductionLot, self).create(vals_list) + return records + class StockPicking(models.Model): _inherit = 'stock.picking' diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 3eed40e3..f6dda9f8 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -60,6 +60,7 @@ class Sf_Mrs_Connect(http.Controller): cnc_processing = request.env['sf.cnc.processing'].with_user( request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret, program_path, program_path_tmp) + logging.info('cnc_processing111:%s' % cnc_processing) if cnc_processing: cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing)) if cnc_program and cnc_processing_arr: diff --git a/sf_oca/__init__.py b/sf_oca/__init__.py new file mode 100644 index 00000000..9a7e03ed --- /dev/null +++ b/sf_oca/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/sf_oca/__manifest__.py b/sf_oca/__manifest__.py new file mode 100644 index 00000000..ee03cbaa --- /dev/null +++ b/sf_oca/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "sf_oca", + "version": "1.0", + 'summary': '智能工厂oca模块', + 'sequence': 1, + 'description': """ +在本模块,进行流程的审核 + """, + 'category': 'sf', + 'website': 'https://www.sf.jikimo.com', + "depends": ["base_tier_validation_forward"], + "data": [ + "security/ir.model.access.csv", + "templates/tier_validation_templates.xml", + ], + "assets": {}, + 'license': 'LGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/sf_oca/models/__init__.py b/sf_oca/models/__init__.py new file mode 100644 index 00000000..1b2d1ace --- /dev/null +++ b/sf_oca/models/__init__.py @@ -0,0 +1 @@ +from . import tier_validation \ No newline at end of file diff --git a/sf_oca/models/tier_validation.py b/sf_oca/models/tier_validation.py new file mode 100644 index 00000000..1ca4c29c --- /dev/null +++ b/sf_oca/models/tier_validation.py @@ -0,0 +1,18 @@ +# Copyright 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from ast import literal_eval + +from lxml import etree + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError +from odoo.tools.misc import frozendict + + +class TierValidation(models.AbstractModel): + _inherit = "tier.validation" + + def _notify_restarted_review_body(self): + return _("%s 取消审批请求.") % (self.env.user.name) + diff --git a/sf_oca/security/ir.model.access.csv b/sf_oca/security/ir.model.access.csv new file mode 100644 index 00000000..97dd8b91 --- /dev/null +++ b/sf_oca/security/ir.model.access.csv @@ -0,0 +1 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink diff --git a/sf_oca/templates/tier_validation_templates.xml b/sf_oca/templates/tier_validation_templates.xml new file mode 100644 index 00000000..24108bcc --- /dev/null +++ b/sf_oca/templates/tier_validation_templates.xml @@ -0,0 +1,122 @@ + + + + + + + + + diff --git a/sf_sale/views/purchase_order_view.xml b/sf_sale/views/purchase_order_view.xml index b0a4ed98..85f5b1c8 100644 --- a/sf_sale/views/purchase_order_view.xml +++ b/sf_sale/views/purchase_order_view.xml @@ -83,6 +83,9 @@ {'readonly': [('state', 'in', ['purchase'])]} + + {'no_create': True} + {'readonly': [('state', 'in', ['purchase'])]} diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index b00ab209..533df3a6 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -41,7 +41,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.Float(string='刀具直径(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') max_lifetime_value = fields.Integer(string='最大寿命值(min)') alarm_value = fields.Integer(string='报警值(min)') @@ -209,7 +209,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', compute='_compute_tool_number', store=True) tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_tool_number', store=True) - diameter = fields.Integer(string='刀具直径(mm)', compute='_compute_tool_number', store=True) + diameter = fields.Float(string='刀具直径(mm)', compute='_compute_tool_number', store=True) tool_included_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_tool_number', store=True) tool_loading_length = fields.Float(string='总长度(mm)', compute='_compute_tool_number', store=True) extension_length = fields.Float(string='伸出长(mm)') @@ -368,7 +368,7 @@ class FunctionalToolAssembly(models.Model): functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, group_expand='_read_group_functional_tool_type_ids') - functional_tool_diameter = fields.Integer(string='功能刀具直径(mm)', readonly=True) + functional_tool_diameter = fields.Float(string='功能刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -542,7 +542,7 @@ class FunctionalToolAssembly(models.Model): after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True) after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='组装后功能刀具类型', readonly=True) - after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)', readonly=True) + after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True) after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True) after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True) cut_time = fields.Integer(string='已切削时间(min)', readonly=True) @@ -696,7 +696,7 @@ class FunctionalToolDismantle(models.Model): 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) + diameter = fields.Float(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) rfid_dismantle = fields.Char('Rfid(已拆解)', readonly=True) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index e855d2a9..989b4578 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -22,7 +22,7 @@ class FunctionalCuttingToolEntity(models.Model): sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True) - functional_tool_diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + functional_tool_diameter = fields.Float(string='刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -244,7 +244,7 @@ class FunctionalToolWarning(models.Model): functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', related='functional_tool_name_id.barcode_id') mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - diameter = fields.Integer(string='刀具直径(mm)') + diameter = fields.Float(string='刀具直径(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') # 其他信息 install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time') @@ -298,7 +298,7 @@ class StockMoveLine(models.Model): functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, group_expand='_read_group_functional_tool_type_id') functional_tool_name = fields.Char('刀具名称') - diameter = fields.Integer(string='刀具直径(mm)') + diameter = fields.Float(string='刀具直径(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now()) code = fields.Char('编码') @@ -320,7 +320,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model): tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=False, required=True) sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False, group_expand='_read_mrs_cutting_tool_type_ids', store=True) - diameter = fields.Integer(string='刀具直径(mm)', readonly=False) + diameter = fields.Float(string='刀具直径(mm)', readonly=False) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=False) tool_stock_num = fields.Integer(string='刀具房数量') side_shelf_num = fields.Integer(string='线边刀库数量') diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py index f693ed2c..a4bcf751 100644 --- a/sf_tool_management/models/maintenance_equipment.py +++ b/sf_tool_management/models/maintenance_equipment.py @@ -13,9 +13,10 @@ class SfMaintenanceEquipmentTool(models.Model): image = fields.Binary('图片', related='functional_tool_name_id.image') tool_code = fields.Char('功能刀具编码', related='functional_tool_name_id.code') + rfid = fields.Char('Rfid', related='functional_tool_name_id.rfid') functional_tool_type = fields.Char('功能刀具类型', related='functional_tool_name_id.sf_cutting_tool_type_id.name') tool_groups = fields.Char('刀具组', related='functional_tool_name_id.tool_groups_id.name') - diameter = fields.Integer('直径(mm)', related='functional_tool_name_id.functional_tool_diameter') + diameter = fields.Float('直径(mm)', related='functional_tool_name_id.functional_tool_diameter') knife_tip_r_angle = fields.Float('刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle') life_value_max = fields.Integer('最大寿命值(min)', related='functional_tool_name_id.max_lifetime_value') alarm_value = fields.Integer('报警值(min)', related='functional_tool_name_id.alarm_value') @@ -26,15 +27,15 @@ class SfMaintenanceEquipmentTool(models.Model): # if datas: # print(datas) - @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 + # @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 class SfMaintenanceEquipment(models.Model): @@ -68,6 +69,18 @@ class SfMaintenanceEquipment(models.Model): [('equipment_id', '=', maintenance_equipment_id.id), ('code', '=', tool_id)]) functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search( [('rfid', '=', data['RfidCode'])]) + if functional_tool_id: + # 查询该功能刀具是否已经装在机床内其他位置,如果是就删除 + equipment_tools = self.env['maintenance.equipment.tool'].sudo().search( + [('functional_tool_name_id', '=', functional_tool_id.id), ('code', '!=', tool_id)]) + if equipment_tools: + for item in equipment_tools: + item.write({ + 'functional_tool_name_id': False, + 'tool_install_time': None + }) + else: + logging.info('Rfid为【%s】的功能刀具不存在!' % data['RfidCode']) time = None if data['AddDatetime']: datatime = str(data['AddDatetime']) diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 44c4ef95..e21941ca 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -32,8 +32,9 @@ class CNCprocessing(models.Model): @api.model_create_multi def create(self, vals): obj = super(CNCprocessing, self).create(vals) - # 调用CAM工单程序用刀计划创建方法 - self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj) + for item in obj: + # 调用CAM工单程序用刀计划创建方法 + self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(item) logging.info('成功调用CAM工单程序用刀计划创建方法!!!') return obj diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml index 53e050d9..abad7539 100644 --- a/sf_tool_management/views/functional_tool_views.xml +++ b/sf_tool_management/views/functional_tool_views.xml @@ -184,27 +184,10 @@ sf.functional.cutting.tool.entity - - - + - - - - - - - - - - - - - - - diff --git a/sf_tool_management/views/sf_maintenance_equipment.xml b/sf_tool_management/views/sf_maintenance_equipment.xml index 8b3de5a9..4bd8870d 100644 --- a/sf_tool_management/views/sf_maintenance_equipment.xml +++ b/sf_tool_management/views/sf_maintenance_equipment.xml @@ -13,6 +13,7 @@ + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index a77c9010..cb32833a 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -1,3 +1,5 @@ +import logging + from datetime import timedelta, datetime from odoo import fields, models, api @@ -25,7 +27,7 @@ class ToolChangeRequirementInformation(models.TransientModel): [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), ('直装固定式', '直装固定式')], string='刀位接口型号', readonly=True) - diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + diameter = fields.Float(string='刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) alarm_value = fields.Integer(string='报警值(min)', readonly=True) @@ -37,7 +39,7 @@ class ToolChangeRequirementInformation(models.TransientModel): # 待换功能刀具信息 replacement_tool_name = fields.Char(string='待换功能刀具名称', compute='_compute_name') replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型') - replacement_diameter = fields.Integer(string='待换刀具直径(mm)') + replacement_diameter = fields.Float(string='待换刀具直径(mm)') replacement_knife_tip_r_angle = fields.Float(string='待换刀具刀尖R角(mm)', required=True) replacement_tool_setting_length = fields.Float(string='待换刀具总长度(mm)', required=True) replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)') @@ -151,7 +153,7 @@ class ToolTransferRequestInformation(models.TransientModel): [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), ('直装固定式', '直装固定式')], string='刀位接口型号', readonly=True) - diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + diameter = fields.Float(string='刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) alarm_value = fields.Integer(string='报警值(min)', readonly=True) @@ -195,7 +197,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, group_expand='_read_group_functional_tool_type_ids') - functional_tool_diameter = fields.Integer(string='功能刀具直径(mm)', readonly=True) + functional_tool_diameter = fields.Float(string='功能刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -461,7 +463,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True) after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='组装后功能刀具类型') - after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)') + after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)') after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)') after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', default='0') cut_time = fields.Integer(string='已切削时间(min)') @@ -613,17 +615,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self) # 刀具物料出库 if self.handle_code_id: - product_id.tool_material_stock_moves(self.handle_code_id) + product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code) if self.integral_product_id: - self.integral_product_id.material_stock_moves(self.integral_freight_barcode) + self.integral_product_id.material_stock_moves(self.integral_freight_barcode,self.assembly_order_code) if self.blade_product_id: - self.blade_product_id.material_stock_moves(self.blade_freight_barcode) + self.blade_product_id.material_stock_moves(self.blade_freight_barcode,self.assembly_order_code) if self.bar_product_id: - self.bar_product_id.material_stock_moves(self.bar_freight_barcode) + self.bar_product_id.material_stock_moves(self.bar_freight_barcode,self.assembly_order_code) if self.pad_product_id: - self.pad_product_id.material_stock_moves(self.pad_freight_barcode) + self.pad_product_id.material_stock_moves(self.pad_freight_barcode,self.assembly_order_code) if self.chuck_product_id: - self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode) + self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode,self.assembly_order_code) # ============================创建功能刀具列表、安全库存记录=============================== # 封装功能刀具数据 @@ -807,6 +809,7 @@ class ProductProduct(models.Model): """ product_id = self.env['product.product'].search([('name', '=', '功能刀具')]) + logging.info("product_id: %s" % product_id) stock_lot = self.env['stock.lot'].create({ 'name': self.get_stock_lot_name(tool_assembly_order_id), 'product_id': product_id.id, @@ -817,7 +820,7 @@ class ProductProduct(models.Model): stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')]) # 创建功能刀具该批次/序列号 库存移动和移动历史 stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id, - '功能刀具组装', obj, obj.after_tool_groups_id) + self.assembly_order_code, obj, obj.after_tool_groups_id) return stock_lot @@ -843,7 +846,7 @@ class ProductProduct(models.Model): num = "%03d" % m return code + str(num) - def tool_material_stock_moves(self, tool_material): + def tool_material_stock_moves(self, tool_material, assembly_order_code): """ 对刀具物料进行库存移动到 刀具组装位置 """ @@ -851,12 +854,12 @@ class ProductProduct(models.Model): location_inventory_id = tool_material.quant_ids.location_id[-1] stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) # 创建功能刀具该批次/序列号 库存移动和移动历史 - tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False, False) + tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False, False) - def material_stock_moves(self, shelf_location_barcode): + def material_stock_moves(self, shelf_location_barcode, assembly_order_code): # 创建库存移动记录 stock_move_id = self.env['stock.move'].sudo().create({ - 'name': '功能刀具组装', + 'name': assembly_order_code, 'product_id': self.id, 'location_id': self.env['stock.location'].search([('name', '=', '刀具房')]).id, 'location_dest_id': self.env['stock.location'].search([('name', '=', '刀具组装位置')]).id, diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 236781ee..1a7ba1e0 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -880,7 +880,7 @@ class SfStockPicking(models.Model): line.compute_destination_location_id() else: # 对除刀柄之外的刀具物料进行 目标货位必填校验 - if self.location_dest_id.name == '刀具房' and line.product_id.cutting_tool_material_id not in ( + if self.location_dest_id.name == '刀具房' and line.product_id.cutting_tool_material_id.name not in ( '刀柄', False): raise ValidationError('请选择【%s】产品的目标货位!' % line.product_id.name) if line.current_location_id: