更改库存模块库区相关字段

This commit is contained in:
mgw
2023-07-14 14:43:06 +08:00
parent 3de5a95a98
commit 5b6a563a87
2 changed files with 26 additions and 26 deletions

View File

@@ -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):

View File

@@ -35,7 +35,7 @@
</group>
<group>
<field name="storage_type" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
<!-- <field name="storage_type" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/> -->
<field name="product_type" widget="many2many_tags" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
<field name="shelf_height" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="shelf_layer" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>