# HG changeset patch
# User Damien Habets <damien.habets@xcg-consulting.fr>
# Date 1593716330 -7200
#      Thu Jul 02 20:58:50 2020 +0200
# Branch 13.0
# Node ID a4197a67934f883bee50c43b9ac1aa9ea695cbb9
# Parent  dbe757b5a676d20a8c3e6caef2b16ad96482982e
[MIG] Update to 13.0

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,3 @@
+include:
+- project: xcg/ci-templates
+  file: /odoo/13.0/gitlab-ci.yaml
diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -1,3 +1,9 @@
+13.0.1.0.0
+==========
+
+* Migrate to Odoo 13.0.
+
+
 11.0.1.1.0
 ==========
 
diff --git a/__manifest__.py b/__manifest__.py
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -51,14 +51,13 @@
     * Parser (``parser``): ``account_report.reports.account_statement.Parser``.
       Optional; provides ``debit_sum``, ``credit_sum``, ``balance_sum``.
 """,
-    "version": "11.0.1.1.0",
+    "version": "13.0.1.1.0",
     "category": "Accounting",
     "author": "XCG Consulting",
     "website": "http://odoo.consulting/",
     "depends": [
         "base",
         "account",
-        "account_invoicing",
         "account_payment_split",
         "account_period",
         "analytic_structure",
diff --git a/menu.xml b/menu.xml
--- a/menu.xml
+++ b/menu.xml
@@ -14,8 +14,8 @@
             parent="legal_reports_menu" />
 
         <!-- Make the older menu only available to the administrator -->
-        <record id="account.menu_finance_legal_statement" model="ir.ui.menu">
-            <field name="groups_id" eval="[(6, 0, [ref('base.group_no_one')])]" />
-        </record>
+<!--        <record id="account.menu_finance_legal_statement" model="ir.ui.menu">-->
+<!--            <field name="groups_id" eval="[(6, 0, [ref('base.group_no_one')])]" />-->
+<!--        </record>-->
     </data>
 </odoo>
diff --git a/models/account_invoice.py b/models/account_invoice.py
--- a/models/account_invoice.py
+++ b/models/account_invoice.py
@@ -18,27 +18,27 @@
 #
 ##############################################################################
 
-from odoo import api, fields, models
+from odoo import fields, models
 
 
 class Invoice(models.Model):
-    """Adapt invoices to reporting needs:
+    """Adapt invoices (account.move) to reporting needs:
     - "Paid amount" field.
     """
 
-    _inherit = "account.invoice"
+    _inherit = "account.move"
 
-    @api.one
     def _get_paid_amount(self):
-        self.paid_amount = (
-            (self.amount_total or 0.0) - (self.residual or 0.0)
-            if self.state != "draft"
-            else 0.0  # residual = 0 when draft so force this to 0.
-        )
+        for record in self:
+            record.paid_amount = (
+                (record.amount_total or 0.0) - (record.amount_residual or 0.0)
+                if record.state != "draft"
+                else 0.0  # in 11.0 residual = 0 when draft so force this to 0.
+            )
 
     paid_amount = fields.Monetary(
         compute=_get_paid_amount,
         compute_sudo=True,
         string="Paid amount",
-        help="amount_total - residual",
+        help="amount_total - amount_residual",
     )
diff --git a/models/account_move_line.py b/models/account_move_line.py
--- a/models/account_move_line.py
+++ b/models/account_move_line.py
@@ -30,9 +30,9 @@
     _inherit = "account.move.line"
 
     @api.depends("debit", "credit")
-    @api.one
     def _get_reporting_balance(self):
-        self.reporting_balance = (self.debit or 0.0) - (self.credit or 0.0)
+        for rec in self:
+            rec.reporting_balance = (rec.debit or 0.0) - (rec.credit or 0.0)
 
     reporting_balance = fields.Monetary(
         compute=_get_reporting_balance,
@@ -41,7 +41,6 @@
         store=True,
     )
 
-    @api.multi
     def control_reconciliation_access(self):
         """Correct the controls performed by Odoo on accounting entries
         before reconciliation, for these contain errors.
@@ -66,6 +65,7 @@
                     "all entries!"
                 )
             )
+        partners.discard(False)
         if len(set(partners)) > 1:
             raise UserError(_("Entries are not of the same partner!"))
         if len(set(all_accounts)) > 1:
@@ -81,7 +81,6 @@
 
         return True
 
-    @api.multi
     def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False):
 
         self.control_reconciliation_access()
@@ -91,7 +90,6 @@
             writeoff_journal_id=writeoff_journal_id,
         )
 
-    @api.multi
     def force_full_reconcile(self):
 
         self.control_reconciliation_access()
diff --git a/reports/account_statement.py b/reports/account_statement.py
--- a/reports/account_statement.py
+++ b/reports/account_statement.py
@@ -23,6 +23,7 @@
 
 class ReportAccountStatement(models.AbstractModel):
     _name = "report.account_report.report_account_statement"
+    _description = "Report Account Statement"
 
     @api.model
     def _get_report_values(self, docids, data=None):
diff --git a/tests/test_account_report.py b/tests/test_account_report.py
--- a/tests/test_account_report.py
+++ b/tests/test_account_report.py
@@ -18,6 +18,7 @@
 #
 ##############################################################################
 
+import time
 import uuid
 
 import odoo.exceptions
@@ -54,6 +55,8 @@
 
         self.product = self.env.ref("product.product_product_1")
 
+        self.a_period = self._create_account_period()
+
     def test_consult_account(self):
         """Consult an account.
         """
@@ -99,33 +102,35 @@
         """Check the "Paid amount" field we have added into invoices.
         """
 
-        # Create an inovice.
+        # Create an invoice.
         client = self._createPartner()
         invoice = self._makeInvoice(client)
         self.assertEqual(invoice.paid_amount, 0.0)  # No payments so far.
 
         # Validate the invoice.
-        self._validateInvoices(invoice)
+        self.assertEqual(invoice.state, "draft")
+        self._validateAccDoc(invoice)
         invoice.refresh()
+        self.assertEqual(invoice.state, "posted")
         self.assertEqual(invoice.paid_amount, 0.0)  # No payments so far.
 
         # Partial payment.
         self._payInvoice(invoice, 2.0)
         invoice.refresh()
         self.assertEqual(invoice.paid_amount, 2.0)
-        self.assertEqual(invoice.state, "open")
+        self.assertEqual(invoice.state, "posted")
 
         # Partial payment.
         self._payInvoice(invoice, 4.0)
         invoice.refresh()
         self.assertEqual(invoice.paid_amount, 2.0 + 4.0)
-        self.assertEqual(invoice.state, "open")
+        self.assertEqual(invoice.state, "posted")
 
         # Pay the rest.
         self._payInvoice(invoice, AMOUNT - 2.0 - 4.0)
         invoice.refresh()
         self.assertEqual(invoice.paid_amount, AMOUNT)
-        self.assertEqual(invoice.state, "paid")
+        self.assertEqual(invoice.invoice_payment_state, "paid")
 
     def _consult_account(self, account, **kwargs):
         """Consult the specified account; return extracted accounting entries.
@@ -176,11 +181,9 @@
 
         return self.env["res.partner"].create(
             {
-                "customer": True,
                 "is_company": True,
                 "name": "TEST-PARTNER-NAME",
                 "property_account_receivable_id": self.debit_account.id,
-                "supplier": False,
             }
         )
 
@@ -213,7 +216,7 @@
             {
                 "journal_id": self.sales_journal.id,
                 "line_ids": [(0, 0, values) for values in accentry_values],
-                "period_id": self.env.ref("account_period.period_1").id,
+                "period_id": self.a_period.id,
                 "ref": uuid.uuid4().hex[:16],
             }
         )
@@ -229,16 +232,18 @@
         return accdoc
 
     def _makeInvoice(self, client):
-        """Create an invoice and return it.
+        """Create an accout.move with account.move.line and return it.
 
         :type client: Odoo "res.partner" record.
 
-        :return: The invoice.
-        :rtype: Odoo "account.invoice" record.
+        :return: The account entry representing the invoice.
+        :rtype: Odoo "account.move" record.
         """
 
-        return self.env["account.invoice"].create(
+        return self.env["account.move"].create(
             {
+                "partner_id": client.id,
+                "type": "out_invoice",
                 "invoice_line_ids": [
                     (
                         0,  # 0: Create.
@@ -252,8 +257,6 @@
                         },
                     )
                 ],
-                "partner_id": client.id,
-                "type": "out_invoice",
             }
         )
 
@@ -261,13 +264,13 @@
         """Register a payment to pay the specified invoice. Partial payments
         supported.
 
-        :type invoice: Odoo "account.invoice" record.
+        :type invoice: Odoo "account.move" record.
 
         :param amount_to_pay: How much of the invoice is being paid.
         :type amount_to_pay: Float.
         """
 
-        acc_entry_to_pay = invoice.move_id.line_ids.filtered(
+        acc_entry_to_pay = invoice.line_ids.filtered(
             lambda aml: aml.account_id.id == self.debit_account.id
         )
         self.assertEqual(len(acc_entry_to_pay), 1)
@@ -297,15 +300,41 @@
         accdoc.post()
         self.assertEqual(accdoc.state, "posted")
 
-    def _validateInvoices(self, invoices):
-        """Validate the specified invoices.
+    def _pay_partiallyAccDoc(self, accdoc):
+        """Validate the specified accounting document.
 
-        :type invoice: Odoo "account.invoice" record set.
+        :type accdoc: Odoo "account.move" record set.
         """
 
-        self.assertTrue(invoices)
-        for invoice in invoices:
-            self.assertEqual(invoice.state, "draft")
-        invoices.action_invoice_open()
-        for invoice in invoices:
-            self.assertEqual(invoice.state, "open")
+        self.assertEqual(accdoc.state, "draft")
+        accdoc.post()
+        self.assertEqual(accdoc.state, "posted")
+
+    def _create_account_period(self):
+        """Create an accout.period and return it
+
+        :rtype: Odoo "account.period" record.
+        """
+        # Create an account.fiscalyear
+        a_fiscalyear = self.env["account.fiscalyear"].create(
+            {
+                "name": "Fiscal Year X " + time.strftime("%Y"),
+                "code": "FY" + time.strftime("%Y"),
+                "company_id": self.env.ref("base.main_company").id,
+                "date_stop": time.strftime("%Y") + "-12-31",
+            }
+        )
+
+        # Create an account.period
+        a_period = self.env["account.period"].create(
+            {
+                "code": "FY" + time.strftime("%Y"),
+                "name": "Fiscal Year X " + time.strftime("%Y"),
+                "fiscalyear_id": a_fiscalyear.id,
+                "date_start": time.strftime("%Y") + "-01-01",
+                "date_stop": time.strftime("%Y") + "-12-31",
+                "company_id": self.env.ref("base.main_company").id,
+            }
+        )
+
+        return a_period
diff --git a/views/account_move_line.xml b/views/account_move_line.xml
--- a/views/account_move_line.xml
+++ b/views/account_move_line.xml
@@ -11,7 +11,7 @@
             <field name="arch" type="xml">
 
                 <tree>
-                    <field name="move_state" string="State" />
+                    <field name="parent_state" string="State" />
                     <field name="ref" />
                     <field name="move_id" />
                     <field name="period_id" />
@@ -19,12 +19,10 @@
                     <field name="date_maturity" />
                     <field name="journal_id" />
                     <field name="partner_id" />
-                    <field name="partner_client_code" />
-                    <field name="partner_supplier_code" />
+                    <field name="partner_code" />
                     <field name="account_id" />
                     <field name="name" />
                     <field name="full_reconcile_id" />
-                    <field name="date_reconcile" />
                     <field name="debit" sum="Total" />
                     <field name="credit" sum="Total" />
                     <field name="reporting_balance" string="Balance" sum="Total" />
@@ -40,13 +38,12 @@
             <field name="arch" type="xml">
 
                 <tree>
-                    <field name="move_state" string="State" />
+                    <field name="parent_state" string="State" />
                     <field name="ref" />
                     <field name="move_id" />
                     <field name="period_id" />
                     <field name="partner_id" />
-                    <field name="partner_client_code" />
-                    <field name="partner_supplier_code" />
+                    <field name="partner_code" />
                     <field name="account_id" />
                     <field name="name" />
                     <field name="tax_line_id" />
diff --git a/wizards/account_consultation.py b/wizards/account_consultation.py
--- a/wizards/account_consultation.py
+++ b/wizards/account_consultation.py
@@ -81,12 +81,12 @@
     )
 
     @api.depends("include_closed_periods")
-    @api.one
     def _get_period_closed_state(self):
         """Trick used in period_from_id / period_to_id view-side domains."""
-        self.period_closed_state = (
-            "done" if self.include_closed_periods else "draft"
-        )
+        for record in self:
+            record.period_closed_state = (
+                "done" if record.include_closed_periods else "draft"
+            )
 
     period_closed_state = fields.Char(
         compute=_get_period_closed_state,
@@ -191,24 +191,24 @@
 
         self._refresh_ref_preview()
 
-    @api.one
     def name_get(self):
-        """Override to name this record as we display it inline."""
+        for record in self:
+            """Override to name this record as we display it inline."""
 
-        account = self.account_id
+            account = record.account_id
 
-        # 0 & 1 below: name_get returns a list of (ID, name) tuples.
-        return (
-            self.id,
-            (
-                _("Account consultation - %s")
-                % (
-                    account.name_get()[0][1]
-                    if account
-                    else self.partner_id.name_get()[0][1]
-                )
-            ),
-        )
+            # 0 & 1 below: name_get returns a list of (ID, name) tuples.
+            return (
+                record.id,
+                (
+                    _("Account consultation - %s")
+                    % (
+                        account.name_get()[0][1]
+                        if account
+                        else record.partner_id.name_get()[0][1]
+                    )
+                ),
+            )
 
     def get_partner_account_fields(self):
         """Provide partner fields that reference accounts. This method is here
@@ -221,7 +221,6 @@
             "property_account_payable_id",
         ]
 
-    @api.multi
     def open_aml_list(self, list_view_ref, list_view_title):
         """Open the accounting entry list for the specified account.
         :param list_view_ref: The "account.move.line" view to display.
@@ -254,14 +253,12 @@
             "res_model": "account.move.line",
             "type": "ir.actions.act_window",
             "view_mode": "tree,form",
-            "view_type": "form",
             "views": [
                 (self.env.ref(list_view_ref).id, "tree"),
                 (self.env.ref("account.view_move_line_form").id, "form"),
             ],
         }
 
-    @api.multi
     def open_general_list(self):
         """Open the accounting entry list for the specified account.
         """
@@ -273,7 +270,6 @@
             _("General list"),
         )
 
-    @api.multi
     def open_analytic_list(self):
         """Open the accounting entry list for the specified account.
         """
@@ -285,7 +281,6 @@
             _("Analytic list"),
         )
 
-    @api.multi
     def print_statement(self):
         """Print an account statement report (which needs to have been set up
         in advance).
@@ -364,9 +359,9 @@
         aml_domain.append(("period_id", "in", periods.ids))
 
         if self.transaction_state == "draft":
-            aml_domain.append(("move_state", "=", "draft"))
+            aml_domain.append(("parent_state", "=", "draft"))
         elif self.transaction_state == "validated":
-            aml_domain.append(("move_state", "=", "posted"))
+            aml_domain.append(("parent_state", "=", "posted"))
 
         if not self.include_reconciled:
             aml_domain.append(("full_reconcile_id", "=", False))
diff --git a/wizards/account_consultation.xml b/wizards/account_consultation.xml
--- a/wizards/account_consultation.xml
+++ b/wizards/account_consultation.xml
@@ -85,6 +85,7 @@
 
                     <group string="Matching references">
                         <label
+                            for=""
                             string="No accounting entry could be found with the specified parameters."
                             attrs="{'invisible': [('matching_count', '!=', 0)]}"
                             colspan="2" />
@@ -117,7 +118,7 @@
                     <button name="open_general_list" type="object" class="oe_highlight"
                         style="margin-right: 10px;">
                         <span>
-                            <i class="fa fa-list" aria-hidden="true"></i>
+                            <i class="fa fa-list" aria-hidden="true"/>
                             Open the general list
                         </span>
                     </button>
@@ -125,7 +126,7 @@
                     <button name="open_analytic_list" type="object"
                         class="oe_highlight" style="margin-right: 10px;">
                         <span>
-                            <i class="fa fa-list" aria-hidden="true"></i>
+                            <i class="fa fa-list" aria-hidden="true"/>
                             Open the analytic list
                         </span>
                     </button>
@@ -133,7 +134,7 @@
                     <button name="print_statement" type="object" class="oe_highlight"
                         style="margin-right: 10px;">
                         <span>
-                            <i class="fa fa-file-text-o" aria-hidden="true"></i>
+                            <i class="fa fa-file-text-o" aria-hidden="true"/>
                             Print the statement
                         </span>
                     </button>
@@ -152,7 +153,6 @@
         <field name="res_model">account.consultation</field>
         <field name="target">inline</field>
         <field name="view_mode">form</field>
-        <field name="view_type">form</field>
     </record>
 
     <menuitem id="account_consultation_menu_command" name="Account consultation"