更改库存模块库区相关字段
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)]}"/>
|
||||
|
||||
Reference in New Issue
Block a user