需求计划下达计划

This commit is contained in:
guanhuan
2025-07-03 17:32:11 +08:00
parent 3822d78f35
commit 6e877d0449
6 changed files with 48 additions and 23 deletions

View File

@@ -161,7 +161,7 @@ class SfDemandPlan(models.Model):
def _compute_hide_button_release_plan(self):
for line in self:
line.hide_button_release_plan = bool(line.line_ids.filtered(
lambda p: p.status != '60'))
lambda p: p.status == '30'))
def button_release_plan(self):
pass
@@ -187,15 +187,28 @@ class SfDemandPlan(models.Model):
lambda p: p.status in ('50', '60') and p.new_supply_method == 'custom_made')
line.readonly_custom_made_type = bool(production_demand_plan)
def write(self, vals):
res = super(SfDemandPlan, self).write(vals)
line_ids = self.line_ids.filtered(lambda p: p.plan_uom_qty == 0 or p.plan_uom_qty < 0)
if line_ids:
raise ValidationError(f"计划量不能小于等于0")
return res
def name_get(self):
result = []
for plan in self:
result.append((plan.id, plan.sale_order_id.name))
return result
def button_batch_release_plan(self):
line_ids = self.line_ids.filtered(lambda p: p.status == '30')
sum_product_uom_qty = sum(line_ids.mapped('plan_uom_qty'))
if sum_product_uom_qty > self.product_uom_qty:
return {
'name': _('需求计划'),
'type': 'ir.actions.act_window',
'views': [(self.env.ref(
'sf_demand_plan.sf_release_plan_wizard_form').id,
'form')],
'res_model': 'sf.release.plan.wizard',
'target': 'new',
'context': {
'default_demand_plan_line_id': line_ids.ids,
'default_release_message': f"您正在下达计划量 {sum_product_uom_qty},需求数量为 {self.product_uom_qty},已超过需求数量,是否继续?",
}}
else:
for demand_plan_line_id in line_ids:
demand_plan_line_id.action_confirm()