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