未齐套提示

This commit is contained in:
guanhuan
2025-06-04 13:38:40 +08:00
parent de951b1b45
commit b0f2fe6a8e
3 changed files with 30 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.tools import float_compare
from datetime import datetime, timedelta
from odoo.exceptions import UserError
class sf_production_plan(models.Model):
@@ -101,7 +102,7 @@ class sf_production_plan(models.Model):
hide_action_open_mrp_production = fields.Boolean(
string='显示待工艺确认按钮',
compute='_compute_hide_action_open_mrp_production',
compute='_compute_hid_button',
default=False
)
@@ -117,6 +118,12 @@ class sf_production_plan(models.Model):
default=False
)
hide_action_view_programming = fields.Boolean(
string='显示编程单按钮',
compute='_compute_hid_button',
default=False
)
@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')
def _compute_status(self):
@@ -339,14 +346,18 @@ class sf_production_plan(models.Model):
'target': 'new',
}
@api.depends('sale_order_id.mrp_production_ids.state')
def _compute_hide_action_open_mrp_production(self):
@api.depends('sale_order_id.mrp_production_ids.state', 'sale_order_id.mrp_production_ids.programming_state')
def _compute_hid_button(self):
for record in self:
mrp_production_ids = record.sale_order_id.mrp_production_ids.filtered(
lambda p: p.state == 'technology_to_confirmed' and p.product_id.id == record.product_id.id
)
record.hide_action_open_mrp_production = bool(mrp_production_ids) and record.supply_method in (
'automation', 'manual')
programming_mrp_production_ids = record.sale_order_id.mrp_production_ids.filtered(
lambda p: p.programming_state == '编程中' and p.product_id.id == record.product_id.id
)
record.hide_action_view_programming = bool(programming_mrp_production_ids)
def _compute_hide_action_purchase_orders(self):
for record in self:
@@ -442,3 +453,14 @@ class sf_production_plan(models.Model):
if 'views' in action:
action['views'] += [(state, view) for state, view in action['views'] if view != 'form']
return action
def action_view_programming(self):
self.ensure_one()
programming_mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered(
lambda p: p.programming_state == '编程中' and p.product_id.id == self.product_id.id
).mapped('programming_no')
if programming_mrp_production_ids:
programming_no = list(set(programming_mrp_production_ids))
numbers_str = "".join(programming_no)
raise ValidationError(f"编程单号:{numbers_str},请去云平台处理")