From 0232cd50415fad39a407016073550e2f61b90a2a Mon Sep 17 00:00:00 2001
From: Juliana <juliana@le-filament.com>
Date: Thu, 12 Aug 2021 12:20:30 +0200
Subject: [PATCH] [MIG] Migration -> 13.0

---
 __manifest__.py                                           | 4 ++--
 models/__init__.py                                        | 2 +-
 models/{account_invoice.py => account_move.py}            | 2 +-
 models/training_training.py                               | 7 +------
 views/{account_invoice_view.xml => account_move_view.xml} | 4 ++--
 views/assets.xml                                          | 2 +-
 views/sale_order_view.xml                                 | 4 ++--
 7 files changed, 10 insertions(+), 15 deletions(-)
 rename models/{account_invoice.py => account_move.py} (90%)
 rename views/{account_invoice_view.xml => account_move_view.xml} (85%)

diff --git a/__manifest__.py b/__manifest__.py
index 27cac26..933aba2 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -2,7 +2,7 @@
 
 {
     'name': 'Le Filament - Training',
-    'version': '10.0.1.0',
+    'version': '13.0.1.0.0',
     'summary': 'Training sessions managment',
     'license': 'AGPL-3',
     'author': 'LE FILAMENT',
@@ -17,7 +17,7 @@
         'security/training_security.xml',
         'security/ir.model.access.csv',
         'data/training_data.xml',
-        'views/account_invoice_view.xml',
+        'views/account_move_view.xml',
         'views/assets.xml',
         'views/partner_view.xml',
         'views/sale_order_view.xml',
diff --git a/models/__init__.py b/models/__init__.py
index 4c05e4e..6a8b089 100644
--- a/models/__init__.py
+++ b/models/__init__.py
@@ -2,7 +2,7 @@
 # © 2019 Le Filament (<http://www.le-filament.com>)
 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 
-from . import account_invoice
+from . import account_move
 from . import partner
 from . import sale_order
 from . import training_course
diff --git a/models/account_invoice.py b/models/account_move.py
similarity index 90%
rename from models/account_invoice.py
rename to models/account_move.py
index 8010643..a314623 100644
--- a/models/account_invoice.py
+++ b/models/account_move.py
@@ -6,7 +6,7 @@ from odoo import models, fields
 
 
 class AccountInvoiceTraining(models.Model):
-    _inherit = ['account.invoice']
+    _inherit = ['account.move']
 
     training_id = fields.Many2one(
         comodel_name='training.training',
diff --git a/models/training_training.py b/models/training_training.py
index bd3e337..c862e86 100644
--- a/models/training_training.py
+++ b/models/training_training.py
@@ -86,7 +86,7 @@ class Training(models.Model):
         inverse_name='training_id',
         string='Commandes',)
     invoice_ids = fields.One2many(
-        comodel_name='account.invoice',
+        comodel_name='account.move',
         inverse_name='training_id',
         string='Factures',)
     state = fields.Selection(
@@ -123,7 +123,6 @@ class Training(models.Model):
                 })
         return record
 
-    @api.multi
     def write(self, vals):
         record = super(Training, self).write(vals)
         if vals.get('course_id', False):
@@ -171,23 +170,19 @@ class Training(models.Model):
     # ------------------------------------------------------
     # Buttons
     # ------------------------------------------------------
-    @api.multi
     def action_valid(self):
         for training in self:
             training.state = 'current'
             training.agreement_number = self.env['ir.sequence'].next_by_code('training.training')
 
-    @api.multi
     def action_done(self):
         for training in self:
             training.state = 'done'
 
-    @api.multi
     def action_draft(self):
         for training in self:
             training.state = 'draft'
 
-    @api.multi
     def _get_trainers(self):
         for training in self:
             trainers = training.session_ids.mapped('user_id')
diff --git a/views/account_invoice_view.xml b/views/account_move_view.xml
similarity index 85%
rename from views/account_invoice_view.xml
rename to views/account_move_view.xml
index 807403b..4d32af8 100644
--- a/views/account_invoice_view.xml
+++ b/views/account_move_view.xml
@@ -6,8 +6,8 @@
 	    <!-- Client Form View -->
 	    <record id="account_invoice_training_form_view" model="ir.ui.view">
 		    <field name="name">Invoice Training Form View</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" >
                 <xpath expr="//page[@name='other_info']/group/group[2]" position="inside">
                     <field 
diff --git a/views/assets.xml b/views/assets.xml
index 59882ac..65aa215 100644
--- a/views/assets.xml
+++ b/views/assets.xml
@@ -3,7 +3,7 @@
 <odoo>
 	<data>
 
-		<template id="training_assets" inherit_id="web.report_assets_editor">
+		<template id="training_assets" inherit_id="web.report_assets_common">
 			<xpath expr="." position="inside">
 				<link rel="stylesheet" href="/lefilament_training/static/src/less/style.less"/>
 			</xpath>
diff --git a/views/sale_order_view.xml b/views/sale_order_view.xml
index 69d0576..6b2d9ac 100644
--- a/views/sale_order_view.xml
+++ b/views/sale_order_view.xml
@@ -9,8 +9,8 @@
 		    <field name="model">sale.order</field>
 		    <field name="inherit_id" ref="sale.view_order_form"/>
 		    <field name="arch" type="xml" >
-                <xpath expr="//group[@name='sale_pay']" position="inside">
-                    <field 
+                <xpath expr="//group[@name='sale_info']" position="inside">
+                    <field
                     	name="training_id"
                     	domain="['|', ('customer_id', '=', partner_id), ('opco_id', '=', partner_id)]"
                     	options="{ 'no_create_edit': True, }" />
-- 
GitLab