Skip to content

Commit

Permalink
[ADD] fieldservice_account_anlytic: Smart buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRetes committed Nov 29, 2024
1 parent 32878ce commit 52ad51f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
17 changes: 16 additions & 1 deletion fieldservice_account_analytic/models/fsm_order.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo import _, api, fields, models


class FSMOrder(models.Model):
Expand Down Expand Up @@ -56,3 +56,18 @@ def create(self, vals_list):
)
record.analytic_account_id = analytic_account
return record

def action_view_analytic_account(self):
self.ensure_one()
analytic_account = self.env["account.analytic.account"].search(

Check warning on line 62 in fieldservice_account_analytic/models/fsm_order.py

View check run for this annotation

Codecov / codecov/patch

fieldservice_account_analytic/models/fsm_order.py#L61-L62

Added lines #L61 - L62 were not covered by tests
[("trip_id", "=", self.id)], limit=1
)

if analytic_account:
return {

Check warning on line 67 in fieldservice_account_analytic/models/fsm_order.py

View check run for this annotation

Codecov / codecov/patch

fieldservice_account_analytic/models/fsm_order.py#L67

Added line #L67 was not covered by tests
"type": "ir.actions.act_window",
"res_model": "account.analytic.account",
"view_mode": "form",
"res_id": analytic_account.id,
"name": _("Analytic Account for Order %s") % self.name,
}
15 changes: 15 additions & 0 deletions fieldservice_account_analytic/views/fsm_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
<field name="model">fsm.order</field>
<field name="inherit_id" ref="fieldservice.fsm_order_form" />
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button
name="action_view_analytic_account"
type="object"
class="oe_stat_button"
icon="fa-bar-chart"
invisible="not analytic_account_id"
>
<field
name="analytic_account_id"
widget="statinfo"
string="Analytic Account"
/>
</button>
</xpath>
<notebook position="inside">
<page name="accounting" string="Accounting">
<group name="bill_to">
Expand Down

0 comments on commit 52ad51f

Please sign in to comment.