Skip to content

Commit

Permalink
[IMP] Improved code.
Browse files Browse the repository at this point in the history
  • Loading branch information
murtuzasaleh committed Oct 12, 2020
1 parent df4f120 commit c10b7fe
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 40 deletions.
1 change: 0 additions & 1 deletion fieldservice_account_analytic/data/ir_rule.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="analytic_account_fsm_manager" model="ir.rule">
<field name="name">account.analytic.line.fsm.manager</field>
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion fieldservice_account_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import (
account_invoice_line,
account_move,
analytic_account,
fsm_location,
fsm_order,
Expand Down
21 changes: 0 additions & 21 deletions fieldservice_account_analytic/models/account_invoice_line.py

This file was deleted.

24 changes: 24 additions & 0 deletions fieldservice_account_analytic/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, models
from odoo.exceptions import ValidationError


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
order = self.env["fsm.order"].browse(vals.get("fsm_order_id"))
if order:
if order.location_id.analytic_account_id:
vals[
"analytic_account_id"
] = order.location_id.analytic_account_id.id
else:
raise ValidationError(
_("No analytic account " "set on the order's Location.")
)
return super(AccountMoveLine, self).create(vals_list)
2 changes: 1 addition & 1 deletion fieldservice_account_analytic/models/fsm_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_default_customer(self):
required=True,
ondelete="restrict",
auto_join=True,
track_visibility="onchange",
tracking=True,
default=get_default_customer,
)

Expand Down
8 changes: 1 addition & 7 deletions fieldservice_account_analytic/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ class FSMOrder(models.Model):
default="location",
)
customer_id = fields.Many2one(
"res.partner",
string="Contact",
domain=[("customer", "=", True)],
change_default=True,
index=True,
track_visibility="always",
"res.partner", string="Contact", change_default=True, index=True, tracking=True,
)

def _compute_total_cost(self):
Expand Down Expand Up @@ -56,7 +51,6 @@ def _onchange_customer_id_location(self):
if self.customer_id:
self.location_id = self.customer_id.service_location_id

@api.multi
def write(self, vals):
res = super(FSMOrder, self).write(vals)
for order in self:
Expand Down

0 comments on commit c10b7fe

Please sign in to comment.