需求计划开发
This commit is contained in:
@@ -173,6 +173,7 @@ class SfDemandPlan(models.Model):
|
||||
status_line = line.line_ids.filtered(lambda p: p.status == '60')
|
||||
if line.sale_order_id.state == 'cancel':
|
||||
line.state = '50'
|
||||
line.line_ids.status = '100'
|
||||
elif len(line.line_ids) == len(status_line):
|
||||
line.state = '40'
|
||||
elif bool(status_line):
|
||||
|
||||
@@ -257,8 +257,11 @@ class SfProductionDemandPlan(models.Model):
|
||||
@api.depends('status')
|
||||
def _compute_mrp_production_ids(self):
|
||||
for record in self:
|
||||
if record.status in ('50', '60'):
|
||||
record.mrp_production_ids = self.env['mrp.production'].sudo().search(
|
||||
[('demand_plan_line_id', '=', record.id)]).ids
|
||||
else:
|
||||
record.mrp_production_ids = None
|
||||
|
||||
@api.depends('mrp_production_ids.state')
|
||||
def _compute_hide_release_production_order(self):
|
||||
@@ -274,10 +277,11 @@ class SfProductionDemandPlan(models.Model):
|
||||
if record.planned_start_date and record.planned_start_date < fields.Date.today():
|
||||
raise ValidationError("计划开工日期必须大于或等于今天。")
|
||||
|
||||
def release_production_order(self):
|
||||
def button_release_production(self):
|
||||
self.ensure_one()
|
||||
if not self.planned_start_date:
|
||||
raise ValidationError("请先填写计划开工日期")
|
||||
pro_plan_list = self.env['sf.production.plan'].search(
|
||||
pro_plan_list = self.env['sf.production.plan'].sudo().search(
|
||||
[('production_id', 'in', self.mrp_production_ids.ids), ('state', '=', 'draft')])
|
||||
sf_production_line = self.env['sf.production.line'].sudo().search(
|
||||
[('name', '=', '1#CNC自动生产线')], limit=1)
|
||||
@@ -290,11 +294,19 @@ class SfProductionDemandPlan(models.Model):
|
||||
pro_plan_list.date_planned_start = date_planned_start
|
||||
self._do_production_schedule(pro_plan_list)
|
||||
self.status = '60'
|
||||
self.update_sale_order_state()
|
||||
|
||||
def _do_production_schedule(self, pro_plan_list):
|
||||
for pro_plan in pro_plan_list:
|
||||
pro_plan.do_production_schedule()
|
||||
|
||||
def update_sale_order_state(self):
|
||||
demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)])
|
||||
demand_plan_state = demand_plan.filtered(lambda line: line.state != '40')
|
||||
if not demand_plan_state:
|
||||
# 修改销售订单为加工中
|
||||
self.sale_order_id.state = 'processing'
|
||||
|
||||
def edit_button(self):
|
||||
self.ensure_one()
|
||||
action = {
|
||||
@@ -563,6 +575,7 @@ class SfProductionDemandPlan(models.Model):
|
||||
self.write({'status': '50'})
|
||||
else:
|
||||
self.write({'status': '60'})
|
||||
self.update_sale_order_state()
|
||||
|
||||
def mrp_bom_create(self):
|
||||
if self.supply_method in ('automation', 'manual'):
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class SfProductionPlan(models.Model):
|
||||
_inherit = 'sf.production.plan'
|
||||
|
||||
demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan",
|
||||
string="需求计划明细", readonly=True)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super(SfProductionPlan, self).create(vals)
|
||||
res.demand_plan_line_id = res.production_id.demand_plan_line_id.id
|
||||
return res
|
||||
@@ -43,7 +43,7 @@
|
||||
<field name="contract_date"/>
|
||||
<field name="date_order"/>
|
||||
<field name="contract_code"/>
|
||||
<field name="plan_remark"/>
|
||||
<field name="plan_remark" attrs="{'readonly': [('status', 'in', ('60','100'))]}"/>
|
||||
<field name="processing_time"/>
|
||||
<field name="material_check" optional="hide"/>
|
||||
<!-- <field name="hide_action_open_mrp_production" invisible="1"/>-->
|
||||
@@ -60,7 +60,7 @@
|
||||
<!-- attrs="{'invisible': [('hide_action_stock_picking', '=', False)]}"/>-->
|
||||
<!-- <button name="action_view_programming" type="object" string="编程单" class="btn-secondary"-->
|
||||
<!-- attrs="{'invisible': [('hide_action_view_programming', '=', False)]}"/>-->
|
||||
<field name="planned_start_date"/>
|
||||
<field name="planned_start_date" attrs="{'readonly': [('status', 'in', ('60','100'))]}"/>
|
||||
<field name="actual_start_date"/>
|
||||
<field name="actual_end_date"/>
|
||||
<field name="create_date" optional="hide" string="创建时间"/>
|
||||
@@ -69,7 +69,7 @@
|
||||
<field name="write_uid" optional="hide" string="更新人"/>
|
||||
<field name="print_count"/>
|
||||
<field name="hide_release_production_order" invisible="1"/>
|
||||
<button name="release_production_order" type="object" string="下发生产" class="btn-primary"
|
||||
<button name="button_release_production" type="object" string="下发生产" class="btn-primary"
|
||||
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
||||
/>
|
||||
<button name="edit_button" type="object" string="拆分" class="btn-primary"/>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<form>
|
||||
<header>
|
||||
<field name="hide_button_release_plan" invisible="1"/>
|
||||
<button string="下达计划" name="button_release_plan" type="object"
|
||||
class="btn-primary" attrs="{'invisible': [('hide_button_release_plan', '=', False)]}"/>
|
||||
<!-- <button string="下达计划" name="button_release_plan" type="object"-->
|
||||
<!-- class="btn-primary" attrs="{'invisible': [('hide_button_release_plan', '=', False)]}"/>-->
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet>
|
||||
@@ -33,12 +33,12 @@
|
||||
<field name="model_process_parameters_ids" widget="many2many_tags"/>
|
||||
<field name="model_machining_precision"/>
|
||||
<field name="inventory_quantity_auto_apply"/>
|
||||
<field name="priority" attrs="{'readonly': [('state', '=', '40')]}"/>
|
||||
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="计划">
|
||||
<field name="line_ids" attrs="{'readonly': [('state', '=', '40')]}">
|
||||
<field name="line_ids" attrs="{'readonly': [('state', 'in', ('40','50'))]}">
|
||||
<tree editable="bottom" delete="false">
|
||||
<field name="status"/>
|
||||
<field name="supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||
@@ -59,7 +59,7 @@
|
||||
class="btn-primary"
|
||||
attrs="{'invisible': [('status', 'in', ('50','60','100'))]}"
|
||||
/>
|
||||
<button name="release_production_order" type="object" string="下发生产"
|
||||
<button name="button_release_production" type="object" string="下发生产"
|
||||
class="btn-primary"
|
||||
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user