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

This commit is contained in:
龚启豪
2023-12-06 11:35:01 +08:00
51 changed files with 1283 additions and 668 deletions

View File

@@ -1,4 +1,4 @@
from odoo import fields, models, api
from odoo import fields, models
class ModelType(models.Model):

View File

@@ -87,22 +87,20 @@ class ResProductMo(models.Model):
cutting_tool_run_out_accuracy_max = fields.Float('端跳精度max', digits=(6, 1))
cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1))
cutting_tool_blade_tip_working_size = fields.Char('刀尖处理尺寸(R半径mm/倒角)', size=20)
fit_blade_shape_id = fields.Many2many('maintenance.equipment.image', 'rel_fit_blade_shape_product_template',
'适配刀片形状', domain=[('type', '=', '刀片形状')])
fit_blade_shape_id = fields.Many2one('maintenance.equipment.image',
'适配刀片形状', domain=[('type', '=', '刀片形状')])
suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image',
'rel_machining_product_template', '适合加工方式',
domain=[('type', '=', '加工能力')])
blade_tip_characteristics_id = fields.Many2many('maintenance.equipment.image',
'rel_blade_tip_product_template', '刀尖特征',
domain=[('type', '=', '刀尖特征')])
handle_type_ids = fields.Many2many('maintenance.equipment.image', 'rel_handle_product_template', '柄部类型',
domain=[('type', '=', '柄部类型')])
blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image', '刀尖特征',
domain=[('type', '=', '刀尖特征')])
handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')])
cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'rel_cutting_product_template',
'走刀方向', domain=[('type', '=', '走刀方向')])
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolant_product_template',
'适合冷却液', domain=[('type', '=', '冷却液')])
compaction_way_ids = fields.Many2many('maintenance.equipment.image', 'rel_compaction_product_template',
'压紧方式', domain=[('type', '=', '压紧方式')])
compaction_way_id = fields.Many2one('maintenance.equipment.image',
'压紧方式', domain=[('type', '=', '压紧方式')])
@api.onchange('cutting_tool_material_id')
def _onchange_cutting_tool_material_id(self):
@@ -141,10 +139,10 @@ class ResProductMo(models.Model):
item.fit_blade_shape_id = False
item.suitable_machining_method_ids = False
item.blade_tip_characteristics_id = False
item.handle_type_ids = False
item.handle_type_id = False
item.cutting_direction_ids = False
item.suitable_coolant_ids = False
item.compaction_way_ids = False
item.compaction_way_id = False
item.cutting_speed_ids = False
item.feed_per_tooth_ids = False
@@ -288,13 +286,9 @@ class ResProductMo(models.Model):
self.suitable_machining_method_ids = [(6, 0, [])] if not \
self.cutting_tool_model_id.suitable_machining_method_ids \
else [(6, 0, self.cutting_tool_model_id.suitable_machining_method_ids.ids)]
self.blade_tip_characteristics_id = [(6, 0, [])] if not \
self.cutting_tool_model_id.blade_tip_characteristics_id \
else [(6, 0, self.cutting_tool_model_id.blade_tip_characteristics_id.ids)]
self.blade_tip_characteristics_id = self.cutting_tool_model_id.blade_tip_characteristics_id.id
self.handle_type_ids = [(6, 0,
[])] if not self.cutting_tool_model_id.handle_type_ids else [
(6, 0, self.cutting_tool_model_id.handle_type_ids.ids)]
self.handle_type_id = self.cutting_tool_model_id.handle_type_id.id
self.cutting_direction_ids = [(6, 0,
[])] if not self.cutting_tool_model_id.cutting_direction_ids else [
@@ -303,9 +297,8 @@ class ResProductMo(models.Model):
self.suitable_coolant_ids = [(6, 0,
[])] if not self.cutting_tool_model_id.suitable_coolant_ids else [
(6, 0, self.cutting_tool_model_id.suitable_coolant_ids.ids)]
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)]
self.compaction_way_id = self.cutting_tool_model_id.compaction_way_id.id
self.fit_blade_shape_id = self.cutting_tool_model_id.fit_blade_shape_id.id
else:
self.cutting_tool_type_id = False
self.brand_id = False
@@ -338,28 +331,28 @@ class ResProductMo(models.Model):
self.fit_blade_shape_id = False
self.suitable_machining_method_ids = False
self.blade_tip_characteristics_id = False
self.handle_type_ids = False
self.handle_type_id = False
self.cutting_direction_ids = False
self.suitable_coolant_ids = False
self.compaction_way_ids = False
self.compaction_way_id = False
self.cutting_speed_ids = False
self.feed_per_tooth_ids = False
@api.constrains('fit_blade_shape_id', 'suitable_machining_method_ids', 'blade_tip_characteristics_id',
'handle_type_ids', 'cutting_direction_ids', 'suitable_coolant_ids', 'compaction_way_ids')
'handle_type_id', 'cutting_direction_ids', 'suitable_coolant_ids', 'compaction_way_id')
def _check_cutting_tool_ability(self):
if self.cutting_tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']:
if self.cutting_tool_type in ['刀片', '刀杆', '刀盘']:
if not self.fit_blade_shape_id:
raise ValidationError("请选择适配刀片形状")
if self.cutting_tool_type in ['刀杆', '刀盘']:
if not self.compaction_way_ids:
if not self.compaction_way_id:
raise ValidationError("请选择压紧方式")
if self.cutting_tool_type == '刀片':
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却液")
elif self.cutting_tool_type == '整体式刀具':
if not self.handle_type_ids:
if not self.handle_type_id:
raise ValidationError("请选择柄部类型")
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却液")
@@ -880,3 +873,13 @@ class SfMaintenanceEquipmentTool(models.Model):
for record in self:
if record.code:
record.name = record.code
@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

View File

@@ -5,7 +5,7 @@ import logging
import json
from re import split as regex_split
from re import findall as regex_findall
from datetime import datetime, timedelta
from datetime import datetime
import requests
from odoo import SUPERUSER_ID, _, api, fields, models
from odoo.tools import float_compare
@@ -149,8 +149,8 @@ class StockRule(models.Model):
raise ProcurementException(errors)
for company_id, productions_values in productions_values_by_company.items():
# create the MO as SUPERUSER because the current user may not have the rights to do it (mto product
# launched by a sale for example)
# create the MO as SUPERUSER because the current user may not have the rights to do it
# (mto product launched by a sale for example)
'''创建制造订单'''
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
productions_values)
@@ -201,18 +201,17 @@ class StockRule(models.Model):
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
if sale_order:
bb = sale_order.deadline_of_delivery
productions = self.env['sf.production.plan'].with_user(SUPERUSER_ID).sudo().with_company(company_id). \
create({
'name': production.name,
'order_deadline': sale_order.deadline_of_delivery,
'production_id': production.id,
'date_planned_start': production.date_planned_start,
'origin': production.origin,
'product_qty': production.product_qty,
'product_id': production.product_id.id,
'state': 'draft',
})
self.env['sf.production.plan'].sudo().with_company(company_id). \
create({
'name': production.name,
'order_deadline': sale_order.deadline_of_delivery,
'production_id': production.id,
'date_planned_start': production.date_planned_start,
'origin': production.origin,
'product_qty': production.product_qty,
'product_id': production.product_id.id,
'state': 'draft',
})
return True