[ADD] project_mrp: monitoring mrp in project

Show mrp information in project when both use the same analytic account.

Task-2469742
PR #68708
This commit is contained in:
yhu-odoo
2021-08-27 16:40:49 +00:00
parent 45912aaebd
commit f2422345fc
5 changed files with 72 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
+17
View File
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': "MRP Project",
'version': '1.0',
'summary': "Monitor MRP using project",
'description': "",
'category': 'Services/Project',
'depends': ['mrp_account', 'project'],
'data': [
'views/project_views.xml',
],
'application': False,
'auto_install': True,
'license': 'LGPL-3',
}
+3
View File
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import project
+24
View File
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class Project(models.Model):
_inherit = "project.project"
production_count = fields.Integer(related="analytic_account_id.production_count")
workorder_count = fields.Integer(related="analytic_account_id.workorder_count")
bom_count = fields.Integer(related="analytic_account_id.bom_count")
def action_view_mrp_production(self):
self.ensure_one()
return self.analytic_account_id.action_view_mrp_production()
def action_view_mrp_bom(self):
self.ensure_one()
return self.analytic_account_id.action_view_mrp_bom()
def action_view_workorder(self):
self.ensure_one()
return self.analytic_account_id.action_view_workorder()
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="project_project_form_view_inherited" model="ir.ui.view">
<field name="name">project.project.view.inherited</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project" />
<field eval="14" name="priority"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_view_analytic_account_entries']" position="after">
<button class="oe_stat_button" type="object" name="action_view_mrp_production"
icon="fa-wrench" attrs="{'invisible': [('production_count', '=', 0)]}">
<field string="Manufacturing Orders" name="production_count" widget="statinfo"/>
</button>
<button class="oe_stat_button" type="object" name="action_view_workorder"
icon="fa-cog" attrs="{'invisible': [('workorder_count', '=', 0)]}">
<field string="Work Orders" name="workorder_count" widget="statinfo"/>
</button>
<button class="oe_stat_button" type="object" name="action_view_mrp_bom"
icon="fa-flask" attrs="{'invisible': [('bom_count', '=', 0)]}">
<field string="Bills of Materials" name="bom_count" widget="statinfo"/>
</button>
</xpath>
</field>
</record>
</odoo>