From 0c44bba5f2b8314d4895b043fb9416c01c5a5b21 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 12 Mar 2024 17:32:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=80=E5=85=B7=E4=BA=A7?= =?UTF-8?q?=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/tool_base_new.py | 23 +- sf_base/models/tool_other_features.py | 3 +- sf_base/views/tool_basic_param.xml | 289 +++++++++++------- sf_base/views/tool_views.xml | 8 +- .../product_template_management_view.xml | 6 +- sf_manufacturing/models/product_template.py | 58 ++-- sf_sale/models/auto_quatotion_common.py | 2 +- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/sale_order.py | 4 +- 9 files changed, 238 insertions(+), 159 deletions(-) diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 03a3678b..7e87e3df 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -import json -import requests +from datetime import date from odoo import fields, models, api -from odoo.exceptions import ValidationError -from odoo.addons.sf_base.commons.common import Common class CuttingToolMaterial(models.Model): @@ -113,6 +110,24 @@ class CuttingToolModel(models.Model): feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(整体式刀具)') feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(刀片)') material_model_id = fields.Many2one('sf.materials.model', '材料型号') + + @api.onchange('cutting_tool_material_id') + def _get_code(self): + if self.is_cloud is False: + today = date.today().strftime("%Y%m%d") + today_code = 'T-DJWL-%s-%s' % (self.cutting_tool_material_id.code, today) + cutting_tool_model = self.search( + [('code', 'ilike', today_code), ('is_cloud', '=', False), + ('active', 'in', [True, False])], + limit=1, + order="id desc") + if not cutting_tool_model: + num = "%03d" % 1 + else: + m = int(today_code[-3:]) + 1 + num = "%03d" % m + return "%s%s" % (today_code, num) + # 适用夹头型号可以多选 # chuck_ids = fields.Many2many( # 'sf.cutting_tool.standard.library', diff --git a/sf_base/models/tool_other_features.py b/sf_base/models/tool_other_features.py index 7ad32bc2..ee83735b 100644 --- a/sf_base/models/tool_other_features.py +++ b/sf_base/models/tool_other_features.py @@ -10,6 +10,7 @@ class ToolMaterialsBasicParameters(models.Model): standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具标准库') cutting_tool_type = fields.Char(related='standard_library_id.cutting_tool_type', string='刀具物料类型', store=True) + is_cloud = fields.Boolean(related='standard_library_id.is_cloud', string='云端数据') # 整体式刀具参数 total_length = fields.Float('总长度(mm)') @@ -170,8 +171,6 @@ class FeedPerTooth(models.Model): feed_per_tooth = fields.Char('每齿走刀量 (mm/z)', size=20) active = fields.Boolean(string='有效', default=True) - - # @api.depends('product_template_id') # def _compute_product_template_id(self): # if self.product_template_id is not None: diff --git a/sf_base/views/tool_basic_param.xml b/sf_base/views/tool_basic_param.xml index 616905ca..f73bf71c 100644 --- a/sf_base/views/tool_basic_param.xml +++ b/sf_base/views/tool_basic_param.xml @@ -1,132 +1,189 @@ - - - sf.tool.materials.basic.parameters.tree - sf.tool.materials.basic.parameters - - - - - - - - - - - - - - - - - - - - - + + + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + - - sf.tool.materials.basic.parameters.tree - sf.tool.materials.basic.parameters - - - - - - - - - - - - - - - - - - - - - - - - + + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + + + + - sf.tool.materials.basic.parameters.tree - sf.tool.materials.basic.parameters - - - - - - - - - - - - - - - - - - - - - - + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + + - sf.tool.materials.basic.parameters.tree - sf.tool.materials.basic.parameters - - - - - - - - - - - - - - - - - - - - - + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + - - sf.tool.materials.basic.parameters.search - sf.tool.materials.basic.parameters - - - - - - + + sf.tool.materials.basic.parameters.search + sf.tool.materials.basic.parameters + + + + + + - - 基础参数 - sf.tool.materials.basic.parameters - tree + + sf.tool.materials.basic.parameters.form + sf.tool.materials.basic.parameters + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
- - [] - -
+ + 基础参数 + sf.tool.materials.basic.parameters + form + {'default_cutting_tool_type': cutting_tool_type} + [] + +
diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index d1c0c510..a9604773 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -123,7 +123,7 @@
+ options="{'zoom': true, 'preview_image':'image_128'}" required="1"/>

@@ -133,9 +133,9 @@ - - - + + +