Merge branch refs/heads/develop into refs/heads/feature/修改机床参数bug

This commit is contained in:
龚启豪
2023-11-20 15:03:36 +08:00
32 changed files with 322 additions and 348 deletions

View File

@@ -165,7 +165,7 @@ class ResMrpWorkOrder(models.Model):
y0 = ((y3 - y4) * (y2 * x1 - y1 * x2) - (y1 - y2) * (y4 * x3 - y3 * x4)) / (
(y3 - y4) * (x1 - x2) - (y1 - y2) * (x3 - x4))
x1 = ((x7 - x8) * (x6 * y5 - x5 * y6) - (x5 - x6) * (x8 * y7 - x7 * y8)) / (
(x7 - x8) * (y5 - y6) - (x5 - x6) * (y7 - y8));
(x7 - x8) * (y5 - y6) - (x5 - x6) * (y7 - y8))
y1 = ((y7 - y8) * (y6 * x5 - y5 * x6) - (y5 - y6) * (y8 * x7 - y7 * x8)) / (
(y7 - y8) * (x5 - x6) - (y5 - y6) * (x7 - x8))
x = (x0 + x1) / 2
@@ -189,19 +189,26 @@ class ResMrpWorkOrder(models.Model):
def json_workorder_str(self, k, production, route):
# 计算预计时长duration_expected
if route.routing_type == '切割':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', '切割')]).time_cycle
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '切割')]).time_cycle
elif route.routing_type == '获取CNC加工程序':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', '获取CNC加工程序')]).time_cycle
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '获取CNC加工程序')]).time_cycle
elif route.routing_type == '工件装夹':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', '工件装夹')]).time_cycle
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '工件装夹')]).time_cycle
elif route.routing_type == '前置三元定位检测':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', '前置三元定位检测')]).time_cycle
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '前置三元定位检测')]).time_cycle
elif route.routing_type == 'CNC加工':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', 'CNC加工')]).time_cycle
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', 'CNC加工')]).time_cycle
elif route.routing_type == '后置三元质量检测':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', '后置三元质量检测')]).time_cycle
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '后置三元质量检测')]).time_cycle
elif route.routing_type == '解除装夹':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', '解除装夹')]).time_cycle
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '解除装夹')]).time_cycle
else:
duration_expected = 60
workorders_values_str = [0, '', {

View File

@@ -151,33 +151,35 @@ class ResProductMo(models.Model):
item.cutting_speed_ids = False
item.feed_per_tooth_ids = False
def choice(self):
if self.cutting_tool_type == '整体式刀具':
tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_integral_tree')
elif self.cutting_tool_type == '刀片':
tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_blade_tree')
elif self.cutting_tool_type == '刀杆':
tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_cutter_bar_tree')
elif self.cutting_tool_type == '刀盘':
tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree')
elif self.cutting_tool_type == '刀柄':
tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree')
else:
tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree')
return {
'name': _('规格'),
'view_mode': 'list',
'view_id': tree_view.id,
'type': 'ir.actions.act_window',
'res_model': 'sf.tool.materials.basic.parameters',
'target': 'new',
'domain': [('cutting_tool_type', '=', self.cutting_tool_type),
('standard_library_id', '=', self.cutting_tool_model_id.id)],
}
# def choice(self):
# if self.cutting_tool_type == '整体式刀具':
# tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_integral_tree')
# elif self.cutting_tool_type == '刀片':
# tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_blade_tree')
# elif self.cutting_tool_type == '刀杆':
# tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_cutter_bar_tree')
# elif self.cutting_tool_type == '刀盘':
# tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree')
# elif self.cutting_tool_type == '刀柄':
# tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree')
# else:
# tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree')
# return {
# 'name': _('规格'),
# 'view_mode': 'list',
# 'view_id': tree_view.id,
# 'type': 'ir.actions.act_window',
# 'res_model': 'sf.tool.materials.basic.parameters',
# 'target': 'new',
# 'domain': [('cutting_tool_type', '=', self.cutting_tool_type),
# ('standard_library_id', '=', self.cutting_tool_model_id.id)],
# }
@api.onchange('specification_id')
def _onchange_specification(self):
if self.specification_id:
self.cutting_speed_ids = False
self.feed_per_tooth_ids = False
self.cutting_tool_type_id = self.cutting_tool_model_id.cutting_tool_type_id.id
self.brand_id = self.cutting_tool_model_id.brand_id.id
self.tool_hardness = self.cutting_tool_model_id.tool_hardness
@@ -202,14 +204,18 @@ class ResProductMo(models.Model):
self.cutting_tool_blade_depth = self.specification_id.blade_depth
self.cutting_tool_cut_depth = self.specification_id.cutting_depth
self.cutting_speed_ids = self.cutting_tool_model_id.cutting_speed_ids
self.feed_per_tooth_ids = [(0, 0, {'product_template_id': product_template.id,
'cutting_speed': product_template.cutting_speed,
'machining_method': product_template.machining_method,
'blade_diameter': product_template.blade_diameter,
'materials_type_id': product_template.materials_type_id.id}) for
product_template in
self.cutting_tool_model_id.feed_per_tooth_ids.filtered(
lambda r: r.blade_diameter == self.specification_id.blade_diameter)]
# # self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids.
# for tooth in self.cutting_tool_model_id.feed_per_tooth_ids:
# print(int(tooth.blade_diameter))
# print(int(self.specification_id.blade_diameter))
# if int(tooth.blade_diameter) == int(self.specification_id.blade_diameter):
# self.feed_per_tooth_ids = [(0, 0, {
# 'cutting_speed': tooth.cutting_speed,
# 'machining_method': tooth.machining_method,
# 'blade_diameter': tooth.blade_diameter,
# 'materials_type_id': tooth.materials_type_id.id})]
self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids.filtered(
lambda r: int(r.blade_diameter) == int(self.specification_id.blade_diameter))
elif self.cutting_tool_type == '夹头':
self.cutting_tool_clamping_length = self.specification_id.clamping_length
self.cutting_tool_clamping_tolerance = self.specification_id.clamping_tolerance
@@ -284,8 +290,8 @@ class ResProductMo(models.Model):
elif self.cutting_tool_type == '刀柄':
self.cutting_tool_total_length = self.specification_id.total_length
self.cutting_tool_standard_speed = self.specification_id.standard_rotate_speed
self.cutting_tool_speed_max = self.specification_id.speed_max
self.cutting_tool_change_time = self.specification_id.change_time
self.cutting_tool_speed_max = self.specification_id.max_rotate_speed
self.cutting_tool_change_time = self.specification_id.tool_changing_time
self.cutting_tool_total_length = self.specification_id.total_length
self.cutting_tool_clamping_diameter_max = self.specification_id.max_clamping_diameter
self.cutting_tool_clamping_diameter_min = self.specification_id.min_clamping_diameter
@@ -313,6 +319,44 @@ class ResProductMo(models.Model):
self.compaction_way_ids = [(6, 0,
[])] if not self.cutting_tool_model_id.compaction_way_ids else [
(6, 0, self.cutting_tool_model_id.compaction_way_ids.ids)]
else:
self.cutting_tool_type_id = False
self.brand_id = False
self.tool_hardness = False
self.cutting_tool_run_out_accuracy_max = False
self.cutting_tool_run_out_accuracy_min = False
self.materials_type_id = False
self.cutting_tool_blade_type = False
self.cutting_tool_total_length = False
self.cutting_tool_clamping_way = False
self.cutting_tool_blade_diameter = False
self.cutting_tool_shank_length = False
self.cutting_tool_blade_length = False
self.cutting_tool_blade_number = False
self.cutting_tool_neck_length = False
self.cutting_tool_neck_diameter = False
self.cutting_tool_shank_diameter = False
self.cutting_tool_blade_tip_diameter = False
self.cutting_tool_blade_tip_taper = False
self.cutting_tool_blade_helix_angle = False
self.cutting_tool_blade_type = False
self.cutting_tool_pitch = False
self.cutting_tool_blade_width = False
self.cutting_tool_blade_depth = False
self.cutting_tool_cut_depth = False
self.cutting_tool_coarse_medium_fine = False
self.cutting_tool_run_out_accuracy_max = False
self.cutting_tool_run_out_accuracy_min = False
self.cutting_tool_blade_tip_working_size = False
self.fit_blade_shape_id = False
self.suitable_machining_method_ids = False
self.blade_tip_characteristics_id = False
self.handle_type_ids = False
self.cutting_direction_ids = False
self.suitable_coolant_ids = False
self.compaction_way_ids = False
self.cutting_speed_ids = False
self.feed_per_tooth_ids = False
# @api.constrains('suitable_machining_method_ids')
# def _check_suitable_machining_method_ids(self):
@@ -899,7 +943,8 @@ class SfMaintenanceEquipmentTool(models.Model):
_description = '机床刀位'
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
product_template_id = fields.Many2one('product.template', string='功能刀具名称', domain="[('categ_type', '=', '刀具')]")
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('直径')
@@ -911,5 +956,3 @@ class SfMaintenanceEquipmentTool(models.Model):
alarm_value = fields.Char('报警值')
used_value = fields.Char('已使用值')
code = fields.Char('机床刀位号')

View File

@@ -1,15 +1,21 @@
# -*- coding: utf-8 -*-
import logging
import base64
<<<<<<<
from collections import defaultdict, namedtuple
import requests
import logging
import json
from re import findall as regex_findall
from datetime import datetime, timedelta
from re import split as regex_split
import requests
from odoo import SUPERUSER_ID, _, api, fields, models
from odoo.tools import float_compare
from collections import defaultdict, namedtuple
from odoo.addons.stock.models.stock_rule import ProcurementException
from odoo.addons.sf_base.commons.common import Common
from odoo.exceptions import ValidationError, UserError
from odoo.exceptions import UserError
@@ -306,12 +312,12 @@ class StockPicking(models.Model):
res = super().button_validate()
# 采购单验证(夹具)
for item in self.move_ids_without_package:
if item.quantity_done > 0:
if item.product_id.categ_type == '夹具':
item._register_fixture()
elif item.product_id.categ_type == '刀具':
item._register_cutting_tool()
# for item in self.move_ids_without_package:
# if item.quantity_done > 0:
# if item.product_id.categ_type == '夹具':
# item._register_fixture()
# elif item.product_id.categ_type == '刀具':
# item._register_cutting_tool()
return res
# 创建 外协出库入单