Skip to content

Commit

Permalink
[ADD] fieldservice_account_analytic: Analytic Plans
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRetes committed Nov 27, 2024
1 parent 097a3bc commit 062bb59
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions fieldservice_account_analytic/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"data": [
"data/ir_rule.xml",
"data/analytic_plan.xml",
"security/ir.model.access.csv",
"report/fsm_order_report_template.xml",
"views/fsm_location.xml",
Expand Down
11 changes: 11 additions & 0 deletions fieldservice_account_analytic/data/analytic_plan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo noupdate="1">
<record id="fsm_order_analytic_plan" model="account.analytic.plan">
<field name="name">FSM Orders</field>
</record>
<record id="fsm_location_analytic_plan" model="account.analytic.plan">
<field name="name">FSM Orders</field>
</record>
<record id="fsm_route_analytic_plan" model="account.analytic.plan">
<field name="name">FSM Orders</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions fieldservice_account_analytic/models/analytic_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ def create(self, vals_list):
@api.onchange("product_id")
def onchange_product_id(self):
self.name = self.product_id.name if self.product_id else False

class AnalyticAccount(models.Model):
_inherit = "account.analytic.account"

fsm_order_id = fields.One2many("tms.order", "analytic_account_id", copy=False)
route_id = fields.One2many("tms.route", "analytic_account_id", copy=False)
14 changes: 14 additions & 0 deletions fieldservice_account_analytic/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,17 @@ def write(self, vals):
if "customer_id" not in vals and not order.customer_id:
order.customer_id = order.location_id.customer_id.id
return res

@api.model
def create(self, vals):
record = super().create(vals)
self.env["account.analytic.account"].create(
{
"name": vals.get("name"),
"plan_id": self.env.ref(
"fieldservice_account_analytic.fsm_order_analytic_plan"
),
"fsm_order_id": record,
}
)
return record

0 comments on commit 062bb59

Please sign in to comment.