Skip to content

Commit

Permalink
[MIG] fieldservice_account: Migration to 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brian10048 committed Oct 22, 2020
1 parent e7bf4d5 commit 84047aa
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion fieldservice_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Field Service - Accounting",
"summary": "Track invoices linked to Field Service orders",
"version": "12.0.3.1.1",
"version": "13.0.1.0.0",
"category": "Field Service",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/field-service",
Expand Down
16 changes: 0 additions & 16 deletions fieldservice_account/migrations/12.0.3.0.0/post-migration.py

This file was deleted.

21 changes: 21 additions & 0 deletions fieldservice_account/migrations/13.0.1.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2020 Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

_model_renames = [
("account.invoice", "account.move"),
("account.invoice.line", "account.move.line"),
]

_table_renames = [
("account.invoice", "account.move"),
("account.invoice.line", "account.move.line"),
("fsm_order_account_invoice_rel", "fsm_order_account_move_rel")
]


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_models(cr, _model_renames)
openupgrade.rename_tables(cr, _table_renames)
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# Copyright (C) 2018, Open Source Integrators
# Copyright 2019 Akretion <raphael.reverdy@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountInvoice(models.Model):
_inherit = "account.invoice"
class AccountMove(models.Model):
_inherit = "account.move"

fsm_order_ids = fields.Many2many(
"fsm.order",
"fsm_order_account_invoice_rel",
"fsm_order_account_move_rel",
"invoice_id",
"fsm_order_id",
string="FSM Orders",
Expand All @@ -24,7 +24,6 @@ def _compute_fsm_order_count(self):
for invoice in self:
invoice.fsm_order_count = len(invoice.fsm_order_ids)

@api.multi
def action_view_fsm_orders(self):
action = self.env.ref("fieldservice.action_fsm_dash_order").read()[0]
if self.fsm_order_count > 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from odoo import fields, models


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

fsm_order_id = fields.Many2one("fsm.order", string="FSM Order")
7 changes: 3 additions & 4 deletions fieldservice_account/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FSMOrder(models.Model):
_inherit = "fsm.order"

invoice_ids = fields.Many2many(
"account.invoice",
"account.move",
"fsm_order_account_invoice_rel",
"fsm_order_id",
"invoice_id",
Expand All @@ -22,12 +22,11 @@ def _compute_account_invoice_count(self):
for order in self:
order.invoice_count = len(order.invoice_ids)

@api.multi
def action_view_invoices(self):
action = self.env.ref("account.action_invoice_tree").read()[0]
action = self.env.ref("account.action_move_out_invoice_type").read()[0]
if self.invoice_count > 1:
action["domain"] = [("id", "in", self.invoice_ids.ids)]
elif self.invoice_ids:
action["views"] = [(self.env.ref("account.invoice_form").id, "form")]
action["views"] = [(self.env.ref("account.view_move_form").id, "form")]
action["res_id"] = self.invoice_ids[0].id
return action
2 changes: 1 addition & 1 deletion fieldservice_account/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_invoice_line_fsm_user,account.invoice.line.fsm.user,model_account_invoice_line,fieldservice.group_fsm_user,1,1,1,1
access_account_move_line_fsm_user,account.move.line.fsm.user,model_account_move_line,fieldservice.group_fsm_user,1,1,1,1
4 changes: 2 additions & 2 deletions fieldservice_account/tests/test_fsm_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def setUp(self):
super(FSMAccountCase, self).setUp()
self.Wizard = self.env["fsm.wizard"]
self.WorkOrder = self.env["fsm.order"]
self.AccountInvoice = self.env["account.invoice"]
self.AccountInvoiceLine = self.env["account.invoice.line"]
self.AccountInvoice = self.env["account.move"]
self.AccountInvoiceLine = self.env["account.move.line"]
# create a Res Partner
self.test_partner = self.env["res.partner"].create(
{"name": "Test Partner", "phone": "123", "email": "tp@email.com"}
Expand Down
18 changes: 9 additions & 9 deletions fieldservice_account/views/account_invoice.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<odoo>
<record id="account_invoice_form" model="ir.ui.view">
<field name="name">FSM order.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button
Expand All @@ -25,10 +25,10 @@
<!-- Vendor Bill List View -->
<record id="vendor_bill_tree_view_fso" model="ir.ui.view">
<field name="name">vendor.bill.tree.view.fso</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_tree" />
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_invoice_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='origin']" position="after">
<xpath expr="//field[@name='invoice_origin']" position="after">
<field
name="fsm_order_ids"
widget="many2many_tags"
Expand All @@ -40,8 +40,8 @@
<!-- Vendor Bill Form View -->
<record id="vendor_bill_form_view_fso" model="ir.ui.view">
<field name="name">vendor.bill.form.view.fso</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form" />
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='other_info']" position="inside">
<group string="Field Service Orders">
Expand All @@ -53,8 +53,8 @@
<!-- Invoice Search View -->
<record id="invoice_search_view_fso" model="ir.ui.view">
<field name="name">invoice.search.view.fso</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.view_account_invoice_filter" />
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_account_move_filter" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="fsm_order_ids" string="FSM Orders" />
Expand Down

0 comments on commit 84047aa

Please sign in to comment.