forked from OCA/hr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BSRTL-169: link project task and BOM
- Loading branch information
Showing
9 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
10.0.8 | ||
10.0.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,3 +132,7 @@ migration: | |
upgrade: | ||
- specific_hr | ||
- specific_sale | ||
- version: 10.0.10 | ||
addons: | ||
upgrade: | ||
- specific_sale |