diff --git a/fieldservice_account/__manifest__.py b/fieldservice_account/__manifest__.py index ed63db6cd9..bcfcd984d1 100644 --- a/fieldservice_account/__manifest__.py +++ b/fieldservice_account/__manifest__.py @@ -4,14 +4,14 @@ { "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", "depends": ["fieldservice", "account"], "data": [ "security/ir.model.access.csv", - "views/account_invoice.xml", + "views/account_move.xml", "views/fsm_order.xml", ], "license": "AGPL-3", diff --git a/fieldservice_account/migrations/12.0.3.0.0/post-migration.py b/fieldservice_account/migrations/12.0.3.0.0/post-migration.py deleted file mode 100644 index 8d5d09ad82..0000000000 --- a/fieldservice_account/migrations/12.0.3.0.0/post-migration.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2019 Open Source Integrators -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - - -def migrate(env, version): - if not version: - return - - env.execute( - """INSERT INTO - fsm_order_account_invoice_rel(fsm_order_id, invoice_id) - SELECT DISTINCT l.fsm_order_id, l.invoice_id - FROM account_invoice_line AS l - WHERE l.fsm_order_id IS NOT NULL AND l.invoice_id IS NOT NULL; - """ - ) diff --git a/fieldservice_account/migrations/13.0.1.0.0/pre-migration.py b/fieldservice_account/migrations/13.0.1.0.0/pre-migration.py new file mode 100644 index 0000000000..57e48a5e8e --- /dev/null +++ b/fieldservice_account/migrations/13.0.1.0.0/pre-migration.py @@ -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(env.cr, _model_renames) + openupgrade.rename_tables(env.cr, _table_renames) diff --git a/fieldservice_account/models/__init__.py b/fieldservice_account/models/__init__.py index 2c8c276534..816289ec31 100644 --- a/fieldservice_account/models/__init__.py +++ b/fieldservice_account/models/__init__.py @@ -1,7 +1,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import ( - account_invoice, - account_invoice_line, + account_move, + account_move_line, fsm_order, ) diff --git a/fieldservice_account/models/account_invoice.py b/fieldservice_account/models/account_move.py similarity index 85% rename from fieldservice_account/models/account_invoice.py rename to fieldservice_account/models/account_move.py index 6ef1e1900d..7143846871 100644 --- a/fieldservice_account/models/account_invoice.py +++ b/fieldservice_account/models/account_move.py @@ -1,16 +1,16 @@ -# Copyright (C) 2018 - TODAY, Open Source Integrators +# Copyright (C) 2018, Open Source Integrators # Copyright 2019 Akretion # 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", @@ -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: diff --git a/fieldservice_account/models/account_invoice_line.py b/fieldservice_account/models/account_move_line.py similarity index 74% rename from fieldservice_account/models/account_invoice_line.py rename to fieldservice_account/models/account_move_line.py index 216d104ecc..574852ef01 100644 --- a/fieldservice_account/models/account_invoice_line.py +++ b/fieldservice_account/models/account_move_line.py @@ -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") diff --git a/fieldservice_account/models/fsm_order.py b/fieldservice_account/models/fsm_order.py index b3b931285e..3cd58c84b0 100644 --- a/fieldservice_account/models/fsm_order.py +++ b/fieldservice_account/models/fsm_order.py @@ -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", @@ -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 diff --git a/fieldservice_account/security/ir.model.access.csv b/fieldservice_account/security/ir.model.access.csv index f6792aef64..e8e0566f22 100644 --- a/fieldservice_account/security/ir.model.access.csv +++ b/fieldservice_account/security/ir.model.access.csv @@ -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 diff --git a/fieldservice_account/tests/test_fsm_account.py b/fieldservice_account/tests/test_fsm_account.py index dd703ed846..7c34315ddd 100644 --- a/fieldservice_account/tests/test_fsm_account.py +++ b/fieldservice_account/tests/test_fsm_account.py @@ -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"} @@ -30,6 +30,5 @@ def setUp(self): "email": "tp@email.com", "partner_id": self.test_loc_partner.id, "owner_id": self.test_loc_partner.id, - "customer_id": self.test_loc_partner.id, } ) diff --git a/fieldservice_account/views/account_invoice.xml b/fieldservice_account/views/account_move.xml similarity index 78% rename from fieldservice_account/views/account_invoice.xml rename to fieldservice_account/views/account_move.xml index a3853ed00d..66f015779a 100644 --- a/fieldservice_account/views/account_invoice.xml +++ b/fieldservice_account/views/account_move.xml @@ -1,8 +1,8 @@ FSM order.invoice.form - account.invoice - + account.move +