diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 7afefcea..ca827e95 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -67,7 +67,12 @@ class MrsMaterialModel(models.Model): mf_materia_post = fields.Char("热处理后密度") density = fields.Float("密度(kg/m³)") materials_id = fields.Many2one('sf.production.materials', "材料名") - tensile_strength = fields.Float("拉伸强度(n/mm²)") + tensile_strength = fields.Char("拉伸强度(n/mm²)") + standards_id = fields.Many2one('sf.international.standards', '制造标准') + alloy_code = fields.Char('合金牌号') + price = fields.Float('单价/kg') + apply = fields.Many2many('material.apply', string='材料应用') + materials_code = fields.Char('材料代号') hardness = fields.Float("硬度(hrc)") rough_machining = fields.Float("粗加工Vc(m/min)") finish_machining = fields.Float("精加工Vc(m/min)") @@ -97,7 +102,7 @@ class MrsProductionProcess(models.Model): _name = 'sf.production.process' _description = '表面工艺' - process_encode = fields.Char("编码") + code = fields.Char("编码") name = fields.Char('名称') remark = fields.Text("备注") processing_order_ids = fields.One2many('sf.processing.order', 'production_process_id', string='工序') @@ -114,7 +119,7 @@ class MrsProcessingTechnology(models.Model): name = fields.Char('名称', index=True) remark = fields.Text('备注', index=True) - process_encode = fields.Char("编码") + code = fields.Char("编码") processing_order_ids = fields.Many2many('sf.processing.order', 'sf_associated_processes', index=True, string='工序') active = fields.Boolean('有效', default=True) @@ -173,3 +178,20 @@ class MrsProductionProcessParameter(models.Model): for i in item.parameter_ids: code_arr.append(i.code) return code_arr + + +class ModelInternationalStandards(models.Model): + _name = 'sf.international.standards' + _description = '制造标准' + + code = fields.Char('编码') + name = fields.Char('名称') + active = fields.Boolean('有效', default=True) + + +class MrsMaterialApply(models.Model): + _name = 'material.apply' + _description = '材料应用' + + name = fields.Char('名称', default=True) + active = fields.Boolean('有效', default=True) diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index fefaeb1b..1829085c 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -24,6 +24,8 @@ access_sf_fixture_model,sf_fixture_model,model_sf_fixture_model,base.group_user, access_sf_functional_fixture_type,sf_functional_fixture_type,model_sf_functional_fixture_type,base.group_user,1,1,1,1 access_sf_functional_fixture,sf_functional_fixture,model_sf_functional_fixture,base.group_user,1,1,1,1 access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,1,1,1 +access_sf_international_standards,sf_international_standards,model_sf_international_standards,base.group_user,1,1,1,1 +access_material_apply,material_apply,model_material_apply,base.group_user,1,1,1,1 diff --git a/sf_base/views/common_view.xml b/sf_base/views/common_view.xml index b079beda..a4853907 100644 --- a/sf_base/views/common_view.xml +++ b/sf_base/views/common_view.xml @@ -24,7 +24,7 @@ sf.processing.technology - + @@ -35,7 +35,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -105,7 +105,7 @@ sf.production.process - + @@ -124,7 +124,7 @@ - + @@ -186,7 +186,7 @@ - + @@ -241,17 +241,20 @@ sf.materials.model - - - - + + + + + + - + - - - - + + + + + diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index dca24821..156ab83f 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -36,6 +36,7 @@ class SfMaintenanceEquipment(models.Model): num = "%04d" % m return num + equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards', 'sf_maintenance_equipment_ids', string='设备维保标准') eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准', diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 6bd0af90..45955147 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -73,105 +73,105 @@ - - - - - - + - - - - - - + + + - - - - - - - + - - - + + + - - - + - - - + + + - - - + @@ -184,54 +184,54 @@ - - - - - - - m/S - m/S - m/S - mm @@ -242,26 +242,26 @@ - mm - mm - ° - mm @@ -275,14 +275,14 @@ - kg - kg @@ -290,7 +290,7 @@ - h @@ -298,7 +298,7 @@ - @@ -326,7 +326,7 @@ - kw @@ -334,7 +334,7 @@ - i @@ -342,7 +342,7 @@ - kw @@ -354,14 +354,14 @@ - kw - i @@ -369,7 +369,7 @@ - kw @@ -377,7 +377,7 @@ - i @@ -393,27 +393,27 @@ - - - - @@ -426,19 +426,19 @@ - - - @@ -448,14 +448,14 @@ - ° - ° @@ -470,15 +470,15 @@ - mm - mm - mm @@ -487,25 +487,25 @@ - mm - kg - kg - mm @@ -526,15 +526,15 @@ - mm - mm - mm @@ -545,22 +545,22 @@ options="{'format': false}"/> - - - ° - ° @@ -575,30 +575,30 @@ - mm - mm - mm - mm - mm - mm @@ -606,19 +606,19 @@ - μm - - @@ -627,19 +627,19 @@ - kg - kg - mm @@ -656,13 +656,13 @@ - - @@ -671,19 +671,19 @@ - 倍 - 倍 - mm @@ -692,23 +692,23 @@ - - 最小 - mm~ - mm @@ -717,19 +717,19 @@ - ° - ° - @@ -737,7 +737,7 @@ - + diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index febab313..e2be4958 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -23,6 +23,7 @@ 'views/mrp_workorder_view.xml', 'views/tool_other_features_view.xml', 'views/model_type_view.xml', + 'views/sf_maintenance_equipment.xml', # 'views/kanban_change.xml' ], diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index d28ae68e..9c3bc6cb 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -861,3 +861,43 @@ class ResMrpBomMo(models.Model): raw_bom = self.env['product.product'].search( [('categ_id.type', '=', '原材料'), ('materials_type_id', '=', product.materials_type_id.id)]) return raw_bom + + +class SfMaintenanceEquipmentAndProductTemplate(models.Model): + _inherit = 'maintenance.equipment' + _description = '设备' + product_template_ids = fields.One2many('maintenance.equipment.tool', 'equipment_id', string='机床刀位') + + @api.model_create_multi + def create(self, vals_list): + vals = [] + for value in vals_list: + res = super(SfMaintenanceEquipmentAndProductTemplate, self).create(value) + number = value.get('number_of_knife_library') + for i in range(1, number + 1): + self.env['maintenance.equipment.tool'].create({ + 'equipment_id': res.id, + 'code': 'T' + str(i) + }) + vals.append(res) + return vals[0] + + +class SfMaintenanceEquipmentTool(models.Model): + _name = 'maintenance.equipment.tool' + _description = '机床刀位' + + equipment_id = fields.Many2one('maintenance.equipment', string='设备') + product_template_id = fields.Many2one('product.template', string='功能刀具名称', domain="[('categ_type', '=', '刀具')]") + image_1920 = fields.Binary('图片', related='product_template_id.image_1920') + categ_type = fields.Char(string='功能刀具类型') + diameter = fields.Char('直径') + precision = fields.Char('粗\中\精') + tool_code = fields.Char('功能刀具编码') + hilt_name = fields.Char('刀柄名称') + hilt_code = fields.Char('刀柄编码') + life_value_max = fields.Char('最大寿命值') + alarm_value = fields.Char('报警值') + used_value = fields.Char('已使用值') + code = fields.Char('机床刀位号') + diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index 76812adb..66de9496 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -14,5 +14,6 @@ access_sf_cutting_direction,sf_cutting_direction,model_sf_cutting_direction,base access_sf_suitable_coolant,sf_suitable_coolant,model_sf_suitable_coolant,base.group_user,1,1,1,1 access_sf_cutting_speed,sf_cutting_speed,model_sf_cutting_speed,base.group_user,1,1,1,1 access_sf_feed_per_tooth,sf_feed_per_tooth,model_sf_feed_per_tooth,base.group_user,1,1,1,1 +access_maintenance_equipment_tool,maintenance_equipment_tool,model_maintenance_equipment_tool,base.group_user,1,1,1,1 diff --git a/sf_manufacturing/views/sf_maintenance_equipment.xml b/sf_manufacturing/views/sf_maintenance_equipment.xml new file mode 100644 index 00000000..f072967b --- /dev/null +++ b/sf_manufacturing/views/sf_maintenance_equipment.xml @@ -0,0 +1,55 @@ + + + + + sf_equipment.form + maintenance.equipment + + + + + + + + + + sf.maintenance.logs.tree + sf.maintenance.logs + + + + + + + + + + sf_manufacturing_equipment.form + maintenance.equipment + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index 95128148..02836d13 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -21,6 +21,10 @@ class ResConfigSettings(models.TransientModel): def sf_all_sync(self): try: + self.env['sf.international.standards'].sync_all_mrs_international_standards() + _logger.info("同步资源库国际标准完成") + self.env['material.apply'].sync_all_material_apply() + _logger.info("同步资源库材料应用完成") self.env['sf.production.materials'].sync_all_production_materials() _logger.info("同步资源库材料") self.env['sf.materials.model'].sync_all_materials_model() @@ -29,8 +33,8 @@ class ResConfigSettings(models.TransientModel): _logger.info("同步资源库表面工艺类别") self.env['sf.production.process'].sync_all_production_process() _logger.info("同步资源库表面工艺") - self.env['sf.processing.technology'].sync_all_processing_technology() - _logger.info("同步资源库加工工艺") + # self.env['sf.processing.technology'].sync_all_processing_technology() + # _logger.info("同步资源库加工工艺") self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags() _logger.info("同步资源库品牌类别") self.env['sf.machine.brand'].sync_all_machine_brand() @@ -44,7 +48,10 @@ class ResConfigSettings(models.TransientModel): self.env['sf.cutting.tool.material'].sync_all_cutting_tool_material() _logger.info("同步刀具类型") self.env['sf.cutting.tool.type'].sync_all_tool_type() - _logger.info("同步功能刀具类型") + _logger.info("同步所有刀具类型完成") + # _logger.info("同步所有刀具型号...") + # self.env['sf.cutting.tool.model'].sync_all_tool_model() + _logger.info("同步所有刀具型号完成") self.env['sf.functional.cutting.tool.model'].sync_all_functional_cutting_tool_model() _logger.info("同步夹具物料") self.env['sf.fixture.material'].sync_all_fixture_material() @@ -53,9 +60,12 @@ class ResConfigSettings(models.TransientModel): _logger.info("同步夹具型号") self.env['sf.fixture.model'].sync_all_fixture_model() _logger.info("同步功能夹具类型") + # self.env['sf.functional.fixture'].sync_all_functional_fixture() + self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type() - _logger.info("同步资源库机床型号") + self.env['sf.machine_tool.type'].sync_all_machine_tool_type() + _logger.info("同步资源库机床型号完成") except Exception as e: _logger.info("捕获错误信息:%s" % e) raise ValidationError("数据错误导致同步失败,请联系管理员") diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index b5f285e4..ebfacfbe 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -207,10 +207,19 @@ class sfMaterialModel(models.Model): "hardness": item['hardness'], "rough_machining": item['rough_machining'], "finish_machining": item['finish_machining'], - "materials_id": materials.id, + "materials_id": self.env['sf.production.materials'].search( + [("materials_no", '=', item['materials_id.materials_no'])]).id, + "standards_id": self.env['sf.international.standards'].search( + [("name", '=', item['standards_id'])]).id, "need_h": item['need_h'], + "alloy_code": item['alloy_code'], "mf_materia_post": item['mf_materia_post'], "density": item['density'], + "materials_code": item['materials_code'], + "apply": self.env['material.apply'].search( + [("name", 'in', item['apply'])]).ids + # "tag_ids": item['tag_ids'] + }) else: materials_model.name = item['name'] @@ -306,7 +315,17 @@ class sfProductionProcess(models.Model): if result['status'] == 1: for item in result['production_process_yesterday_list']: if item: - production_process = self.search([("process_encode", '=', item['code'])]) + brand = self.env['sf.production.process'].search( + [("code", '=', item['code'])]) + if brand: + brand.name = item['name'], + brand.category_id = self.env['sf.production.process.category'].search( + [("code", '=', item['category_code'])]).id, + brand.code = item['code'], + brand.remark = item['remark'], + brand.active = item['active'], + brand.remark = item['remark'] + production_process = self.search([("code", '=', item['code'])]) category = self.env['sf.production.process.category'].search( [("code", '=', item['category_code'])]) if production_process: @@ -317,8 +336,9 @@ class sfProductionProcess(models.Model): else: self.create({ "name": item['name'], - "category_id": category.id, - "process_encode": item['code'], + "category_id": self.env['sf.production.process.category'].search( + [("code", '=', item['category_code'])]).id, + "code": item['code'], "remark": item['remark'], "active": item['active'], }) @@ -338,14 +358,14 @@ class sfProductionProcess(models.Model): if result['status'] == 1: for item in result['production_process_all_list']: if item: - production_process = self.search([("process_encode", '=', item['code'])]) + production_process = self.search([("code", '=', item['code'])]) category = self.env['sf.production.process.category'].search( [("code", '=', item['category_code'])]) if not production_process: self.create({ "name": item['name'], "category_id": category.id, - "process_encode": item['code'], + "code": item['code'], "remark": item['remark'], "active": item['active'], }) @@ -358,6 +378,7 @@ class sfProductionProcess(models.Model): raise ValidationError("表面工艺认证未通过") + class sfProcessingTechnology(models.Model): _inherit = 'sf.processing.technology' _description = '加工工艺' @@ -376,7 +397,7 @@ class sfProcessingTechnology(models.Model): if result['status'] == 1: for item in result['processing_technology_yesterday_list']: if item: - processing_technology = self.search([("process_encode", '=', item['process_encode'])]) + processing_technology = self.search([("code", '=', item['code'])]) if processing_technology: processing_technology.name = item['name'] processing_technology.remark = item['remark'] @@ -384,7 +405,7 @@ class sfProcessingTechnology(models.Model): else: self.create({ "name": item['name'], - "process_encode": item['process_encode'], + "code": item['code'], "remark": item['remark'], "active": item['active'], }) @@ -404,11 +425,11 @@ class sfProcessingTechnology(models.Model): if result['status'] == 1: for item in result['processing_technology_all_list']: if item: - processing_technology = self.search([("process_encode", '=', item['process_encode'])]) + processing_technology = self.search([("code", '=', item['code'])]) if not processing_technology: self.create({ "name": item['name'], - "process_encode": item['process_encode'], + "code": item['code'], "remark": item['remark'], "active": item['active'], }) @@ -884,7 +905,7 @@ class sfProductionProcessParameter(models.Model): _description = '表面工艺可选参数' url = '/api/production_process_parameter/list' - # 定时同步每日表面工艺 + # 定时同步每日表面工艺可选参数 def sync_production_process_parameter_yesterday(self): sf_sync_config = self.env['res.config.settings'].get_values() token = sf_sync_config['token'] @@ -899,7 +920,7 @@ class sfProductionProcessParameter(models.Model): if item: production_process_parameter = self.search([("code", '=', item['code'])]) process = self.env['sf.production.process'].search( - [('process_encode', '=', item['process_id_code'])]) + [('code', '=', item['process_id_code'])]) if production_process_parameter: production_process_parameter.name = item['name'] production_process_parameter.active = item['active'] @@ -918,7 +939,7 @@ class sfProductionProcessParameter(models.Model): else: raise ValidationError("表面工艺可选参数认证未通过") # 定时同步表面工艺 - # 同步所有表面工艺 + # 同步所有表面工艺可选参数 def sync_all_production_process_parameter(self): sf_sync_config = self.env['res.config.settings'].get_values() token = sf_sync_config['token'] @@ -934,7 +955,7 @@ class sfProductionProcessParameter(models.Model): production_process_parameter = self.search( [("code", '=', item['code'])]) process = self.env['sf.production.process'].search( - [('process_encode', '=', item['process_id_code'])]) + [('code', '=', item['process_id_code'])], limit=1) if not production_process_parameter: self.create({ "name": item['name'], @@ -1684,5 +1705,115 @@ class SfMaintenanceEquipmentImage(models.Model): "image": '' if not item['image'] else base64.b64decode(item['image']), "active": item['active'], }) + else: + raise ValidationError("认证未通过") + +class MaterialApply(models.Model): + _inherit = 'material.apply' + _description = '材料应用' + url = '/api/material_apply/list' + + # 定时同步材料应用 + def sync_material_apply(self): + sf_sync_config = self.env['res.config.settings'].get_values() + token = sf_sync_config['token'] + sf_secret_key = sf_sync_config['sf_secret_key'] + headers = Common.get_headers(self, token, sf_secret_key) + + strUrl = sf_sync_config['sf_url'] + self.url + r = requests.post(strUrl, json={}, data=None, headers=headers) + r = r.json() + result = json.loads(r['result']) + if result['status'] == 1: + for item in result['material_apply_yesterday_list']: + brand = self.env['material.apply'].search( + [("name", '=', item['name'])]) + if brand: + brand.name = item['name'], + brand.active = item['active'] + else: + self.env['material.apply'].create({ + "name": item['name'], + "active": item['active'], + + }) + else: + raise ValidationError("认证未通过") + + # 同步所有材料应用 + def sync_all_material_apply(self): + sf_sync_config = self.env['res.config.settings'].get_values() + token = sf_sync_config['token'] + sf_secret_key = sf_sync_config['sf_secret_key'] + headers = Common.get_headers(self, token, sf_secret_key) + + strUrl = sf_sync_config['sf_url'] + self.url + r = requests.post(strUrl, json={}, data=None, headers=headers) + r = r.json() + result = json.loads(r['result']) + if result['status'] == 1: + for item in result['material_apply_all_list']: + brand = self.env['material.apply'].search( + [("name", '=', item['name'])]) + if not brand: + self.env['material.apply'].create({ + "name": item['name'], + "active": item['active'], + }) + else: + raise ValidationError("认证未通过") + +class ModelInternationalStandards(models.Model): + _inherit = 'sf.international.standards' + _description = '制造标准' + url = '/api/mrs_international_standards/list' + + # 定时同步制造标准 + def sync_mrs_international_standards(self): + sf_sync_config = self.env['res.config.settings'].get_values() + token = sf_sync_config['token'] + sf_secret_key = sf_sync_config['sf_secret_key'] + headers = Common.get_headers(self, token, sf_secret_key) + + strUrl = sf_sync_config['sf_url'] + self.url + r = requests.post(strUrl, json={}, data=None, headers=headers) + r = r.json() + result = json.loads(r['result']) + if result['status'] == 1: + for item in result['mrs_international_standards_yesterday_list']: + brand = self.env['sf.international.standards'].search( + [("name", '=', item['name'])]) + if brand: + brand.name = item['name'], + brand.active = item['active'] + else: + self.env['sf.international.standards'].create({ + "name": item['name'], + "active": item['active'], + + }) + else: + raise ValidationError("认证未通过") + + # 同步所有制造标准 + def sync_all_mrs_international_standards(self): + sf_sync_config = self.env['res.config.settings'].get_values() + token = sf_sync_config['token'] + sf_secret_key = sf_sync_config['sf_secret_key'] + headers = Common.get_headers(self, token, sf_secret_key) + + strUrl = sf_sync_config['sf_url'] + self.url + r = requests.post(strUrl, json={}, data=None, headers=headers) + r = r.json() + result = json.loads(r['result']) + if result['status'] == 1: + for item in result['mrs_international_standards_all_list']: + brand = self.env['sf.international.standards'].search( + [("name", '=', item['name'])]) + if not brand: + self.env['sf.international.standards'].create({ + "name": item['name'], + "active": item['active'], + }) else: raise ValidationError("能力特征库认证未通过")