7231_lxb_commit

This commit is contained in:
lixiaobin@jikimo.com
2025-07-10 14:29:06 +08:00
parent 3be1c4c529
commit 559c6bfb1d
3 changed files with 20 additions and 3 deletions

View File

@@ -72,6 +72,8 @@ class SfDemandPlan(models.Model):
('4', ''),
], string='优先级', default='3')
overdelivery_allowed = fields.Boolean('可超量发货', default=False)
hide_button_release_plan = fields.Boolean(
string='显示下达计划按钮',
compute='_compute_hide_button_release_plan',
@@ -194,7 +196,9 @@ class SfDemandPlan(models.Model):
def button_production_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:
if sum_product_uom_qty > self.product_uom_qty and not self.overdelivery_allowed and line_ids.filtered(lambda p: p.location_id.name == '客户'):
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
elif sum_product_uom_qty > self.product_uom_qty:
return {
'name': _('需求计划'),
'type': 'ir.actions.act_window',