From 11a360222edd8f923e85b5974b716dde10bb5b29 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 22 Nov 2022 21:18:15 +0800 Subject: [PATCH] =?UTF-8?q?cnc=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/__manifest__.py | 2 +- sf_dlm/models/product_template.py | 9 +++++--- sf_dlm/views/product_template_view.xml | 5 +--- sf_manufacturing/models/mrp_workcenter.py | 2 +- sf_manufacturing/models/mrp_workorder.py | 28 ++++++++++++++--------- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/sf_dlm/__manifest__.py b/sf_dlm/__manifest__.py index df6b5425..1cd1e995 100644 --- a/sf_dlm/__manifest__.py +++ b/sf_dlm/__manifest__.py @@ -12,7 +12,7 @@ 'website': 'https://www.sf.jikimo.com', 'depends': ['mrp', 'base', 'sf_manufacturing'], 'data': [ - 'data/product_data.xml', + # 'data/product_data.xml', 'views/product_template_view.xml' ], 'demo': [ diff --git a/sf_dlm/models/product_template.py b/sf_dlm/models/product_template.py index 470eff03..14071dc6 100644 --- a/sf_dlm/models/product_template.py +++ b/sf_dlm/models/product_template.py @@ -10,14 +10,17 @@ class ResProductTemplate(models.Model): model_width = fields.Float('模型宽[mm]', digits=(16, 3)) model_height = fields.Float('模型高[mm]', digits=(16, 3)) model_volume = fields.Float('模型体积[mm³]', digits=(16, 3)) - model_precision = fields.Float('精度要求', digits=(16, 3)) + model_machining_precision = fields.Selection([ + ('±0.10mm', '±0.10mm'), + ('±0.05mm', '±0.05mm'), + ('±0.03mm', '±0.03mm'), + ('±0.02mm', '±0.02mm'), + ('±0.01mm', '±0.01mm')], string='加工精度') model_type_id = fields.Many2one('sf.model.type', string='模型类型') model_processing_panel = fields.Char('模型加工面板') model_surface_process_id = fields.Many2one('sf.production.process', string='表面工艺') model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数') model_price = fields.Float('模型单价', digits=(16, 3)) - model_total_amount = fields.Float('模型金额', digits=(16, 3)) - model_number = fields.Integer('模型数量', default=1) model_remark = fields.Char('模型备注说明') long = fields.Float('长[mm]', digits=(16, 3), onchange='add_product_size') width = fields.Float('宽[mm]', digits=(16, 3), onchange='add_product_size') diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index 83d70cfa..04507aaa 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -37,13 +37,10 @@ - + - - - diff --git a/sf_manufacturing/models/mrp_workcenter.py b/sf_manufacturing/models/mrp_workcenter.py index c10d6068..ad7a0419 100644 --- a/sf_manufacturing/models/mrp_workcenter.py +++ b/sf_manufacturing/models/mrp_workcenter.py @@ -33,7 +33,7 @@ class ResWorkcenter(models.Model): AND equipment_id IS NOT NULL AND maintenance_equipment.workcenter_id IS NOT NULL AND maintenance_equipment.workcenter_id IN %s - AND (schedule_date, schedule_date + INTERVAL '1h' * duration) OVERLAPS (%s, %s) + AND (schedule_date, schedule_date + INT ERVAL '1h' * duration) OVERLAPS (%s, %s) GROUP BY maintenance_equipment.workcenter_id; """ self.env.cr.execute(sql, [tuple(self.ids), fields.Datetime.to_string(start_datetime.astimezone()), diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2922ee3e..eef41de7 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1,3 +1,6 @@ +import json +import requests +import logging from datetime import datetime from dateutil.relativedelta import relativedelta from odoo import api, fields, models, SUPERUSER_ID, _ @@ -200,17 +203,20 @@ class ResMrpWorkOrder(models.Model): # cnc程序获取 def fetchCNC(self): - res = [{'model_code': self.product_id.barcode, 'production_no': self.production_id.name, - 'machine_tool_code': self.workcenter_id.machine_tool_id.code, - 'material_code': self.env['sf.production.materials'].search( - [('id', '=', self.product_id.materials_id.id)]).materials_no, - 'material_type_code': self.env['sf.materials.model'].search( - [('id', '=', self.product_id.materials_type_id.id)]).materials_no, - 'embryo_long': self.product_id.bom_ids.bom_line_ids.product_id.long, - 'embryo_height': self.product_id.bom_ids.bom_line_ids.product_id.height, - 'embryo_width': self.product_id.bom_ids.bom_line_ids.product_id.width - # 'factory_code': self.env.user.company_id.partner_id. - }] + cnc = self.env['mrp.workorder'].search([('routing_type', '=', 'CNC加工')], limit=1) + res = {'model_code': cnc.product_id.barcode, 'production_no': self.production_id.name, + 'machine_tool_code': cnc.workcenter_id.machine_tool_id.code, + 'material_code': cnc.env['sf.production.materials'].search( + [('id', '=', cnc.product_id.materials_id.id)]).materials_no, + 'material_type_code': cnc.env['sf.materials.model'].search( + [('id', '=', cnc.product_id.materials_type_id.id)]).materials_no, + 'machining_precision': cnc.product_id.model_machining_precision, + 'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.long, + 'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height, + 'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width + # 'factory_code': self.env.user.company_id.partner_id. + } + logging.info('res:%s' % res) configsettings = self.env['res.config.settings'].get_values() config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key']) url = '/api/intelligent_programming/create'