From ce67b7985b3c0f82f319ce9b3b8adc615d6cec91 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 20 Dec 2023 15:21:06 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=92=8C=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=BC=B9=E7=AA=97=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=88=80=E5=85=B7=E7=89=A9?= =?UTF-8?q?=E6=96=99=E8=A7=84=E6=A0=BC=E5=AD=97=E6=AE=B5=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E7=A1=AE=E8=AE=A4=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E4=BD=9C=E4=B8=9A=E6=97=B6=E6=96=B0=E5=A2=9Ename?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=86=85=E5=AE=B9=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=87=AA=E5=8A=A8=E9=AA=8C=E8=AF=81=EF=BC=9B?= =?UTF-8?q?3=E3=80=81=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8F=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 103 ++++------- sf_tool_management/views/tool_base_views.xml | 6 + sf_tool_management/wizard/wizard.py | 172 +++++++++---------- sf_tool_management/wizard/wizard_view.xml | 30 ++-- 4 files changed, 129 insertions(+), 182 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 44b2b912..3a919de7 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -657,91 +657,52 @@ class FunctionalToolAssembly(models.Model): # 整体式刀具型号 integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', readonly=True) cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', - readonly=True) - integral_name = fields.Char('整体式刀具名称', readonly=True, compute='_compute_auto_fill') - sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True) + related='integral_code_id.product_id.cutting_tool_model_id') + integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name') + integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格', + related='integral_code_id.product_id.specification_id') + sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', + related='integral_code_id.product_id.brand_id') # 刀片型号 blade_code_id = fields.Many2one('stock.lot', '刀片序列号', readonly=True) - cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True) - blade_name = fields.Char('刀片名称', readonly=True, compute='_compute_auto_fill') - sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True) + cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', + related='blade_code_id.product_id.cutting_tool_model_id') + blade_name = fields.Char('刀片名称', related='blade_code_id.product_id.name') + blade_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀片规格', + related='blade_code_id.product_id.specification_id') + sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_code_id.product_id.brand_id') # 刀杆型号 bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', readonly=True) cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', - readonly=True) - bar_name = fields.Char('刀杆名称', readonly=True, compute='_compute_auto_fill') - sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True) + related='bar_code_id.product_id.cutting_tool_model_id') + bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name') + bar_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀杆规格', + related='bar_code_id.product_id.specification_id') + sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_code_id.product_id.brand_id') # 刀盘型号 pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', readonly=True) cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', - readonly=True) - pad_name = fields.Char('刀盘名称', readonly=True, compute='_compute_auto_fill') - sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True) + related='pad_code_id.product_id.cutting_tool_model_id') + pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name') + pad_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀盘规格', + related='pad_code_id.product_id.specification_id') + sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_code_id.product_id.brand_id') # 刀柄型号 handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', readonly=True) cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', - readonly=True) - handle_name = fields.Char('刀柄名称', readonly=True, compute='_compute_auto_fill') - sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True) + related='handle_code_id.product_id.cutting_tool_model_id') + handle_name = fields.Char('刀柄名称', related='handle_code_id.product_id.name') + handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格', + related='handle_code_id.product_id.specification_id') + sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id') # 夹头型号 chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', readonly=True) cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', - readonly=True) - chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill') - sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) - - @api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id') - def _compute_auto_fill(self): - for record in self: - if record.integral_code_id: - print(record.integral_code_id.product_id) - record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_model_id.id - record.integral_name = record.integral_code_id.product_id.name - record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id - else: - record.cutting_tool_integral_model_id = None - record.integral_name = None - record.sf_tool_brand_id_1 = None - if record.blade_code_id: - record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_model_id.id - record.blade_name = record.blade_code_id.product_id.name - record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id - else: - record.cutting_tool_blade_model_id = None - record.blade_name = None - record.sf_tool_brand_id_2 = None - if record.bar_code_id: - record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_model_id.id - record.bar_name = record.bar_code_id.product_id.name - record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterbar_model_id = None - record.bar_name = None - record.sf_tool_brand_id_3 = None - if record.pad_code_id: - record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_model_id.id - record.pad_name = record.pad_code_id.product_id.name - record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterpad_model_id = None - record.pad_name = None - record.sf_tool_brand_id_4 = None - if record.handle_code_id: - record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_model_id.id - record.handle_name = record.handle_code_id.product_id.name - record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterhandle_model_id = None - record.handle_name = None - record.sf_tool_brand_id_5 = None - if record.chuck_code_id: - record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_model_id.id - record.chuck_name = record.chuck_code_id.product_id.name - record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterhead_model_id = None - record.chuck_name = None - record.sf_tool_brand_id_6 = None + related='chuck_code_id.product_id.cutting_tool_model_id') + chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name') + chuck_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='夹头规格', + related='chuck_code_id.product_id.specification_id') + sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_code_id.product_id.brand_id') # 组装功能刀具参数信息 barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index c4202131..68b595b0 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -1012,6 +1012,7 @@ options="{'no_create': True, 'no_quick_create': True}"/> + @@ -1024,6 +1025,7 @@ options="{'no_create': True, 'no_quick_create': True}"/> + @@ -1036,6 +1038,7 @@ options="{'no_create': True, 'no_quick_create': True}"/> + @@ -1051,6 +1054,7 @@ options="{'no_create': True, 'no_quick_create': True}"/> + @@ -1065,6 +1069,7 @@ options="{'no_create': True, 'no_quick_create': True}"/> + @@ -1079,6 +1084,7 @@ options="{'no_create': True, 'no_quick_create': True}"/> + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index b198c2e7..89b9f854 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -1,4 +1,4 @@ -from datetime import timedelta +from datetime import timedelta, datetime from odoo import fields, models, api from odoo.exceptions import ValidationError @@ -213,18 +213,24 @@ class FunctionalToolAssemblyOrder(models.TransientModel): ('quant_ids.location_id.name', 'in', ['刀具房']), ('quant_ids.quantity', '>', 0)]) cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', - readonly=True) - integral_name = fields.Char('整体式刀具名称', readonly=True) - sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True) + related='integral_code_id.product_id.cutting_tool_model_id') + integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name') + integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格', + related='integral_code_id.product_id.specification_id') + sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', + related='integral_code_id.product_id.brand_id') # 刀片型号 blade_code_id = fields.Many2one('stock.lot', '刀片序列号', domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'), ('quant_ids.location_id.name', 'in', ['刀具房']), ('quant_ids.quantity', '>', 0)]) - cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True) - blade_name = fields.Char('刀片名称', readonly=True) - sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True) + cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', + related='blade_code_id.product_id.cutting_tool_model_id') + blade_name = fields.Char('刀片名称', related='blade_code_id.product_id.name') + blade_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀片规格', + related='blade_code_id.product_id.specification_id') + sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_code_id.product_id.brand_id') # 刀杆型号 bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', @@ -232,9 +238,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel): ('quant_ids.location_id.name', 'in', ['刀具房']), ('quant_ids.quantity', '>', 0)]) cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', - readonly=True) - bar_name = fields.Char('刀杆名称', readonly=True) - sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True) + related='bar_code_id.product_id.cutting_tool_model_id') + bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name') + bar_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀杆规格', + related='bar_code_id.product_id.specification_id') + sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_code_id.product_id.brand_id') # 刀盘型号 pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', @@ -242,9 +250,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel): ('quant_ids.location_id.name', 'in', ['刀具房']), ('quant_ids.quantity', '>', 0)]) cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', - readonly=True) - pad_name = fields.Char('刀盘名称', readonly=True) - sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True) + related='pad_code_id.product_id.cutting_tool_model_id') + pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name') + pad_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀盘规格', + related='pad_code_id.product_id.specification_id') + sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_code_id.product_id.brand_id') # 刀柄型号 handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True, @@ -252,9 +262,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel): ('quant_ids.location_id.name', 'in', ['刀具房']), ('quant_ids.quantity', '>', 0)]) cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', - readonly=True) - handle_name = fields.Char('刀柄名称', readonly=True) - sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True) + related='handle_code_id.product_id.cutting_tool_model_id') + handle_name = fields.Char('刀柄名称', related='handle_code_id.product_id.name') + handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格', + related='handle_code_id.product_id.specification_id') + sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id') # 夹头型号 chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True, @@ -262,9 +274,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel): ('quant_ids.location_id.name', 'in', ['刀具房']), ('quant_ids.quantity', '>', 0)]) cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', - readonly=True) - chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill') - sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) + related='chuck_code_id.product_id.cutting_tool_model_id') + chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name') + chuck_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='夹头规格', + related='chuck_code_id.product_id.specification_id') + sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_code_id.product_id.brand_id') def on_barcode_scanned(self, barcode): """ @@ -291,58 +305,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel): else: raise ValidationError('扫描的刀具物料不存在,请重新扫描!') - @api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id') - def _compute_auto_fill(self): - for record in self: - if record.integral_code_id: - record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_model_id.id - record.integral_name = record.integral_code_id.product_id.name - record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id - else: - record.cutting_tool_integral_model_id = None - record.integral_name = None - record.sf_tool_brand_id_1 = None - if record.blade_code_id: - record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_model_id.id - record.blade_name = record.blade_code_id.product_id.name - record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id - else: - record.cutting_tool_blade_model_id = None - record.blade_name = None - record.sf_tool_brand_id_2 = None - if record.bar_code_id: - record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_model_id.id - record.bar_name = record.bar_code_id.product_id.name - record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterbar_model_id = None - record.bar_name = None - record.sf_tool_brand_id_3 = None - if record.pad_code_id: - record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_model_id.id - record.pad_name = record.pad_code_id.product_id.name - record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterpad_model_id = None - record.pad_name = None - record.sf_tool_brand_id_4 = None - if record.handle_code_id: - record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_model_id.id - record.handle_name = record.handle_code_id.product_id.name - record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterhandle_model_id = None - record.handle_name = None - record.sf_tool_brand_id_5 = None - if record.chuck_code_id: - record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_model_id.id - record.chuck_name = record.chuck_code_id.product_id.name - record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id - else: - record.cutting_tool_cutterhead_model_id = None - record.chuck_name = None - record.sf_tool_brand_id_6 = None - # 组装功能刀具参数信息 barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号') after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', required=True) @@ -430,7 +392,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 创建功能刀具批次/序列号记录 stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly) # 创建刀具组装入库单 - self.create_stocking_picking(stock_lot, functional_tool_assembly) + self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly) # 刀具物料出库 if self.integral_code_id: product_id.tool_material_stock_moves(self.integral_code_id) @@ -488,26 +450,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel): if not self.bar_code_id and not self.pad_code_id: raise ValidationError('【刀盘】和【刀杆】必须填写一个!') - def create_stocking_picking(self, stock_lot, functional_tool_assembly): - """ - 创建刀具组装入库单 - """ - # 获取名称为刀具组装入库的作业类型 - picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '刀具组装入库')]) - # 创建刀具组装入库单 - picking_id = self.env['stock.picking'].create({ - 'picking_type_id': picking_type_id.id - }) - # 创建作业详情对象记录,并绑定到刀具组装入库单 - self.env['stock.move.line'].create({ - 'picking_id': picking_id.id, - 'product_id': stock_lot.product_id.id, - 'lot_id': stock_lot.id, - 'functional_tool_name_id': functional_tool_assembly.id - }) - # 将刀具组装入库单的状态更改为就绪 - picking_id.action_confirm() - def get_desc_1(self, stock_lot): return { 'barcode_id': stock_lot.id, @@ -575,6 +517,50 @@ class FunctionalToolAssemblyOrder(models.TransientModel): } +class StockPicking(models.Model): + _inherit = 'stock.picking' + + def create_stocking_picking(self, stock_lot, functional_tool_assembly): + """ + 创建刀具组装入库单 + """ + # 获取名称为刀具组装入库的作业类型 + picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '刀具组装入库')]) + # 创建刀具组装入库单 + picking_id = self.env['stock.picking'].create({ + 'name': self._get_name_stock(picking_type_id), + 'picking_type_id': picking_type_id.id, + 'location_id': picking_type_id.default_location_src_id.id, + 'location_dest_id': picking_type_id.default_location_dest_id.id, + }) + # 创建作业详情对象记录,并绑定到刀具组装入库单 + self.env['stock.move.line'].create({ + 'picking_id': picking_id.id, + 'product_id': stock_lot.product_id.id, + 'lot_id': stock_lot.id, + 'qty_done': 1, + 'functional_tool_name_id': functional_tool_assembly.id + }) + # 将刀具组装入库单的状态更改为就绪 + picking_id.action_confirm() + picking_id.button_validate() + + def _get_name_stock(self, picking_type_id): + name = picking_type_id.sequence_id.prefix + str( + datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d")) + stock_id = self.env['stock.picking'].sudo().search( + [('name', 'like', name), ('picking_type_id', '=', picking_type_id.id)], + limit=1, + order="id desc" + ) + if not stock_id: + num = "%03d" % 1 + else: + m = int(stock_id.name[-3:]) + 1 + num = "%03d" % m + return name + str(num) + + class ProductProduct(models.Model): _inherit = 'product.product' @@ -605,7 +591,7 @@ class ProductProduct(models.Model): [('id', '=', tool_assembly_order_id)]) code = 'JKM-T-' + str(tool_assembly_order.after_assembly_functional_tool_type_id.code) + '-' + str( tool_assembly_order.after_assembly_functional_tool_diameter) + '-' - new_time = fields.Date.today() + new_time = datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d") code += str(new_time) + '-' stock_lot_id = self.env['stock.lot'].sudo().search( [('name', 'like', new_time), ('product_id.name', '=', '功能刀具')], diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index 453d6f60..7b3d2ab5 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -206,14 +206,13 @@ options="{'no_create': True, 'no_quick_create': True}"/> - + + - - @@ -228,14 +227,13 @@ options="{'no_create': True, 'no_quick_create': True}"/> - + + - - @@ -251,14 +249,13 @@ options="{'no_create': True, 'no_quick_create': True}"/> - + + - - @@ -274,14 +271,13 @@ options="{'no_create': True, 'no_quick_create': True}"/> - + + - - @@ -296,14 +292,13 @@ options="{'no_create': True, 'no_quick_create': True}"/> - + + - - @@ -318,14 +313,13 @@ options="{'no_create': True, 'no_quick_create': True}"/> - + + - -