@@ -283,33 +308,6 @@
-
@@ -334,37 +332,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
From 4391a4e1454dacc7ccbba49e781df893b9ec5755 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Thu, 11 Apr 2024 17:34:15 +0800
Subject: [PATCH 3/3] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E6=B8=85=E5=8D=95=E6=A8=A1=E5=9E=8B=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0=E9=87=8D?=
=?UTF-8?q?=E5=90=8D=E6=A3=80=E9=AA=8C=EF=BC=8C2=E3=80=81=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E5=AE=89=E5=85=A8=E5=BA=93=E5=AD=98?=
=?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=B7=BB=E5=8A=A0=E6=A0=B9=E6=8D=AE=E6=89=80?=
=?UTF-8?q?=E9=80=89=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0?=
=?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=B8=A6=E5=87=BA=E7=B1=BB=E5=9E=8B=E3=80=81?=
=?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E3=80=81=E7=9B=B4=E5=BE=84=E3=80=81?=
=?UTF-8?q?R=E8=A7=92=E4=BF=A1=E6=81=AF=EF=BC=9B3=E3=80=81=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E6=90=9C=E7=B4=A2?=
=?UTF-8?q?=E6=A8=A1=E5=9E=8B=EF=BC=8C=E7=89=A9=E6=96=99=E6=95=B0=E9=87=8F?=
=?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=94=B9=E4=B8=BA=E5=AD=98=E5=82=A8=E5=AD=97?=
=?UTF-8?q?=E6=AE=B5=EF=BC=8C=E6=A0=B9=E6=8D=AE=E5=AF=B9=E5=BA=94=E4=BA=A7?=
=?UTF-8?q?=E5=93=81=E7=9A=84=E5=90=84=E4=B8=AA=E4=BD=8D=E7=BD=AE=E7=9A=84?=
=?UTF-8?q?=E5=BA=93=E5=AD=98=E6=95=B0=E9=87=8F=E8=87=AA=E5=8A=A8=E8=AE=A1?=
=?UTF-8?q?=E7=AE=97=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E7=9A=84=E6=80=BB?=
=?UTF-8?q?=E6=95=B0=E7=AD=89=E5=80=BC=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_base/models/tool_base_new.py | 14 ++++++++
sf_tool_management/models/functional_tool.py | 9 +++++
.../models/tool_material_search.py | 35 ++++---------------
.../views/functional_tool_views.xml | 32 +++++++++--------
4 files changed, 47 insertions(+), 43 deletions(-)
diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py
index f2010b4a..3aa85ceb 100644
--- a/sf_base/models/tool_base_new.py
+++ b/sf_base/models/tool_base_new.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from datetime import date
from odoo import fields, models, api
+from odoo.exceptions import UserError
class CuttingToolMaterial(models.Model):
@@ -333,3 +334,16 @@ class ToolInventory(models.Model):
tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组')
active = fields.Boolean('已归档', default=True)
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ # 名称重复校验
+ name_list = []
+ for val in vals_list:
+ tool_inventory = self.search([('name', '=', val['name'])])
+ if tool_inventory:
+ name_list.append(val['name'])
+ if name_list:
+ raise UserError("功能刀具名称%s已存在,请重新输入" % name_list)
+ records = super(ToolInventory, self).create(vals_list)
+ return records
diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py
index 334511a6..478fb744 100644
--- a/sf_tool_management/models/functional_tool.py
+++ b/sf_tool_management/models/functional_tool.py
@@ -370,6 +370,15 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
active = fields.Boolean(string='已归档', default=True)
+ @api.onchange('functional_name_id')
+ def _onchange_num(self):
+ for item in self:
+ if item.functional_name_id:
+ item.tool_groups_id = item.functional_name_id.tool_groups_id.id
+ item.sf_cutting_tool_type_id = item.functional_name_id.functional_cutting_tool_model_id.id
+ item.diameter = item.functional_name_id.diameter
+ item.knife_tip_r_angle = item.functional_name_id.angle
+
@api.depends('functional_name_id')
def _compute_name(self):
for obj in self:
diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py
index 1338d758..bfb8d64b 100644
--- a/sf_tool_management/models/tool_material_search.py
+++ b/sf_tool_management/models/tool_material_search.py
@@ -20,14 +20,14 @@ class ToolMaterial(models.Model):
specification_id = fields.Many2one('sf.tool.materials.basic.parameters', '规格',
related='product_id.specification_id')
image = fields.Binary('图片', related='product_id.image_1920')
- number = fields.Integer('总数量', compute='_compute_number')
- usable_num = fields.Integer('可用数量', compute='_compute_number')
- have_been_used_num = fields.Integer('在用数量', compute='_compute_number')
- scrap_num = fields.Integer('报废数量', compute='_compute_number')
+ number = fields.Integer('总数量', compute='_compute_number', store=True)
+ usable_num = fields.Integer('可用数量', compute='_compute_number', store=True)
+ have_been_used_num = fields.Integer('在用数量', compute='_compute_number', store=True)
+ scrap_num = fields.Integer('报废数量', compute='_compute_number', store=True)
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
- @api.depends('product_id')
+ @api.depends('product_id.stock_quant_ids.quantity')
def _compute_number(self):
for record in self:
usable_num = 0
@@ -47,29 +47,8 @@ class ToolMaterial(models.Model):
record.have_been_used_num = have_been_used_num
record.scrap_num = scrap_num
record.number = usable_num + have_been_used_num + scrap_num
-
- # @api.depends('barcode_ids')
- # def _compute_number(self):
- # for record in self:
- # usable_num = 0
- # have_been_used_num = 0
- # scrap_num = 0
- # if record.barcode_ids:
- # record.number = len(record.barcode_ids)
- # for barcode_id in record.barcode_ids:
- # if barcode_id.quant_ids:
- # if barcode_id.quant_ids[-1].location_id.name == '刀具组装位置':
- # have_been_used_num = have_been_used_num + 1
- # else:
- # usable_num = usable_num + 1
- # record.usable_num = usable_num
- # record.have_been_used_num = have_been_used_num
- # record.scrap_num = scrap_num
- # else:
- # record.number = 0
- # record.usable_num = 0
- # record.have_been_used_num = 0
- # record.scrap_num = 0
+ # 更新数据到cloud的动态数据
+ record.enroll_tool_material()
@api.model
def _read_group_cutting_tool_material_id(self, categories, domain, order):
diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml
index 1e30dc41..d8907859 100644
--- a/sf_tool_management/views/functional_tool_views.xml
+++ b/sf_tool_management/views/functional_tool_views.xml
@@ -338,21 +338,23 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+