Skip to content

Commit

Permalink
merge update of the validation rules for sale orders
Browse files Browse the repository at this point in the history
change during merge: improve the product.category view

BSRTL-204
  • Loading branch information
gurneyalex committed May 17, 2017
2 parents 11cb6b1 + 98d42a1 commit 6bc2b6d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 6 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Latest (unreleased)

**Features and Improvements**

* SO change validation button visibility/process given product_category

**Bugfixes**

**Build**
Expand Down
14 changes: 14 additions & 0 deletions odoo/local-src/specific_sale/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
42 changes: 39 additions & 3 deletions odoo/local-src/specific_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions odoo/local-src/specific_sale/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,19 @@
</field>
</record>

<record id="product_category_validation_form_view" model="ir.ui.view">
<field name="name">product.category.form.validation</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<xpath expr='//group[@name="first"]' position="after">
<group name="validation" col='4' string='Validation'>
<field name='engineering_validation_required'/>
<field name='system_validation_required'/>
<field name='process_validation_required'/>
</group>
</xpath>
</field>
</record>

</odoo>
9 changes: 6 additions & 3 deletions odoo/local-src/specific_sale/views/sale_order_crm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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)]}"/>

<button name="action_validate_sys"
string="System Validation"
class="btn-primary"
groups="specific_sale.rtl_sys_manager"
type="object"
attrs="{'invisible': [('system_validation_id', '!=', False)]}"/>
attrs="{'invisible': [('system_validation_required', '=', False)]}"/>

<button name="action_validate_pro"
string="Process Validation"
class="btn-primary"
groups="specific_sale.rtl_pro_manager"
type="object"
attrs="{'invisible': [('process_validation_id', '!=', False)]}"/>
attrs="{'invisible': [('process_validation_required', '=', False)]}"/>
</header>

<field name="validity_date" position="after">
Expand Down Expand Up @@ -80,6 +80,9 @@
<page string="Internal Validation" name="roctool">
<group>
<group name="validation" string="Validation">
<field name='engineering_validation_required' invisible="True"/>
<field name='system_validation_required' invisible="True"/>
<field name='process_validation_required' invisible="True"/>
<field name='engineering_validation_id'/>
<field name='system_validation_id'/>
<field name='process_validation_id'/>
Expand Down
4 changes: 4 additions & 0 deletions odoo/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,7 @@ migration:
operations:
post:
- anthem songs.upgrade.10_0_14.intercompany::main
- version: 10.0.15
addons:
upgrade:
- specific_sale

0 comments on commit 6bc2b6d

Please sign in to comment.