From 6a7cff656b4beb92a279f95ef593d4e514022ee8 Mon Sep 17 00:00:00 2001 From: "qihao.gong@jikimo.com" Date: Fri, 23 Feb 2024 16:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=93=E4=BD=8D=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_warehouse/models/model.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 58b3a078..74e1ad4e 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -72,8 +72,8 @@ class SfLocation(models.Model): ('禁用', '禁用') ], string='货位状态', default='空闲') # product_id = fields.Many2one('product.template', string='产品') - # product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', readonly=True) - product_id = fields.Many2one('product.product', string='产品', readonly=True) + product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', readonly=True) + # product_id = fields.Many2one('product.product', string='产品', readonly=True) product_sn_id = fields.Many2one('stock.lot', string='产品序列号') # time_test = fields.Char(string='time') # 添加SQL约束 @@ -375,22 +375,22 @@ class ShelfLocation(models.Model): def action_location_status_enable(self): self.location_status = '空闲' - # @api.depends('product_sn_id') - # def _compute_product_id(self): - # """ - # 根据产品序列号,获取产品 - # """ - # for record in self: - # if record.product_sn_id: - # record.sudo().product_id = record.product_sn_id.product_id - # record.sudo().location_status = '占用' - # - # else: - # if record.production_id: - # record.location_status = '占用' - # else: - # record.product_id = False - # record.location_status = '空闲' + @api.depends('product_sn_id') + def _compute_product_id(self): + """ + 根据产品序列号,获取产品 + """ + for record in self: + if record.product_sn_id: + record.sudo().product_id = record.product_sn_id.product_id + record.sudo().location_status = '占用' + + else: + if record.production_id: + record.location_status = '占用' + else: + record.product_id = False + # record.location_status = '空闲' # 调取获取货位信息接口 def get_sf_shelf_location_info(self):