Accept Merge Request #245: (feature/解决工作日历无法创建的bug -> develop)

Merge Request: 解决冲突与优化结构

Created By: @马广威
Accepted By: @马广威
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/245?initial=true
This commit is contained in:
马广威
2023-07-14 14:45:03 +08:00
3 changed files with 27 additions and 27 deletions

View File

@@ -179,7 +179,7 @@ class WorkLogSetting(models.Model):
is_workday = single_date.strftime("%A")
if is_workday in rest_days:
print('is_workday in rest_days', is_workday)
self.env['sf.work.schedule.calendar'].create({
self.env['sf.work.schedule.calendar'].sudo().create({
'name': '休息日',
'name_id': self.id,
'calendar_code': self.code,

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)]}"/>