From 67c4f64d084256d2482687aaebce29e405b7cdf5 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 3 Jun 2024 17:34:47 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E5=8D=95=E3=80=81=E5=88=80=E5=85=B7=E7=BB=84?= =?UTF-8?q?=E8=A3=85=E5=8D=95=E5=BC=B9=E7=AA=97=E3=80=81=E5=88=80=E5=85=B7?= =?UTF-8?q?=E6=8B=86=E8=A7=A3=E5=8D=95=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=99=A4?= =?UTF-8?q?=E5=88=80=E6=9F=84=E5=A4=96=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99?= =?UTF-8?q?=E6=8C=89=E6=89=B9=E6=AC=A1=E5=8F=B7=E8=BF=9B=E8=A1=8C=E7=AE=A1?= =?UTF-8?q?=E7=90=86=EF=BC=9B=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2=E5=B8=83?= =?UTF-8?q?=E5=B1=80=EF=BC=8C=E4=BC=98=E5=8C=96=E7=BB=84=E8=A3=85=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 96 ++++---- .../views/functional_tool_views.xml | 6 +- sf_tool_management/views/tool_base_views.xml | 53 +++-- sf_tool_management/wizard/wizard.py | 213 +++++++----------- sf_tool_management/wizard/wizard_view.xml | 33 ++- sf_warehouse/models/model.py | 1 + 6 files changed, 201 insertions(+), 201 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 4a440df6..f763ed4b 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -401,8 +401,9 @@ class FunctionalToolAssembly(models.Model): return categories.browse(functional_tool_type_ids) # 刀具物料信息 - # ==============整体式刀具型号============ - integral_freight_barcode = fields.Char('整体式刀具货位') + # ==============整体式刀具型号============= + integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位') + integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次') integral_product_id = fields.Many2one('product.product', string='整体式刀具名称', compute='_compute_integral_product_id', store=True) cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', @@ -412,19 +413,15 @@ class FunctionalToolAssembly(models.Model): sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', related='integral_product_id.brand_id') - @api.depends('integral_freight_barcode') + @api.depends('integral_freight_barcode_id') def _compute_integral_product_id(self): for item in self: - if item.integral_freight_barcode: - location = self.env['sf.shelf.location'].sudo().search( - [('barcode', '=', item.integral_freight_barcode)]) - if location: - item.integral_product_id = location.product_id.id - else: - item.integral_product_id = False + if item.integral_freight_barcode_id: + item.integral_product_id = item.integral_freight_barcode_id.product_id.id # =================刀片型号============= - blade_freight_barcode = fields.Char('刀片货位') + blade_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位') + blade_lot_id = fields.Many2one('stock.lot', string='刀片批次') blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id', store=True) cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', @@ -433,18 +430,15 @@ class FunctionalToolAssembly(models.Model): related='blade_product_id.specification_id') sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id') - @api.depends('blade_freight_barcode') + @api.depends('blade_freight_barcode_id') def _compute_blade_product_id(self): for item in self: - if item.blade_freight_barcode: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)]) - if location: - item.blade_product_id = location.product_id.id - else: - item.blade_product_id = False + if item.blade_freight_barcode_id: + item.blade_product_id = item.blade_freight_barcode_id.product_id.id # ==============刀杆型号================ - bar_freight_barcode = fields.Char('刀杆货位') + bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位') + bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次') bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id', store=True) cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', @@ -453,18 +447,15 @@ class FunctionalToolAssembly(models.Model): related='bar_product_id.specification_id') sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id') - @api.depends('bar_freight_barcode') + @api.depends('bar_freight_barcode_id') def _compute_bar_product_id(self): for item in self: - if item.bar_freight_barcode: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)]) - if location: - item.bar_product_id = location.product_id.id - else: - item.bar_product_id = False + if item.bar_freight_barcode_id: + item.bar_product_id = item.bar_freight_barcode_id.product_id.id # =============刀盘型号================ - pad_freight_barcode = fields.Char('刀盘货位') + pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位') + pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次') pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id', store=True) cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', @@ -473,15 +464,11 @@ class FunctionalToolAssembly(models.Model): related='pad_product_id.specification_id') sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id') - @api.depends('pad_freight_barcode') + @api.depends('pad_freight_barcode_id') def _compute_pad_product_id(self): for item in self: - if item.pad_freight_barcode: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)]) - if location: - item.pad_product_id = location.product_id.id - else: - item.pad_product_id = False + if item.pad_freight_barcode_id: + item.pad_product_id = item.pad_freight_barcode_id.product_id.id # ==============刀柄型号============== handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_handle_product_id', store=True) @@ -505,7 +492,8 @@ class FunctionalToolAssembly(models.Model): item.handle_freight_rfid = False # ==============夹头型号============== - chuck_freight_barcode = fields.Char('夹头货位') + chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位') + chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次') chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id', store=True) cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', @@ -514,17 +502,18 @@ class FunctionalToolAssembly(models.Model): related='chuck_product_id.specification_id') sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id') - @api.depends('chuck_freight_barcode') + @api.depends('chuck_freight_barcode_id') def _compute_chuck_product_id(self): for item in self: - if item.chuck_freight_barcode: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)]) - if location: - item.chuck_product_id = location.product_id.id - else: - item.chuck_product_id = False + if item.chuck_freight_barcode_id: + item.chuck_product_id = item.chuck_freight_barcode_id.product_id.id # ==================待删除字段================== + integral_freight_barcode = fields.Char('整体式刀具货位') + blade_freight_barcode = fields.Char('刀片货位') + bar_freight_barcode = fields.Char('刀杆货位') + pad_freight_barcode = fields.Char('刀盘货位') + chuck_freight_barcode = fields.Char('夹头货位') blade_name = fields.Char('') integral_name = fields.Char('') blade_code_id = fields.Many2one('stock.lot', '刀片序列号') @@ -721,6 +710,8 @@ class FunctionalToolDismantle(models.Model): related='handle_product_id.cutting_tool_model_id') handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id') handle_rfid = fields.Char(string='刀柄Rfid', compute='_compute_functional_tool_num', store=True) + handle_lot_id = fields.Many2one('stock.lot', string='刀柄序列号', compute='_compute_functional_tool_num', + store=True) scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False) # 整体式 @@ -730,6 +721,8 @@ class FunctionalToolDismantle(models.Model): related='integral_product_id.cutting_tool_model_id') integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', related='integral_product_id.brand_id') + integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次', compute='_compute_functional_tool_num', + store=True) integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位', domain="[('product_id', 'in', (integral_product_id, False))]") @@ -739,6 +732,7 @@ class FunctionalToolDismantle(models.Model): blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', related='blade_product_id.cutting_tool_model_id') blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id') + blade_lot_id = fields.Many2one('stock.lot', string='刀片批次', compute='_compute_functional_tool_num', store=True) blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位', domain="[('product_id', 'in', (blade_product_id, False))]") @@ -748,6 +742,7 @@ class FunctionalToolDismantle(models.Model): bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', related='bar_product_id.cutting_tool_model_id') bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id') + bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次', compute='_compute_functional_tool_num', store=True) bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位', domain="[('product_id', 'in', (bar_product_id, False))]") @@ -757,6 +752,7 @@ class FunctionalToolDismantle(models.Model): pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', related='pad_product_id.cutting_tool_model_id') pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id') + pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次', compute='_compute_functional_tool_num', store=True) pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位', domain="[('product_id', 'in', (pad_product_id, False))]") @@ -766,6 +762,7 @@ class FunctionalToolDismantle(models.Model): chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', related='chuck_product_id.cutting_tool_model_id') chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id') + chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次', compute='_compute_functional_tool_num', store=True) chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位', domain="[('product_id', 'in', (chuck_product_id, False))]") @@ -789,12 +786,20 @@ class FunctionalToolDismantle(models.Model): item.rfid = item.functional_tool_id.rfid item.handle_rfid = item.functional_tool_id.rfid + # 产品 item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id item.blade_product_id = item.functional_tool_id.functional_tool_name_id.blade_product_id.id item.bar_product_id = item.functional_tool_id.functional_tool_name_id.bar_product_id.id item.pad_product_id = item.functional_tool_id.functional_tool_name_id.pad_product_id.id item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id + # 批次/序列号 + item.handle_lot_id = item.functional_tool_id.functional_tool_name_id.handle_code_id.id + item.integral_lot_id = item.functional_tool_id.functional_tool_name_id.integral_lot_id.id + item.blade_lot_id = item.functional_tool_id.functional_tool_name_id.blade_lot_id.id + item.bar_lot_id = item.functional_tool_id.functional_tool_name_id.bar_lot_id.id + item.pad_lot_id = item.functional_tool_id.functional_tool_name_id.pad_lot_id.id + item.chuck_lot_id = item.functional_tool_id.functional_tool_name_id.chuck_lot_id.id else: item.tool_groups_id = False item.tool_type_id = False @@ -810,6 +815,13 @@ class FunctionalToolDismantle(models.Model): item.pad_product_id = False item.chuck_product_id = False + item.handle_lot_id = False + item.integral_lot_id = False + item.blade_lot_id = False + item.bar_lot_id = False + item.pad_lot_id = False + item.chuck_lot_id = False + def confirmation_disassembly(self): logging.info('%s刀具确认开始拆解' % self.dismantle_cause) if self.functional_tool_id.functional_tool_status == '已拆除': diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml index ac98a703..5c3d64aa 100644 --- a/sf_tool_management/views/functional_tool_views.xml +++ b/sf_tool_management/views/functional_tool_views.xml @@ -46,8 +46,8 @@
-
- + + + + diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 91bd5bf9..53d785d1 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -539,6 +539,7 @@ class SfShelfLocationLot(models.Model): _name = 'sf.shelf.location.lot' _description = '批次数量' + name = fields.Char('名称', related='lot_id.name') shelf_location_id = fields.Many2one('sf.shelf.location', string="货位") lot_id = fields.Many2one('stock.lot', string='批次号') qty = fields.Integer('数量')