From bf7ef78b20937a013be7471d8d242ce223691cce Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Thu, 24 Aug 2023 11:24:27 +0800 Subject: [PATCH 01/36] =?UTF-8?q?=E6=90=AD=E5=BB=BA=E6=8E=92=E7=A8=8B?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E6=9E=B6=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 43 +++++++++++++++ .../views/mrp_production_addional_change.xml | 53 +++++++++++++++++++ sf_plan/__manifest__.py | 2 +- sf_plan/models/custom_plan.py | 3 +- sf_plan/views/view.xml | 17 ++++-- 5 files changed, 111 insertions(+), 7 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 67c1f14c..bddf7558 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -14,6 +14,49 @@ class MrpProduction(models.Model): model_file = fields.Binary('模型文件', related='product_id.model_file') schedule_state = fields.Selection([('未排', '未排'), ('已排', '已排')], string='排程状态', default='未排') + # state = fields.Selection(selection_add=[('未排程', '未排程'), ('已排程', '已排程')]) + # 生产线 + production_line_id = fields.Many2one('sf.production.line', string='生产线') + state = fields.Selection([ + ('draft', 'Draft'), + ('confirmed', 'Confirmed'), + ('未排程', '未排程'), ('已排程', '已排程'), + ('progress', 'In Progress'), + ('to_close', 'To Close'), + ('done', 'Done'), + ('cancel', 'Cancelled')], string='State', + compute='_compute_state', copy=False, index=True, readonly=True, + store=True, tracking=True, + help=" * Draft: The MO is not confirmed yet.\n" + " * Confirmed: The MO is confirmed, the stock rules and the reordering of the components are trigerred.\n" + " * In Progress: The production has started (on the MO or on the WO).\n" + " * To Close: The production is done, the MO has to be closed.\n" + " * Done: The MO is closed, the stock moves are posted. \n" + " * Cancelled: The MO has been cancelled, can't be confirmed anymore.") + + # 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了 + def action_view_production_schedule(self): + self.ensure_one() + self.state = '已排程' + # if self.plan_start_time and self.plan_end_time: + # return None + # elif self.plan_start_time and not self.plan_end_time: + # # 如果没有给出计划结束时间,则计划结束时间为计划开始时间+采购周期+缓冲期 + # # 采购周期 + # purchase_cycle = 3 + # # 缓冲期 + # buffer_period = 1 + # # 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期 + # self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period) + # return self.plan_end_time + # else: + # return None + + def cancel_plan(self): + self.ensure_one() + self.state = 'confirmed' + # self.plan_start_time = None + # self.plan_end_time = None @api.depends('request_ids') def _compute_maintenance_count(self): diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 716cdb76..1eced0cf 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -40,7 +40,60 @@ decoration-warning="reservation_state != 'assigned' and components_availability_state in ('expected', 'available')" decoration-danger="reservation_state != 'assigned' and components_availability_state == 'late'"/> + +