diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py
index 37701de2..ea5b36fb 100644
--- a/sf_demand_plan/models/sf_production_demand_plan.py
+++ b/sf_demand_plan/models/sf_production_demand_plan.py
@@ -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},请去云平台处理")
+
diff --git a/sf_demand_plan/static/src/scss/style.css b/sf_demand_plan/static/src/scss/style.css
index 6c8e57fd..0e4e6ff0 100644
--- a/sf_demand_plan/static/src/scss/style.css
+++ b/sf_demand_plan/static/src/scss/style.css
@@ -1,7 +1,7 @@
-.demand_plan_tree th:not(.o_list_record_selector,.row_no,[data-name=sequence]) {
+.demand_plan_tree .o_list_table_ungrouped th:not(.o_list_record_selector,.row_no,[data-name=sequence]) {
min-width: 98px !important;
}
.demand_plan_tree .o_list_table_grouped th:not(.o_list_record_selector,.row_no,[data-name=sequence]) {
- min-width: 98px !important;
+ width: 98px !important;
}
\ No newline at end of file
diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml
index 11736148..64845fd8 100644
--- a/sf_demand_plan/views/demand_plan.xml
+++ b/sf_demand_plan/views/demand_plan.xml
@@ -43,6 +43,7 @@
+
+