物料需求计划

This commit is contained in:
guanhuan
2025-06-24 11:17:41 +08:00
parent 2f26aee90a
commit 02b4f76326
8 changed files with 75 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from . import sf_demand_plan
from . import sf_production_demand_plan
from . import sale_order
from . import sf_demand_plan

View File

@@ -16,7 +16,10 @@ class ReSaleOrder(models.Model):
'sale_order_id': ret.order_id.id,
'sale_order_line_id': ret.id,
}
demand_plan_info = self.env['sf.demand.plan'].sudo().create(vals)
vals.update({'demand_plan_id': demand_plan_info.id})
demand_plan = self.env['sf.production.demand.plan'].sudo().create(vals)
demand_plan_info.write({'line_ids': demand_plan.id})
if demand_plan.product_id.machining_drawings_name:
filename_url = demand_plan.product_id.machining_drawings_name.rsplit('.', 1)[0]
wizard_vals = {

View File

@@ -12,7 +12,15 @@ class SfDemandPlan(models.Model):
list = [(m.sync_id, m.name) for m in machinings]
return list
line_ids = fields.One2many('sf.production.demand.plan', 'demand_plan_id', string="需求计划", copy=True)
state = fields.Selection([
('10', '草稿'),
('20', '待工艺设计'),
('30', '部分下达'),
('40', '已下达'),
], string='状态')
line_ids = fields.One2many(comodel_name='sf.production.demand.plan',
inverse_name='demand_plan_id', string="需求计划", copy=True)
sale_order_id = fields.Many2one(comodel_name="sale.order",
string="销售订单", readonly=True)
@@ -35,6 +43,9 @@ class SfDemandPlan(models.Model):
# product_uom_qty = fields.Float(
# string="待计划",
# related='sale_order_line_id.product_uom_qty', store=True)
# product_uom_qty = fields.Float(
# string="已计划",
# related='sale_order_line_id.product_uom_qty', store=True)
model_id = fields.Char('模型ID', related='product_id.model_id')
customer_name = fields.Char('客户', related='sale_order_id.customer_name')
product_uom_qty = fields.Float(
@@ -65,6 +76,8 @@ class SfDemandPlan(models.Model):
('4', ''),
], string='优先级', default='3')
remark = fields.Char('备注')
@api.depends('product_id.part_number', 'product_id.model_name')
def _compute_part_number(self):
for line in self:

View File

@@ -270,6 +270,16 @@ class SfProductionDemandPlan(models.Model):
pro_plan_list.date_planned_start = date_planned_start
self._do_production_schedule(pro_plan_list)
def edit_button(self):
return {
'res_model': 'sf.demand.plan',
'type': 'ir.actions.act_window',
'name': _("需求计划"),
'domain': [('line_ids', 'in', self.demand_plan_id.ids)],
'views': [[self.env.ref('sf_demand_plan.view_sf_demand_plan_list').id, 'list']],
'target': 'new',
}
def _do_production_schedule(self, pro_plan_list):
for pro_plan in pro_plan_list:
pro_plan.do_production_schedule()