Can you customize which smart buttons appear at the top of a company or contact record? I would like to have projects visible and linked, not just tasks from projects.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Buchhaltung
- Lager
- PoS
- Project
- MRP
Diese Frage wurde gekennzeichnet
1
Antworten
304
Ansichten
Hi,
Please refer to the following links:
1. https://www.cybrosys.com/blog/how-to-add-smart-buttons-in-odoo-18
2. https://www.cybrosys.com/blog/how-to-add-smart-buttons-in-odoo-17
Please refer to the code below:
Python
from odoo import models, fields
class ResPartner(models.Model):
_inherit = 'res.partner'
project_count = fields.Integer(
compute="_compute_project_count", string="Projects")
def _compute_project_count(self):
for rec in self:
rec.project_count = self.env['project.project'].search_count([
('partner_id', '=', rec.id)
])
def action_view_projects(self):
projects = self.env['project.project'].sudo().search([
('partner_id', '=', self.id)
])
return {
"type": "ir.actions.act_window",
"res_model": "project.project",
"name": _("Projects"),
"domain": [('id', 'in', projects.ids)],
"view_mode": "list,form",
}
XML
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.view.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button class="oe_stat_button" type="object"
icon="fa-folder" name="action_view_projects">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="project_count"/>
</span>
<span class="o_stat_text">Projects</span>
</div>
</button>
</xpath>
</field>
</record>
Hope it helps.
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
Registrieren