制造订单页面新增生产线和计划开始加工时间字段

This commit is contained in:
jinling.yang
2024-01-24 14:24:27 +08:00
parent 8f379a2635
commit 82f54b5d83
7 changed files with 359 additions and 370 deletions

View File

@@ -324,32 +324,22 @@ class sf_production_plan(models.Model):
raise UserError(e)
# # sf生产排程
# class sf_produce_plan(models.Model):
# _name = 'sf.produce.plan'
# _description = 'sf生产排程'
class ReMrpProduction(models.Model):
_inherit = 'mrp.production'
# # 重写create方法使得创建坯料预制排程时如果给出了计划结束时间则计划开始时间为计划结束时间减去坯料预制时间
# @api.model
# def create(self, vals):
# # 评估结束时间
# vals['plan_end_time'] = self._get_plan_end_time(vals['plan_start_time'], vals['quantity'])
# return super(sf_pl_plan, self).create(vals)
production_line_id = fields.Many2one('sf.production.line', string='生产线', compute='_compute_production_line_id',
store=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间')
@api.depends('name')
def _compute_production_line_id(self):
for production in self:
if production.name:
plan_production = self.env['sf.production.plan'].search([('production_id', '=', production.id)])
if plan_production:
production.production_line_id = plan_production.production_line_id
production.plan_start_processing_time = plan_production.date_planned_start
# # 当不设置计划结束时间时,增加计算计划结束时间的方法
# @api.onchange('plan_start_time', 'quantity')
# def _onchange_plan_start_time(self):
# if self.plan_start_time and self.quantity:
# self.plan_end_time = self._get_plan_end_time(self.plan_start_time, self.quantity)
#
# # 计算计划结束时间
# def _get_plan_end_time(self, plan_start_time, quantity):
# # 坯料预制时间
# pl_time = 0.5
# # 计划结束时间 = 计划开始时间 + 坯料预制时间
# plan_end_time = plan_start_time + pl_time
# return plan_end_time
#
# 机台作业计划
class machine_work_schedule(models.Model):