@@ -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/6] =?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 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
Date: Fri, 12 Apr 2024 16:15:02 +0800
Subject: [PATCH 4/6] =?UTF-8?q?1=E3=80=81=E8=B0=83=E6=95=B4=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E6=B8=85=E5=8D=95=E6=A8=A1=E5=9E=8B?=
=?UTF-8?q?=E7=9A=84=E8=8F=9C=E5=8D=95=E4=BB=A3=E7=A0=81=E4=BD=8D=E7=BD=AE?=
=?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E4=BE=9D=E8=B5=96=E5=86=B2=E7=AA=81?=
=?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B2=E3=80=81=E4=BA=A7=E5=93=81?=
=?UTF-8?q?=E9=87=87=E8=B4=AD=E6=97=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=80?=
=?UTF-8?q?=E4=B8=AA=E8=AE=A2=E5=8D=95=E5=90=8C=E6=97=B6=E9=87=87=E8=B4=AD?=
=?UTF-8?q?=E5=A4=9A=E4=B8=AA=E7=9B=B8=E5=90=8C=E4=BA=A7=E5=93=81=E7=9A=84?=
=?UTF-8?q?=E6=A0=A1=E9=AA=8C=EF=BC=9B3=E3=80=81=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E5=88=80=E6=9F=84=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93=E6=97=B6?=
=?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E7=9A=84=E5=BA=8F?=
=?UTF-8?q?=E5=88=97=E5=8F=B7=E8=A7=84=E5=88=99=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_base/views/tool_menu.xml | 44 ++++++++++++--------
sf_base/views/tool_views.xml | 9 ----
sf_manufacturing/models/stock.py | 70 ++++++++++++++++++++++++++++++--
sf_sale/models/sale_order.py | 10 +++++
4 files changed, 102 insertions(+), 31 deletions(-)
diff --git a/sf_base/views/tool_menu.xml b/sf_base/views/tool_menu.xml
index bad606d6..263d11fa 100644
--- a/sf_base/views/tool_menu.xml
+++ b/sf_base/views/tool_menu.xml
@@ -21,7 +21,7 @@
刀具标准库
ir.actions.act_window
sf.cutting_tool.standard.library
-
+
tree,form
@@ -69,14 +69,22 @@
sequence="20"
action="action_sf_cutting_tool_standard_library"
/>
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ id="menu_sf_maintenance_equipment_image"
+ name="能力特征库"
+ parent="menu_sf_cutting_tool"
+ action="action_maintenance_equipment_image"
+ sequence="40"/>
+ id="menu_sf_tool_groups"
+ name="刀具组"
+ parent="menu_sf_cutting_tool"
+ action="sf_tool_groups_view_act"
+ sequence="50"/>
diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml
index e52a6222..1e82b8c2 100644
--- a/sf_base/views/tool_views.xml
+++ b/sf_base/views/tool_views.xml
@@ -609,13 +609,4 @@
tree
-
-
-
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index 80a334ce..94a9d646 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -317,13 +317,15 @@ class ProductionLot(models.Model):
"""
now = datetime.now().strftime("%Y%m%d")
last_serial = self.env['stock.lot'].search(
- [('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'like', now)],
+ [('company_id', '=', company.id), ('product_id', '=', product.id)],
limit=1, order='id DESC')
if product.cutting_tool_model_id:
+ split_codes = product.cutting_tool_model_id.code.split('-')
if not last_serial:
- return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
+ return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1)
else:
- return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 1)
+ return "%s-T-%s-%s-%03d" % (
+ split_codes[0], now, product.specification_id.name, int(last_serial.name[-3:]) + 1)
else:
raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!')
@@ -341,7 +343,8 @@ class ProductionLot(models.Model):
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1]
now = datetime.now().strftime("%Y%m%d")
if product.cutting_tool_model_id:
- return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
+ split_codes = product.cutting_tool_model_id.code.split('-')
+ return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1)
return "%s-%03d" % (product.name, 1)
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
@@ -539,6 +542,65 @@ class ReStockMove(models.Model):
else:
raise UserError(_("没有可打印的标签数据"))
+ def action_show_details(self):
+ """ Returns an action that will open a form view (in a popup) allowing to work on all the
+ move lines of a particular move. This form view is used when "show operations" is not
+ checked on the picking type.
+ """
+ self.ensure_one()
+
+ # If "show suggestions" is not checked on the picking type, we have to filter out the
+ # reserved move lines. We do this by displaying `move_line_nosuggest_ids`. We use
+ # different views to display one field or another so that the webclient doesn't have to
+ # fetch both.
+ if self.picking_type_id.show_reserved:
+ view = self.env.ref('stock.view_stock_move_operations')
+ else:
+ view = self.env.ref('stock.view_stock_move_nosuggest_operations')
+
+ if self.product_id.tracking == "serial" and self.state == "assigned":
+ print(self.origin)
+ if self.product_id.categ_id.name == '刀具':
+ self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
+ else:
+ self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
+
+ return {
+ 'name': _('Detailed Operations'),
+ 'type': 'ir.actions.act_window',
+ 'view_mode': 'form',
+ 'res_model': 'stock.move',
+ 'views': [(view.id, 'form')],
+ 'view_id': view.id,
+ 'target': 'new',
+ 'res_id': self.id,
+ 'context': dict(
+ self.env.context,
+ show_owner=self.picking_type_id.code != 'incoming',
+ show_lots_m2o=self.has_tracking != 'none' and (
+ self.picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id),
+ # able to create lots, whatever the value of ` use_create_lots`.
+ show_lots_text=self.has_tracking != 'none' and self.picking_type_id.use_create_lots and not self.picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id,
+ show_source_location=self.picking_type_id.code != 'incoming',
+ show_destination_location=self.picking_type_id.code != 'outgoing',
+ show_package=not self.location_id.usage == 'supplier',
+ show_reserved_quantity=self.state != 'done' and not self.picking_id.immediate_transfer and self.picking_type_id.code != 'incoming'
+ ),
+ }
+
+ def _get_tool_next_serial(self, company, product, origin):
+ """Return the next serial number to be attributed to the product."""
+ if product.tracking == "serial":
+ last_serial = self.env['stock.lot'].search(
+ [('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', origin)],
+ limit=1, order='id DESC')
+ split_codes = product.cutting_tool_model_id.code.split('-')
+ if last_serial:
+ return "%s-T-%s-%s-%03d" % (
+ split_codes[0], origin, product.specification_id.name, int(last_serial.name[-3:]) + 1)
+ else:
+ return "%s-T-%s-%s-%03d" % (split_codes[0], origin, product.specification_id.name, 1)
+
class ReStockQuant(models.Model):
_inherit = 'stock.quant'
diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py
index e2313ba3..05523194 100644
--- a/sf_sale/models/sale_order.py
+++ b/sf_sale/models/sale_order.py
@@ -206,6 +206,16 @@ class RePurchaseOrder(models.Model):
order.message_subscribe([order.partner_id.id])
return True
+ @api.onchange('order_line')
+ def _onchange_order_line(self):
+ for order in self:
+ if order.order_line:
+ line = order.order_line
+ product = line.product_id
+ product_id = product.ids
+ if len(product_id) != len(line):
+ raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
+
class ResPartnerToSale(models.Model):
_inherit = 'res.partner'
From 3c47553be6062b8bde01577e199855ecd59c1157 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Tue, 16 Apr 2024 17:22:16 +0800
Subject: [PATCH 5/6] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E9=94=80?=
=?UTF-8?q?=E5=94=AE=E6=80=BB=E7=9B=91=E5=92=8C=E9=87=87=E8=B4=AD=E6=80=BB?=
=?UTF-8?q?=E7=9B=91=E5=AF=B9=E5=A4=B9=E5=85=B7=E7=9A=84=E5=8F=AF=E8=AF=BB?=
=?UTF-8?q?=E6=9D=83=E9=99=90=EF=BC=9B2=E3=80=81=E5=B7=A5=E5=8D=95?=
=?UTF-8?q?=E7=9A=84tree=E8=A7=86=E5=9B=BE=E6=B7=BB=E5=8A=A0=E5=88=B6?=
=?UTF-8?q?=E9=80=A0=E8=AE=A2=E5=8D=95=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_base/security/ir.model.access.csv | 16 +++++++++++++++-
sf_manufacturing/views/mrp_workorder_view.xml | 3 +++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv
index 9d027bdb..c0f53f98 100644
--- a/sf_base/security/ir.model.access.csv
+++ b/sf_base/security/ir.model.access.csv
@@ -199,4 +199,18 @@ access_group_sf_mrp_user_admin,sf_tool_inventory_admin,model_sf_tool_inventory,b
access_group_sf_mrp_user_group_purchase_director,sf_tool_inventory_group_purchase_director,model_sf_tool_inventory,sf_base.group_purchase_director,1,0,1,0
access_group_sf_mrp_user_group_sale_director,sf_tool_inventory_group_sale_director,model_sf_tool_inventory,sf_base.group_sale_director,1,0,1,0
access_sf_cutting_tool_material_group_plan_director,sf_tool_inventory_group_plan_director,model_sf_tool_inventory,sf_base.group_plan_director,1,0,1,0
-access_group_sf_mrp_user_group_sf_mrp_user,sf_tool_inventory_group_sf_mrp_user,model_sf_tool_inventory,sf_base.group_sf_mrp_user,1,1,0,0
\ No newline at end of file
+access_group_sf_mrp_user_group_sf_mrp_user,sf_tool_inventory_group_sf_mrp_user,model_sf_tool_inventory,sf_base.group_sf_mrp_user,1,1,0,0
+
+
+access_sf_fixture_material_group_purchase_director,sf_fixture_material_group_purchase_director,model_sf_fixture_material,sf_base.group_purchase_director,1,0,0,0
+access_sf_multi_mounting_type_group_purchase_director,sf_multi_mounting_type_group_purchase_director,model_sf_multi_mounting_type,sf_base.group_purchase_director,1,0,0,0
+access_sf_fixture_model_group_purchase_director,sf_fixture_model_group_purchase_director,model_sf_fixture_model,sf_base.group_purchase_director,1,0,0,0
+access_sf_fixture_materials_basic_parameters_group_purchase_director,sf_fixture_materials_basic_parameters_group_purchase_director,model_sf_fixture_materials_basic_parameters,sf_base.group_purchase_director,1,0,0,0
+access_sf_machine_tool_type_group_purchase_director,sf_machine_tool_type_group_purchase_director,model_sf_machine_tool_type,sf_base.group_purchase_director,1,0,0,0
+
+access_sf_fixture_material_group_sale_director,sf_fixture_material_group_sale_director,model_sf_fixture_material,sf_base.group_sale_director,1,0,0,0
+access_sf_multi_mounting_type_group_sale_director,sf_multi_mounting_type_group_sale_director,model_sf_multi_mounting_type,sf_base.group_sale_director,1,0,0,0
+access_sf_fixture_model_group_sale_director,sf_fixture_model_group_sale_director,model_sf_fixture_model,sf_base.group_sale_director,1,0,0,0
+access_sf_fixture_materials_basic_parameters_group_sale_director,sf_fixture_materials_basic_parameters_group_sale_director,model_sf_fixture_materials_basic_parameters,sf_base.group_sale_director,1,0,0,0
+access_sf_machine_tool_type_group_sale_director,sf_machine_tool_type_group_sale_director,model_sf_machine_tool_type,sf_base.group_sale_director,1,0,0,0
+
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index 9a747791..61b4bd8b 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -46,6 +46,9 @@
1
+
+
+
From c6b1c5e0472750aba5a9e2a1f7ca3edf2a616b96 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Wed, 17 Apr 2024 14:55:45 +0800
Subject: [PATCH 6/6] =?UTF-8?q?1=E3=80=81=E5=88=A0=E9=99=A4=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E5=88=97=E8=A1=A8=E6=A8=A1=E5=9E=8B?=
=?UTF-8?q?=E7=9A=84=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0=E8=AE=A1=E7=AE=97?=
=?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E6=94=B9=E4=B8=BA=E5=88=9B=E5=BB=BA?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=97=B6=E7=BB=99=E6=95=B0=E6=8D=AE=EF=BC=9B?=
=?UTF-8?q?2=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84?=
=?UTF-8?q?=E8=A3=85=E5=8D=95=E5=BC=B9=E7=AA=97=E6=B7=BB=E5=8A=A0=E6=A0=B9?=
=?UTF-8?q?=E6=8D=AE=E6=97=A7=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E9=80=89=E6=8B=A9=E6=96=B0=E5=88=80=E5=85=B7=E7=9A=84?=
=?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=9B=E4=BC=98=E5=8C=96=E6=B2=A1=E6=9C=89?=
=?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8F=B7=E7=9A=84=E5=88=80=E5=85=B7=E7=89=A9?=
=?UTF-8?q?=E6=96=99=E7=9A=84=E5=BA=93=E5=AD=98=E4=BD=8D=E7=A7=BB=E6=96=B9?=
=?UTF-8?q?=E6=B3=95=EF=BC=8C=E5=B9=B6=E5=9C=A8=E5=88=80=E5=85=B7=E7=89=A9?=
=?UTF-8?q?=E6=96=99=E5=87=BA=E5=BA=93=E5=90=8C=E6=97=B6=E8=B4=A7=E4=BD=8D?=
=?UTF-8?q?=E7=89=A9=E6=96=99=E6=95=B0=E5=87=8F=E4=B8=80=EF=BC=9B=E5=85=B3?=
=?UTF-8?q?=E9=97=AD=E5=BC=B9=E7=AA=97=E5=88=9B=E5=BB=BA=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E7=BB=84=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D?=
=?UTF-8?q?=E7=A7=B0=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/functional_tool.py | 22 ++-----------
.../views/functional_tool_views.xml | 7 +++--
sf_tool_management/wizard/wizard.py | 31 +++++++++++++------
sf_tool_management/wizard/wizard_view.xml | 8 +++--
4 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py
index 478fb744..c37d5317 100644
--- a/sf_tool_management/models/functional_tool.py
+++ b/sf_tool_management/models/functional_tool.py
@@ -11,27 +11,11 @@ class FunctionalCuttingToolEntity(models.Model):
_description = '功能刀具列表'
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具组装单', readonly=True)
-
- @api.depends('functional_tool_name_id')
- def _compute_name(self):
- for item in self:
- if item.functional_tool_name_id:
- name = item.functional_tool_name_id.after_assembly_functional_tool_name
- inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', name)])
- item.name = name
- if inventory:
- item.tool_name_id = inventory.id
- else:
- item.tool_name_id = False
- else:
- item.name = ''
- item.tool_name_id = False
-
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
code = fields.Char('编码')
rfid = fields.Char('Rfid', readonly=True)
- name = fields.Char('名称', compute='_compute_name', stroe=True)
- tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称', compute='_compute_name', store=True)
+ name = fields.Char('名称')
+ tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称')
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
@@ -302,7 +286,7 @@ class StockMoveLine(models.Model):
_description = '功能刀具出入库记录'
_order = 'date desc'
- functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称')
+ functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具组装单')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
group_expand='_read_group_functional_tool_type_id')
functional_tool_name = fields.Char('刀具名称')
diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml
index d8907859..82fbd8bc 100644
--- a/sf_tool_management/views/functional_tool_views.xml
+++ b/sf_tool_management/views/functional_tool_views.xml
@@ -397,7 +397,7 @@
-
+
@@ -458,7 +458,8 @@
-
+
+
@@ -481,7 +482,7 @@
-
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index b6f963f6..979d8efe 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -221,6 +221,14 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
image = fields.Binary('图片')
+ @api.onchange('functional_tool_name')
+ def _onchange_functional_tool_name(self):
+ for item in self:
+ if item.functional_tool_name:
+ inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)])
+ if inventory:
+ item.after_name_id = inventory.id
+
# 功能刀具组装信息
# ===============整体式刀具型号=================
integral_freight_barcode = fields.Char('整体式刀具货位')
@@ -461,7 +469,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
obj.tool_code = str_2
def _get_code(self, str_2):
- functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search(
+ functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(
[('code', 'like', str_2)],
limit=1,
order="id desc"
@@ -548,15 +556,15 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
if self.handle_code_id:
product_id.tool_material_stock_moves(self.handle_code_id)
if self.integral_product_id:
- self.integral_product_id.material_stock_moves()
+ self.integral_product_id.material_stock_moves(self.integral_freight_barcode)
if self.blade_product_id:
- self.blade_product_id.material_stock_moves()
+ self.blade_product_id.material_stock_moves(self.blade_freight_barcode)
if self.bar_product_id:
- self.bar_product_id.material_stock_moves()
+ self.bar_product_id.material_stock_moves(self.bar_freight_barcode)
if self.pad_product_id:
- self.pad_product_id.material_stock_moves()
+ self.pad_product_id.material_stock_moves(self.pad_freight_barcode)
if self.chuck_product_id:
- self.chuck_product_id.material_stock_moves()
+ self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode)
# ============================创建功能刀具列表、安全库存记录===============================
# 封装功能刀具数据
@@ -643,7 +651,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
return {
'barcode_id': stock_lot.id,
'code': self.tool_code,
- 'name': self.after_assembly_functional_tool_name,
+ 'name': self.after_name_id.name,
+ 'tool_name_id': self.after_name_id.id,
'rfid': self.rfid,
'tool_groups_id': self.after_tool_groups_id.id,
'functional_tool_name_id': functional_tool_assembly_id.id,
@@ -784,7 +793,7 @@ class ProductProduct(models.Model):
# 创建功能刀具该批次/序列号 库存移动和移动历史
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False)
- def material_stock_moves(self):
+ def material_stock_moves(self, shelf_location_barcode):
# 创建库存移动记录
stock_move_id = self.env['stock.move'].sudo().create({
'name': '功能刀具组装',
@@ -795,15 +804,19 @@ class ProductProduct(models.Model):
'state': 'done'
})
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
# 创建移动历史记录
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.id,
- 'lot_id': self.id,
'move_id': stock_move_id.id,
+ 'current_location_id': location.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',
})
+
+ location.product_num = location.product_num - 1
+
return stock_move_id, stock_move_line_id
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index 386c8d7c..0eb2a77f 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -288,7 +288,7 @@
+ attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
@@ -336,11 +336,13 @@
-
+
-
+