物料需求计划管理
This commit is contained in:
@@ -50,19 +50,10 @@ class ReSaleOrder(models.Model):
|
|||||||
def action_view_demand_plan(self):
|
def action_view_demand_plan(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
demand_plan_ids = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.id)]).ids
|
demand_plan_ids = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.id)]).ids
|
||||||
action = {
|
return {
|
||||||
'res_model': 'sf.production.demand.plan',
|
'res_model': 'sf.production.demand.plan',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
|
'name': _("需求计划"),
|
||||||
|
'domain': [('id', 'in', demand_plan_ids)],
|
||||||
|
'view_mode': 'tree',
|
||||||
}
|
}
|
||||||
if len(demand_plan_ids) == 1:
|
|
||||||
action.update({
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_id': demand_plan_ids[0],
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
action.update({
|
|
||||||
'name': _("需求计划"),
|
|
||||||
'domain': [('id', 'in', demand_plan_ids)],
|
|
||||||
'view_mode': 'tree',
|
|
||||||
})
|
|
||||||
return action
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
('50', '待下达生产'),
|
('50', '待下达生产'),
|
||||||
('60', '已下达'),
|
('60', '已下达'),
|
||||||
('100', '取消'),
|
('100', '取消'),
|
||||||
], string='状态', default='30', compute='_compute_status', store=True)
|
], string='状态', default='30', readonly=True)
|
||||||
demand_plan_id = fields.Many2one(comodel_name="sf.demand.plan",
|
demand_plan_id = fields.Many2one(comodel_name="sf.demand.plan",
|
||||||
string="物料需求", readonly=True)
|
string="物料需求", readonly=True)
|
||||||
sale_order_id = fields.Many2one(comodel_name="sale.order",
|
sale_order_id = fields.Many2one(comodel_name="sale.order",
|
||||||
@@ -154,41 +154,41 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
[('demand_plan_selectable', '=', True), ('stock_route_group_ids', '=', group_id.id)])
|
[('demand_plan_selectable', '=', True), ('stock_route_group_ids', '=', group_id.id)])
|
||||||
if route_ids:
|
if route_ids:
|
||||||
pdp.route_ids = route_ids.ids
|
pdp.route_ids = route_ids.ids
|
||||||
break
|
continue
|
||||||
pdp.route_ids = None
|
pdp.route_ids = None
|
||||||
|
|
||||||
@api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line',
|
# @api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line',
|
||||||
'sale_order_id.mrp_production_ids.state')
|
# 'sale_order_id.mrp_production_ids.state')
|
||||||
def _compute_status(self):
|
# def _compute_status(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if record.sale_order_id:
|
# if record.sale_order_id:
|
||||||
sale_order_state = record.sale_order_id.state
|
# sale_order_state = record.sale_order_id.state
|
||||||
if sale_order_state in ('draft', 'sent', 'supply method'):
|
# if sale_order_state in ('draft', 'sent', 'supply method'):
|
||||||
record.status = '20' # 待确认
|
# record.status = '20' # 待确认
|
||||||
if record.supply_method in ('purchase', 'outsourcing') and sale_order_state in (
|
# if record.supply_method in ('purchase', 'outsourcing') and sale_order_state in (
|
||||||
'sale', 'processing', 'physical_distribution', 'delivered',
|
# 'sale', 'processing', 'physical_distribution', 'delivered',
|
||||||
'done') and sale_order_state != 'cancel':
|
# 'done') and sale_order_state != 'cancel':
|
||||||
record.status = '60' # 已下达
|
# record.status = '60' # 已下达
|
||||||
if record.supply_method in ('automation', 'manual'):
|
# if record.supply_method in ('automation', 'manual'):
|
||||||
if sale_order_state in (
|
# if sale_order_state in (
|
||||||
'sale', 'processing', 'physical_distribution', 'delivered',
|
# 'sale', 'processing', 'physical_distribution', 'delivered',
|
||||||
'done') and sale_order_state != 'cancel':
|
# 'done') and sale_order_state != 'cancel':
|
||||||
record.status = '30' # 需求确认
|
# record.status = '30' # 需求确认
|
||||||
# 检查所有制造订单的排程单状态,有一个为待排程状态,就为待下达生产
|
# # 检查所有制造订单的排程单状态,有一个为待排程状态,就为待下达生产
|
||||||
pending_productions = record.sale_order_id.mrp_production_ids.filtered(
|
# pending_productions = record.sale_order_id.mrp_production_ids.filtered(
|
||||||
lambda p: p.state == 'confirmed' and p.product_id.id == record.product_id.id
|
# lambda p: p.state == 'confirmed' and p.product_id.id == record.product_id.id
|
||||||
)
|
# )
|
||||||
if pending_productions:
|
# if pending_productions:
|
||||||
record.status = '50' # 待下达生产
|
# record.status = '50' # 待下达生产
|
||||||
# 检查所有制造订单的排程单状态
|
# # 检查所有制造订单的排程单状态
|
||||||
if record.sale_order_id.mrp_production_ids:
|
# if record.sale_order_id.mrp_production_ids:
|
||||||
product_productions = record.sale_order_id.mrp_production_ids.filtered(
|
# product_productions = record.sale_order_id.mrp_production_ids.filtered(
|
||||||
lambda p: p.product_id.id == record.product_id.id
|
# lambda p: p.product_id.id == record.product_id.id
|
||||||
)
|
# )
|
||||||
if product_productions and all(order.schedule_state != '未排' for order in product_productions):
|
# if product_productions and all(order.schedule_state != '未排' for order in product_productions):
|
||||||
record.status = '60' # 已下达
|
# record.status = '60' # 已下达
|
||||||
if sale_order_state == 'cancel' or not record.sale_order_line_id:
|
# if sale_order_state == 'cancel' or not record.sale_order_line_id:
|
||||||
record.status = '100' # 取消
|
# record.status = '100' # 取消
|
||||||
|
|
||||||
@api.depends('sale_order_line_id.product_id.name')
|
@api.depends('sale_order_line_id.product_id.name')
|
||||||
def _compute_sale_order_line_number(self):
|
def _compute_sale_order_line_number(self):
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class SfStockRoute(models.Model):
|
|||||||
[('supply_method', 'in', stock_route_group)])
|
[('supply_method', 'in', stock_route_group)])
|
||||||
if demand_plan_ids:
|
if demand_plan_ids:
|
||||||
sr.demand_plan_ids = demand_plan_ids.ids
|
sr.demand_plan_ids = demand_plan_ids.ids
|
||||||
break
|
continue
|
||||||
sr.demand_plan_ids = None
|
sr.demand_plan_ids = None
|
||||||
|
|
||||||
# def name_get(self):
|
# def name_get(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user