diff --git a/account_mass_reconcile/README.rst b/account_mass_reconcile/README.rst index 56ac4215..5fe88688 100644 --- a/account_mass_reconcile/README.rst +++ b/account_mass_reconcile/README.rst @@ -14,13 +14,13 @@ Account Mass Reconcile :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github - :target: https://github.com/OCA/account-reconcile/tree/12.0/account_mass_reconcile + :target: https://github.com/OCA/account-reconcile/tree/13.0/account_mass_reconcile :alt: OCA/account-reconcile .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-reconcile-12-0/account-reconcile-12-0-account_mass_reconcile + :target: https://translation.odoo-community.org/projects/account-reconcile-13-0/account-reconcile-13-0-account_mass_reconcile :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/98/12.0 + :target: https://runbot.odoo-community.org/runbot/98/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -62,7 +62,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -96,6 +96,7 @@ Contributors * Damien Crier * Akim Juillerat * Mykhailo Panarin +* Adrià Gil Sorribes Maintainers ~~~~~~~~~~~ @@ -110,6 +111,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/account-reconcile `_ project on GitHub. +This module is part of the `OCA/account-reconcile `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_mass_reconcile/__manifest__.py b/account_mass_reconcile/__manifest__.py index 16a9ac2d..c09a1e91 100644 --- a/account_mass_reconcile/__manifest__.py +++ b/account_mass_reconcile/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Account Mass Reconcile", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "depends": ["account"], "author": "Akretion,Camptocamp,Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-reconcile", diff --git a/account_mass_reconcile/models/advanced_reconciliation.py b/account_mass_reconcile/models/advanced_reconciliation.py index dd18b60b..af0a4459 100644 --- a/account_mass_reconcile/models/advanced_reconciliation.py +++ b/account_mass_reconcile/models/advanced_reconciliation.py @@ -9,6 +9,7 @@ class MassReconcileAdvancedRef(models.TransientModel): _name = "mass.reconcile.advanced.ref" _inherit = "mass.reconcile.advanced" + _description = "Mass Reconcile Advanced Ref" @staticmethod def _skip_line(move_line): diff --git a/account_mass_reconcile/models/base_advanced_reconciliation.py b/account_mass_reconcile/models/base_advanced_reconciliation.py index 7632e7b3..3e036fae 100644 --- a/account_mass_reconcile/models/base_advanced_reconciliation.py +++ b/account_mass_reconcile/models/base_advanced_reconciliation.py @@ -5,7 +5,7 @@ import logging from itertools import product -from odoo import api, models +from odoo import models from odoo.tools.translate import _ _logger = logging.getLogger(__name__) @@ -14,6 +14,7 @@ _logger = logging.getLogger(__name__) class MassReconcileAdvanced(models.AbstractModel): _name = "mass.reconcile.advanced" _inherit = "mass.reconcile.base" + _description = "Mass Reconcile Advanced" def _query_debit(self): """Select all move (debit>0) as candidate. """ @@ -217,9 +218,9 @@ class MassReconcileAdvanced(models.AbstractModel): """ return False - @api.multi def _rec_auto_lines_advanced(self, credit_lines, debit_lines): """ Advanced reconciliation main loop """ + # pylint: disable=invalid-commit reconciled_ids = [] for rec in self: reconcile_groups = [] diff --git a/account_mass_reconcile/models/base_reconciliation.py b/account_mass_reconcile/models/base_reconciliation.py index 6ae8d692..909c84e6 100644 --- a/account_mass_reconcile/models/base_reconciliation.py +++ b/account_mass_reconcile/models/base_reconciliation.py @@ -5,7 +5,7 @@ from functools import reduce from operator import itemgetter -from odoo import _, api, fields, models +from odoo import _, fields, models from odoo.tools.safe_eval import safe_eval @@ -14,6 +14,7 @@ class MassReconcileBase(models.AbstractModel): _name = "mass.reconcile.base" _inherit = "mass.reconcile.options" + _description = "Mass Reconcile Base" account_id = fields.Many2one("account.account", string="Account", required=True) partner_ids = fields.Many2many( @@ -21,7 +22,6 @@ class MassReconcileBase(models.AbstractModel): ) # other fields are inherited from mass.reconcile.options - @api.multi def automatic_reconcile(self): """ Reconciliation method called from the view. @@ -65,7 +65,6 @@ class MassReconcileBase(models.AbstractModel): def _from_query(self, *args, **kwargs): return "FROM account_move_line " - @api.multi def _where_query(self, *args, **kwargs): self.ensure_one() where = ( @@ -82,7 +81,6 @@ class MassReconcileBase(models.AbstractModel): params.append(tuple([l.id for l in self.partner_ids])) return where, params - @api.multi def _get_filter(self): self.ensure_one() ml_obj = self.env["account.move.line"] @@ -94,7 +92,6 @@ class MassReconcileBase(models.AbstractModel): where = " AND %s" % where return where, params - @api.multi def _below_writeoff_limit(self, lines, writeoff_limit): self.ensure_one() precision = self.env["decimal.precision"].precision_get("Account") @@ -109,7 +106,6 @@ class MassReconcileBase(models.AbstractModel): writeoff_amount = round(debit - credit, precision) return bool(writeoff_limit >= abs(writeoff_amount)), debit, credit - @api.multi def _get_rec_date(self, lines, based_on="end_period_last_credit"): self.ensure_one() @@ -132,7 +128,6 @@ class MassReconcileBase(models.AbstractModel): # when date is None return None - @api.multi def _reconcile_lines(self, lines, allow_partial=False): """ Try to reconcile given lines diff --git a/account_mass_reconcile/models/mass_reconcile.py b/account_mass_reconcile/models/mass_reconcile.py index 828897a9..5e9673f1 100644 --- a/account_mass_reconcile/models/mass_reconcile.py +++ b/account_mass_reconcile/models/mass_reconcile.py @@ -5,6 +5,8 @@ import logging from datetime import datetime +from psycopg2.extensions import AsIs + from odoo import _, api, fields, models, sql_db from odoo.exceptions import Warning as UserError @@ -37,7 +39,7 @@ class MassReconcileOptions(models.AbstractModel): string="Date of reconciliation", default="newest", ) - _filter = fields.Char(string="Filter", oldname="filter") + _filter = fields.Char(string="Filter") income_exchange_account_id = fields.Many2one( "account.account", string="Gain Exchange Rate Account" ) @@ -48,7 +50,7 @@ class MassReconcileOptions(models.AbstractModel): class AccountMassReconcileMethod(models.Model): _name = "account.mass.reconcile.method" - _description = "reconcile method for account_mass_reconcile" + _description = "Reconcile Method for account_mass_reconcile" _inherit = "mass.reconcile.options" _order = "sequence" @@ -86,20 +88,18 @@ class AccountMassReconcileMethod(models.Model): class AccountMassReconcile(models.Model): _name = "account.mass.reconcile" _inherit = ["mail.thread"] - _description = "account mass reconcile" + _description = "Account Mass Reconcile" - @api.multi @api.depends("account") - def _get_total_unrec(self): + def _compute_total_unrec(self): obj_move_line = self.env["account.move.line"] for rec in self: rec.unreconciled_count = obj_move_line.search_count( [("account_id", "=", rec.account.id), ("reconciled", "=", False)] ) - @api.multi @api.depends("history_ids") - def _last_history(self): + def _compute_last_history(self): # do a search() for retrieving the latest history line, # as a read() will badly split the list of ids with 'date desc' # and return the wrong result. @@ -116,7 +116,7 @@ class AccountMassReconcile(models.Model): "account.mass.reconcile.method", "task_id", string="Method" ) unreconciled_count = fields.Integer( - string="Unreconciled Items", compute="_get_total_unrec" + string="Unreconciled Items", compute="_compute_total_unrec" ) history_ids = fields.One2many( "mass.reconcile.history", "mass_reconcile_id", string="History", readonly=True @@ -125,7 +125,7 @@ class AccountMassReconcile(models.Model): "mass.reconcile.history", string="Last history", readonly=True, - compute="_last_history", + compute="_compute_last_history", ) company_id = fields.Many2one("res.company", string="Company") @@ -143,17 +143,17 @@ class AccountMassReconcile(models.Model): "_filter": rec_method._filter, } - @api.multi def run_reconcile(self): def find_reconcile_ids(fieldname, move_line_ids): if not move_line_ids: return [] - sql = ( - "SELECT DISTINCT " + fieldname + " FROM account_move_line " - " WHERE id in %s " - " AND " + fieldname + " IS NOT NULL" - ) - self.env.cr.execute(sql, (tuple(move_line_ids),)) + self.flush() + sql = """ + SELECT DISTINCT %s FROM account_move_line + WHERE %s IS NOT NULL AND id in %s + """ + params = [AsIs(fieldname), AsIs(fieldname), tuple(move_line_ids)] + self.env.cr.execute(sql, params) res = self.env.cr.fetchall() return [row[0] for row in res] @@ -235,7 +235,6 @@ class AccountMassReconcile(models.Model): "domain": [("id", "in", move_line_ids)], } - @api.multi def open_unreconcile(self): """ Open the view of move line with the unreconciled move lines""" self.ensure_one() diff --git a/account_mass_reconcile/models/mass_reconcile_history.py b/account_mass_reconcile/models/mass_reconcile_history.py index 4b10a6fb..11ef62c1 100644 --- a/account_mass_reconcile/models/mass_reconcile_history.py +++ b/account_mass_reconcile/models/mass_reconcile_history.py @@ -15,9 +15,8 @@ class MassReconcileHistory(models.Model): _rec_name = "mass_reconcile_id" _order = "date DESC" - @api.multi @api.depends("reconcile_ids") - def _get_reconcile_line_ids(self): + def _compute_reconcile_line_ids(self): for rec in self: rec.reconcile_line_ids = rec.mapped("reconcile_ids.reconciled_line_ids").ids @@ -35,7 +34,7 @@ class MassReconcileHistory(models.Model): comodel_name="account.move.line", relation="account_move_line_history_rel", string="Reconciled Items", - compute="_get_reconcile_line_ids", + compute="_compute_reconcile_line_ids", ) company_id = fields.Many2one( "res.company", @@ -45,7 +44,6 @@ class MassReconcileHistory(models.Model): related="mass_reconcile_id.company_id", ) - @api.multi def _open_move_lines(self): """ For an history record, open the view of move line with the reconciled move lines @@ -67,7 +65,6 @@ class MassReconcileHistory(models.Model): "domain": [("id", "in", move_line_ids)], } - @api.multi def open_reconcile(self): """ For an history record, open the view of move line with the reconciled move lines diff --git a/account_mass_reconcile/models/simple_reconciliation.py b/account_mass_reconcile/models/simple_reconciliation.py index 0c0f5244..f55c4801 100644 --- a/account_mass_reconcile/models/simple_reconciliation.py +++ b/account_mass_reconcile/models/simple_reconciliation.py @@ -2,18 +2,18 @@ # Copyright 2010 Sébastien Beau # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models +from odoo import models class MassReconcileSimple(models.AbstractModel): _name = "mass.reconcile.simple" _inherit = "mass.reconcile.base" + _description = "Mass Reconcile Simple" # has to be subclassed # field name used as key for matching the move lines _key_field = None - @api.multi def rec_auto_lines_simple(self, lines): if self._key_field is None: raise ValueError("_key_field has to be defined") @@ -67,6 +67,7 @@ class MassReconcileSimple(models.AbstractModel): class MassReconcileSimpleName(models.TransientModel): _name = "mass.reconcile.simple.name" _inherit = "mass.reconcile.simple" + _description = "Mass Reconcile Simple Name" # has to be subclassed # field name used as key for matching the move lines @@ -76,6 +77,7 @@ class MassReconcileSimpleName(models.TransientModel): class MassReconcileSimplePartner(models.TransientModel): _name = "mass.reconcile.simple.partner" _inherit = "mass.reconcile.simple" + _description = "Mass Reconcile Simple Partner" # has to be subclassed # field name used as key for matching the move lines @@ -85,6 +87,7 @@ class MassReconcileSimplePartner(models.TransientModel): class MassReconcileSimpleReference(models.TransientModel): _name = "mass.reconcile.simple.reference" _inherit = "mass.reconcile.simple" + _description = "Mass Reconcile Simple Reference" # has to be subclassed # field name used as key for matching the move lines diff --git a/account_mass_reconcile/readme/CONTRIBUTORS.rst b/account_mass_reconcile/readme/CONTRIBUTORS.rst index 36a3d934..8dbad2e1 100644 --- a/account_mass_reconcile/readme/CONTRIBUTORS.rst +++ b/account_mass_reconcile/readme/CONTRIBUTORS.rst @@ -16,3 +16,4 @@ * Damien Crier * Akim Juillerat * Mykhailo Panarin +* Adrià Gil Sorribes diff --git a/account_mass_reconcile/static/description/index.html b/account_mass_reconcile/static/description/index.html index 7ee7353d..2f8792f4 100644 --- a/account_mass_reconcile/static/description/index.html +++ b/account_mass_reconcile/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-reconcile Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/account-reconcile Translate me on Weblate Try me on Runbot

This is a shared work between Akretion and Camptocamp in order to provide:

@@ -452,7 +453,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/account-reconcile project on GitHub.

+

This module is part of the OCA/account-reconcile project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/account_mass_reconcile/tests/test_scenario_reconcile.py b/account_mass_reconcile/tests/test_scenario_reconcile.py index ddbef084..9ef536f5 100644 --- a/account_mass_reconcile/tests/test_scenario_reconcile.py +++ b/account_mass_reconcile/tests/test_scenario_reconcile.py @@ -21,7 +21,7 @@ class TestScenarioReconcile(common.SavepointCase): ) cls.rec_history_obj = cls.env["mass.reconcile.history"] cls.mass_rec_obj = cls.env["account.mass.reconcile"] - cls.invoice_obj = cls.env["account.invoice"] + cls.invoice_obj = cls.env["account.move"] cls.bk_stmt_obj = cls.env["account.bank.statement"] cls.bk_stmt_line_obj = cls.env["account.bank.statement.line"] cls.acc_move_line_obj = cls.env["account.move.line"] @@ -45,10 +45,9 @@ class TestScenarioReconcile(common.SavepointCase): def test_scenario_reconcile(self): # create invoice - invoice = self.invoice_obj.create( + invoice = self.invoice_obj.with_context(default_type="out_invoice").create( { "type": "out_invoice", - "account_id": self.ref("account.a_recv"), "company_id": self.ref("base.main_company"), "journal_id": self.ref("account.sales_journal"), "partner_id": self.ref("base.res_partner_12"), @@ -57,7 +56,7 @@ class TestScenarioReconcile(common.SavepointCase): 0, 0, { - "name": "[PCSC234] PC Assemble SC234", + "name": "[FURN_7800] Desk Combination", "account_id": self.ref("account.a_sale"), "price_unit": 1000.0, "quantity": 1.0, @@ -68,8 +67,8 @@ class TestScenarioReconcile(common.SavepointCase): } ) # validate invoice - invoice.action_invoice_open() - self.assertEqual("open", invoice.state) + invoice.post() + self.assertEqual("posted", invoice.state) # create bank_statement statement = self.bk_stmt_obj.create( @@ -85,8 +84,8 @@ class TestScenarioReconcile(common.SavepointCase): { "amount": 1000.0, "partner_id": self.ref("base.res_partner_12"), - "name": invoice.number, - "ref": invoice.number, + "name": invoice.name, + "ref": invoice.name, }, ) ], @@ -95,8 +94,8 @@ class TestScenarioReconcile(common.SavepointCase): # reconcile line_id = None - for l in invoice.move_id.line_ids: - if l.account_id.id == self.ref("account.a_recv"): + for l in invoice.line_ids: + if l.account_id.internal_type == "receivable": line_id = l break @@ -107,7 +106,7 @@ class TestScenarioReconcile(common.SavepointCase): "move_line": line_id, "credit": 1000.0, "debit": 0.0, - "name": invoice.number, + "name": invoice.name, } ] ) @@ -122,13 +121,14 @@ class TestScenarioReconcile(common.SavepointCase): mass_rec = self.mass_rec_obj.create( { "name": "mass_reconcile_1", - "account": self.ref("account.a_recv"), + "account": line_id.account_id.id, "reconcile_method": [(0, 0, {"name": "mass.reconcile.simple.partner"})], } ) # call the automatic reconcilation method mass_rec.run_reconcile() - self.assertEqual("paid", invoice.state) + invoice.invalidate_cache() + self.assertEqual("paid", invoice.invoice_payment_state) def test_scenario_reconcile_currency(self): # create currency rate @@ -140,20 +140,19 @@ class TestScenarioReconcile(common.SavepointCase): } ) # create invoice - invoice = self.invoice_obj.create( + invoice = self.invoice_obj.with_context(default_type="out_invoice").create( { "type": "out_invoice", - "account_id": self.ref("account.a_recv"), "company_id": self.ref("base.main_company"), "currency_id": self.ref("base.USD"), - "journal_id": self.ref("account.bank_journal_usd"), + "journal_id": self.ref("account.sales_journal"), "partner_id": self.ref("base.res_partner_12"), "invoice_line_ids": [ ( 0, 0, { - "name": "[PCSC234] PC Assemble SC234", + "name": "[FURN_7800] Desk Combination", "account_id": self.ref("account.a_sale"), "price_unit": 1000.0, "quantity": 1.0, @@ -164,8 +163,8 @@ class TestScenarioReconcile(common.SavepointCase): } ) # validate invoice - invoice.action_invoice_open() - self.assertEqual("open", invoice.state) + invoice.post() + self.assertEqual("posted", invoice.state) # create bank_statement statement = self.bk_stmt_obj.create( @@ -183,8 +182,8 @@ class TestScenarioReconcile(common.SavepointCase): "amount": 1000.0, "amount_currency": 1500.0, "partner_id": self.ref("base.res_partner_12"), - "name": invoice.number, - "ref": invoice.number, + "name": invoice.name, + "ref": invoice.name, }, ) ], @@ -193,8 +192,8 @@ class TestScenarioReconcile(common.SavepointCase): # reconcile line_id = None - for l in invoice.move_id.line_ids: - if l.account_id.id == self.ref("account.a_recv"): + for l in invoice.line_ids: + if l.account_id.internal_type == "receivable": line_id = l break @@ -205,7 +204,7 @@ class TestScenarioReconcile(common.SavepointCase): "move_line": line_id, "credit": 1000.0, "debit": 0.0, - "name": invoice.number, + "name": invoice.name, } ] ) @@ -219,10 +218,11 @@ class TestScenarioReconcile(common.SavepointCase): mass_rec = self.mass_rec_obj.create( { "name": "mass_reconcile_1", - "account": self.ref("account.a_recv"), + "account": line_id.account_id.id, "reconcile_method": [(0, 0, {"name": "mass.reconcile.simple.partner"})], } ) # call the automatic reconcilation method mass_rec.run_reconcile() - self.assertEqual("paid", invoice.state) + invoice.invalidate_cache() + self.assertEqual("paid", invoice.invoice_payment_state) diff --git a/account_mass_reconcile/views/mass_reconcile.xml b/account_mass_reconcile/views/mass_reconcile.xml index 9247b4a1..ce59569a 100644 --- a/account_mass_reconcile/views/mass_reconcile.xml +++ b/account_mass_reconcile/views/mass_reconcile.xml @@ -142,7 +142,6 @@ The lines should have the same partner, and the credit entry ref. is matched wit Mass Automatic Reconcile ir.actions.act_window account.mass.reconcile - form tree,form

diff --git a/account_mass_reconcile/views/mass_reconcile_history_view.xml b/account_mass_reconcile/views/mass_reconcile_history_view.xml index 7b39d56f..30d7ffc7 100644 --- a/account_mass_reconcile/views/mass_reconcile_history_view.xml +++ b/account_mass_reconcile/views/mass_reconcile_history_view.xml @@ -85,7 +85,6 @@ Mass Automatic Reconcile History ir.actions.act_window mass.reconcile.history - form tree,form