diff --git a/HISTORY.rst b/HISTORY.rst
index 11eed81c58c..1b6574569cd 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -22,6 +22,8 @@ Latest (unreleased)
**Features and Improvements**
+* SO change validation button visibility/process given product_category
+
**Bugfixes**
**Build**
diff --git a/odoo/local-src/specific_sale/models/product.py b/odoo/local-src/specific_sale/models/product.py
index c9727bcd6c4..67ff6d2c249 100644
--- a/odoo/local-src/specific_sale/models/product.py
+++ b/odoo/local-src/specific_sale/models/product.py
@@ -12,3 +12,17 @@ class ProductTemplate(models.Model):
is_ghost = fields.Boolean(
string='Ghost Product',
)
+
+
+class ProductCategory(models.Model):
+ _inherit = 'product.category'
+
+ engineering_validation_required = fields.Boolean(
+ string='Engineering Validation Required',
+ )
+ system_validation_required = fields.Boolean(
+ string='System Validation Required',
+ )
+ process_validation_required = fields.Boolean(
+ string='Process Validation Required',
+ )
diff --git a/odoo/local-src/specific_sale/models/sale_order.py b/odoo/local-src/specific_sale/models/sale_order.py
index 01d25d2fbad..c1e70ebc4d6 100644
--- a/odoo/local-src/specific_sale/models/sale_order.py
+++ b/odoo/local-src/specific_sale/models/sale_order.py
@@ -54,6 +54,21 @@ class SaleOrder(models.Model):
'cancel': [('required', False)]}
)
sales_condition_filename = fields.Char()
+ engineering_validation_required = fields.Boolean(
+ string='Engineering Validation Required',
+ compute="_compute_validation_required",
+ readonly=True,
+ )
+ system_validation_required = fields.Boolean(
+ string='System Validation Required',
+ compute='_compute_validation_required',
+ readonly=True,
+ )
+ process_validation_required = fields.Boolean(
+ string='Process Validation Required',
+ compute='_compute_validation_required',
+ readonly=True,
+ )
@api.model
def _setup_fields(self, partial):
@@ -104,6 +119,27 @@ def _create_analytic_account(self, prefix=None):
'project_market_id': order.project_market_id.id}
)
+ @api.multi
+ @api.depends(
+ 'order_line.product_id.categ_id', 'engineering_validation_id',
+ 'system_validation_id', 'process_validation_id')
+ def _compute_validation_required(self):
+ for so in self:
+ for line in so.order_line:
+ cat = line.product_id.categ_id
+ # compute engineering_validation
+ if (cat.engineering_validation_required and
+ not so.engineering_validation_id):
+ so.engineering_validation_required = True
+ # compute system_validation_required
+ if (cat.system_validation_required and
+ not so.system_validation_id):
+ so.system_validation_required = True
+ # compute process_validation_required
+ if (cat.process_validation_required and
+ not so.process_validation_id):
+ so.process_validation_required = True
+
@api.onchange('opportunity_id')
def onchange_opportunity_id(self):
if self.opportunity_id:
@@ -174,9 +210,9 @@ def _check_sales_condition(self):
@api.multi
def _check_validators(self):
for so in self:
- if not (so.engineering_validation_id and
- so.system_validation_id and
- so.process_validation_id):
+ if (so.engineering_validation_required and
+ so.system_validation_required and
+ so.process_validation_required):
raise UserError(_('The Sale Order needs to be reviewed.'))
@api.multi
diff --git a/odoo/local-src/specific_sale/views/product_views.xml b/odoo/local-src/specific_sale/views/product_views.xml
index 8b878ccebd7..786ec813fe3 100644
--- a/odoo/local-src/specific_sale/views/product_views.xml
+++ b/odoo/local-src/specific_sale/views/product_views.xml
@@ -15,4 +15,19 @@
+
+ product.category.form.validation
+ product.category
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/odoo/local-src/specific_sale/views/sale_order_crm.xml b/odoo/local-src/specific_sale/views/sale_order_crm.xml
index 557ab14e337..2d1ed88c35a 100644
--- a/odoo/local-src/specific_sale/views/sale_order_crm.xml
+++ b/odoo/local-src/specific_sale/views/sale_order_crm.xml
@@ -15,21 +15,21 @@
class="btn-primary"
groups="specific_sale.rtl_eng_validation"
type="object"
- attrs="{'invisible': [('engineering_validation_id', '!=', False)]}"/>
+ attrs="{'invisible': [('engineering_validation_required', '=', False)]}"/>
+ attrs="{'invisible': [('system_validation_required', '=', False)]}"/>
+ attrs="{'invisible': [('process_validation_required', '=', False)]}"/>
@@ -80,6 +80,9 @@
+
+
+
diff --git a/odoo/migration.yml b/odoo/migration.yml
index b3bd1b2f117..de9bb1fffe5 100644
--- a/odoo/migration.yml
+++ b/odoo/migration.yml
@@ -178,3 +178,7 @@ migration:
operations:
post:
- anthem songs.upgrade.10_0_14.intercompany::main
+ - version: 10.0.15
+ addons:
+ upgrade:
+ - specific_sale