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 9, 2020
1 parent df4f120 commit 8d38b04
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 33 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.

22 changes: 22 additions & 0 deletions fieldservice_account_analytic/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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)
1 change: 0 additions & 1 deletion fieldservice_account_analytic/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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 8d38b04

Please sign in to comment.