解决冲突
This commit is contained in:
@@ -35,23 +35,18 @@ class MrpProduction(models.Model):
|
||||
tool_state_remark2 = fields.Text(string='功能刀具状态备注(无效刀)', readonly=True)
|
||||
|
||||
def _compute_default_delivery_status(self):
|
||||
need_list = [
|
||||
'pending_cam',
|
||||
'progress',
|
||||
'rework',
|
||||
'scrap',
|
||||
'to_close',
|
||||
]
|
||||
try:
|
||||
if self.state not in need_list:
|
||||
if self.state == 'cancel':
|
||||
return False
|
||||
if not self.deadline_of_delivery:
|
||||
return '已逾期'
|
||||
return False
|
||||
hours = self.get_hours_diff()
|
||||
if hours >= 48:
|
||||
return '正常'
|
||||
elif hours > 0 and hours < 48:
|
||||
elif hours > 0 and hours < 48 and self.state != 'done':
|
||||
return '预警'
|
||||
elif hours > 0 and hours < 48 and self.state == 'done':
|
||||
return '正常'
|
||||
else:
|
||||
return '已逾期'
|
||||
except Exception as e:
|
||||
@@ -60,20 +55,55 @@ class MrpProduction(models.Model):
|
||||
|
||||
@api.depends('state', 'deadline_of_delivery')
|
||||
def _compute_delivery_status(self):
|
||||
for production in self:
|
||||
delivery_status = production._compute_default_delivery_status()
|
||||
if delivery_status and production.delivery_status != delivery_status:
|
||||
production.delivery_status = delivery_status
|
||||
|
||||
delivery_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')], string='交期状态',
|
||||
store=True,
|
||||
compute='_compute_delivery_status',
|
||||
default=lambda self: self._compute_default_delivery_status())
|
||||
|
||||
def get_page_all_records(self, model_name, func, domain, page_size=100):
|
||||
# 获取模型对象
|
||||
model = self.env[model_name].sudo()
|
||||
|
||||
# 初始化分页参数
|
||||
page_number = 1
|
||||
while True:
|
||||
# 计算偏移量
|
||||
offset = (page_number - 1) * page_size
|
||||
|
||||
# 获取当前页的数据
|
||||
records = model.search(domain, limit=page_size, offset=offset)
|
||||
|
||||
# 如果没有更多记录,退出循环
|
||||
if not records:
|
||||
break
|
||||
|
||||
# 将当前页的数据添加到结果列表
|
||||
func(records)
|
||||
# 增加页码
|
||||
page_number += 1
|
||||
|
||||
def run_compute_delivery_status(self, records):
|
||||
records._compute_delivery_status()
|
||||
|
||||
def _corn_update_delivery_status(self):
|
||||
need_list = [
|
||||
'draft',
|
||||
'technology_to_confirmed',
|
||||
'confirmed',
|
||||
'pending_cam',
|
||||
'progress',
|
||||
'rework',
|
||||
'scrap',
|
||||
'to_close',
|
||||
]
|
||||
for production in self:
|
||||
production.delivery_status = production._compute_default_delivery_status()
|
||||
|
||||
delivery_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')], string='交期状态',
|
||||
store=True,
|
||||
compute='_compute_delivery_status',
|
||||
default=lambda self: self._compute_default_delivery_status())
|
||||
# previous_workorder = self.env['mrp.production'].search([('state', 'in', need_list)])
|
||||
self.get_page_all_records('mrp.production', self.run_compute_delivery_status,
|
||||
[('state', 'in', need_list)], 100)
|
||||
|
||||
def get_hours_diff(self):
|
||||
# 获取当前日期和时间
|
||||
@@ -779,6 +809,7 @@ class MrpProduction(models.Model):
|
||||
if td_ids:
|
||||
work.sequence = td_ids[0].sequence
|
||||
|
||||
|
||||
def _reset_work_order_sequence_1(self):
|
||||
"""
|
||||
工单工序排序方法(旧)
|
||||
|
||||
Reference in New Issue
Block a user