Skip to content

Commit

Permalink
BSRTL-169: link project task and BOM
Browse files Browse the repository at this point in the history
  • Loading branch information
gurneyalex committed Mar 29, 2017
2 parents b4278e0 + fd22a2a commit abd930f
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 2 deletions.
14 changes: 14 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ Release History
latest (unreleased)
+++++++++++++++++++

**Features and Improvements**
- Add link inbetween 'BOM' and 'project.task / project.project'
- Add fields in views for 'BOM' and 'project.task'
- Add smartbutton on 'task' view

**Bugfixes**

**Build**

**Documentation**

10.0.9 (2017-03-23)
+++++++++++++++++++

**Features and Improvements**

**Bugfixes**
Expand Down
2 changes: 1 addition & 1 deletion odoo/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.0.8
10.0.9
10 changes: 9 additions & 1 deletion odoo/local-src/specific_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@
{
"name": "RocTool specific sale module",
"version": "10.0.1.0.0",
"depends": ['specific_crm', 'sale', 'sale_crm', 'website_sale_options'],
"depends": [
'specific_crm',
'sale',
'sale_crm',
'website_sale_options',
'mrp',
],
"author": "Camptocamp,Odoo Community Association (OCA)",
"website": "http://www.camptocamp.com",
"license": "GPL-3 or any later version",
"category": "Sale",
"data": [
'views/product_views.xml',
'views/sale_order_crm.xml',
'views/project_task.xml',
'views/mrp_bom.xml',
'data/res_groups_data.xml',
],
'installable': True,
Expand Down
2 changes: 2 additions & 0 deletions odoo/local-src/specific_sale/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
from . import product
from . import sale_order
from . import mail_compose_message
from . import mrp_bom
from . import project_task
21 changes: 21 additions & 0 deletions odoo/local-src/specific_sale/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Author: Denis Leemann
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields


class MrpBom(models.Model):
_inherit = 'mrp.bom'

project_task_id = fields.Many2one(
'project.task',
string='Project Task',
)
project_id = fields.Many2one(
'project.project',
string='Project',
related='project_task_id.project_id',
readonly=True,
)
32 changes: 32 additions & 0 deletions odoo/local-src/specific_sale/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Author: Denis Leemann
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields


class ProjectTask(models.Model):
_inherit = 'project.task'

mrp_bom_ids = fields.One2many(
'mrp.bom',
'project_task_id',
string='BOM',
)
bom_count = fields.Integer(
compute='_compute_linked_bom',
string='Count BOM',
)

def action_view_bom(self):
action = self.env.ref('mrp.mrp_bom_form_action')
result = action.read()[0]
result['context'] = {'default_project_task_id': self.id}
return result

def _compute_linked_bom(self):
BOM = self.env['mrp.bom']
for task in self:
task.bom_count = BOM.search_count([
('project_task_id', '=', task.id)])
16 changes: 16 additions & 0 deletions odoo/local-src/specific_sale/views/mrp_bom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="mrp_bom_form_project" model="ir.ui.view">
<field name="name">mrp.bom.form.project</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='company_id']" position="after">
<field name="project_task_id"/>
<field name="project_id"/>
</xpath>
</field>
</record>

</odoo>
25 changes: 25 additions & 0 deletions odoo/local-src/specific_sale/views/project_task.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_task_form2_bom" model="ir.ui.view">
<field name="name">project.task.form bom</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field eval="2" name="priority"/>
<field name='groups_id' eval="[(4,ref('mrp.group_mrp_user')),
(4,ref('stock.group_stock_user'))]"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Bill Of Materials" name="bom_page">
<field name="mrp_bom_ids" readonly="True" />
</page>
</xpath>
<xpath expr="//div[@class='oe_button_box']" position="inside">
<button class="oe_stat_button" type="object" name="action_view_bom" icon="fa-cog" >
<field name="bom_count" string="Bill Of Materials" widget="statinfo" />
</button>
</xpath>
</field>
</record>

</odoo>
4 changes: 4 additions & 0 deletions odoo/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ migration:
upgrade:
- specific_hr
- specific_sale
- version: 10.0.10
addons:
upgrade:
- specific_sale

0 comments on commit abd930f

Please sign in to comment.