diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 8954a84e..bb0323e6 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -15,7 +15,7 @@ class SfLocation(models.Model): ('库区', '库区'), ('货架', '货架'), ('货位', '货位') - ], string='仓库类别') + ], string='存储类型') # 库区类型(selection:拣货区、存货区、收货区、退货区、次品区) area_type = fields.Selection([ ('拣货区', '拣货区'), @@ -25,10 +25,10 @@ class SfLocation(models.Model): ('次品区', '次品区') ], string='库区类型') # 存储类型(selection:库区、货架) - storage_type = fields.Selection([ - ('库区', '库区'), - ('货架', '货架') - ], string='存储类型') + # storage_type = fields.Selection([ + # ('库区', '库区'), + # ('货架', '货架') + # ], string='存储类型') # 产品类别 (关联:product.category) product_type = fields.Many2many('product.category', string='产品类别') # 货架独有字段:通道、方向、货架高度(m)、货架层数、层数容量 @@ -61,26 +61,26 @@ class SfLocation(models.Model): hide_shelf = fields.Boolean(compute='_compute_hide_what', string='隐藏货架') hide_location = fields.Boolean(compute='_compute_hide_what', string='隐藏货位') - @api.model - def create(self, vals): - """ - 重写create方法,添加自定义的约束 - """ - print('create', vals) - if vals.get('location_id'): - location = self.env['stock.location'].browse(vals.get('location_id')) - if location.storage_type == '库区': - raise UserError('库区不能作为父级仓库') - return super().create(vals) - - @api.onchange('location_id') - def _onchange_location_id(self): - """ - 重写onchange方法,添加自定义的约束 - """ - if self.location_id: - if self.location_id.storage_type == '库区': - raise UserError('库区不能作为父级仓库') + # @api.model + # def create(self, vals): + # """ + # 重写create方法,添加自定义的约束 + # """ + # print('create', vals) + # if vals.get('location_id'): + # location = self.env['stock.location'].browse(vals.get('location_id')) + # if location.storage_type == '库区': + # raise UserError('库区不能作为父级仓库') + # return super().create(vals) + # + # @api.onchange('location_id') + # def _onchange_location_id(self): + # """ + # 重写onchange方法,添加自定义的约束 + # """ + # if self.location_id: + # if self.location_id.storage_type == '库区': + # raise UserError('库区不能作为父级仓库') # @api.constrains('shelf_height') # def _check_shelf_height(self): diff --git a/sf_warehouse/views/view.xml b/sf_warehouse/views/view.xml index ad353f0e..bcb782f5 100644 --- a/sf_warehouse/views/view.xml +++ b/sf_warehouse/views/view.xml @@ -35,7 +35,7 @@ - +