diff --git a/.travis.yml b/.travis.yml index 6716bfad..a143c2e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ addons: apt: packages: - expect-dev # provides unbuffer utility + - swig stages: - linting diff --git a/account_mass_reconcile/tests/test_scenario_reconcile.py b/account_mass_reconcile/tests/test_scenario_reconcile.py index 9ef536f5..51c5607c 100644 --- a/account_mass_reconcile/tests/test_scenario_reconcile.py +++ b/account_mass_reconcile/tests/test_scenario_reconcile.py @@ -125,20 +125,35 @@ class TestScenarioReconcile(common.SavepointCase): "reconcile_method": [(0, 0, {"name": "mass.reconcile.simple.partner"})], } ) - # call the automatic reconcilation method + # call the automatic reconciliation method mass_rec.run_reconcile() invoice.invalidate_cache() self.assertEqual("paid", invoice.invoice_payment_state) def test_scenario_reconcile_currency(self): - # create currency rate - self.env["res.currency.rate"].create( - { - "name": fields.Date.today().strftime("%Y-%m-%d") + " 00:00:00", - "currency_id": self.ref("base.USD"), - "rate": 1.5, - } + currency_rate = ( + self.env["res.currency.rate"] + .sudo() + .search( + [ + ("currency_id", "=", self.ref("base.USD")), + ("company_id", "=", self.ref("base.main_company")), + ] + ) + .filtered(lambda r: r.name == fields.Date.today()) ) + if not currency_rate: + # create currency rate + self.env["res.currency.rate"].create( + { + "name": fields.Date.today(), + "currency_id": self.ref("base.USD"), + "rate": 1.5, + } + ) + else: + currency_rate = fields.first(currency_rate) + currency_rate.rate = 1.5 # create invoice invoice = self.invoice_obj.with_context(default_type="out_invoice").create( { diff --git a/account_mass_reconcile_by_purchase_line/README.rst b/account_mass_reconcile_by_purchase_line/README.rst new file mode 100644 index 00000000..419efb8f --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/README.rst @@ -0,0 +1,65 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +======================================= +Account Mass Reconcile by Purchase Line +======================================= + +This module extends the functionality of account_mass_reconcile and +allow an user to reconcile debits and credits of an Account +using the PO Line and Product as key fields. This type of +reconciliation is to be used in the context of the Perpetual Inventory +accounting system, with the accrual account '*Goods Received Not Invoiced*'. + +Usage +===== + +To use this module, you need to: + +* Go to 'Invoicing / Accounting / Actions / Mass Automatic Reconcile'. + +* Create a new reconciliation profile, and select a new configuration entry + with type 'Advanced. Product, purchase order line'. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/98/12.0 + +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 smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Jordi Ballester Alomar +* Miquel Raïch +* Lois Rilo + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_mass_reconcile_by_purchase_line/__init__.py b/account_mass_reconcile_by_purchase_line/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_mass_reconcile_by_purchase_line/__manifest__.py b/account_mass_reconcile_by_purchase_line/__manifest__.py new file mode 100644 index 00000000..26035eff --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Account Mass Reconcile by Purchase Line", + "summary": "Allows to reconcile based on the PO line", + "version": "13.0.1.0.0", + "author": "ForgeFlow, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-reconcile", + "category": "Finance", + "depends": ["account_mass_reconcile", "account_move_line_purchase_info"], + "license": "AGPL-3", + "data": ["views/mass_reconcile.xml"], + "installable": True, + "auto_install": False, +} diff --git a/account_mass_reconcile_by_purchase_line/i18n/account_mass_reconcile_by_purchase_line.pot b/account_mass_reconcile_by_purchase_line/i18n/account_mass_reconcile_by_purchase_line.pot new file mode 100644 index 00000000..262d3376 --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/i18n/account_mass_reconcile_by_purchase_line.pot @@ -0,0 +1,75 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_mass_reconcile_by_purchase_line +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.ui.view,arch_db:account_mass_reconcile_by_purchase_line.account_mass_reconcile_form +msgid "Advanced. Purchase Order Line" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_create_uid +msgid "Created by" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_create_date +msgid "Created on" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_display_name +msgid "Display Name" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_id +msgid "ID" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line___last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_write_date +msgid "Last Updated on" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.ui.view,arch_db:account_mass_reconcile_by_purchase_line.account_mass_reconcile_form +msgid "Match multiple debit vs multiple credit entries. Allow partial reconciliation. The lines should have the same partner, product and PO lines to be reconciled." +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model,name:account_mass_reconcile_by_purchase_line.model_mass_reconcile_advanced +msgid "mass.reconcile.advanced" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model,name:account_mass_reconcile_by_purchase_line.model_mass_reconcile_advanced_by_purchase_line +msgid "mass.reconcile.advanced.by.purchase.line" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model,name:account_mass_reconcile_by_purchase_line.model_account_mass_reconcile_method +msgid "reconcile method for account_mass_reconcile" +msgstr "" + diff --git a/account_mass_reconcile_by_purchase_line/i18n/ar.po b/account_mass_reconcile_by_purchase_line/i18n/ar.po new file mode 100644 index 00000000..16c8257e --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/i18n/ar.po @@ -0,0 +1,80 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_mass_reconcile_by_purchase_line +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-08-12 00:01+0000\n" +"Last-Translator: Osoul \n" +"Language-Team: none\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" +"X-Generator: Weblate 3.1.1\n" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.ui.view,arch_db:account_mass_reconcile_by_purchase_line.account_mass_reconcile_form +msgid "Advanced. Purchase Order Line" +msgstr "متطور. أوامر الشراء" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_create_uid +msgid "Created by" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_create_date +msgid "Created on" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_display_name +msgid "Display Name" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_id +msgid "ID" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line___last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model.fields,field_description:account_mass_reconcile_by_purchase_line.field_mass_reconcile_advanced_by_purchase_line_write_date +msgid "Last Updated on" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.ui.view,arch_db:account_mass_reconcile_by_purchase_line.account_mass_reconcile_form +msgid "Match multiple debit vs multiple credit entries. Allow partial reconciliation. The lines should have the same partner, product and PO lines to be reconciled." +msgstr "" +"تسوية مجموعة قيود مدينة ودائنة. السماح بالتسوية الجزئية. القيود يجب ان تحتوي " +"على نفس الشريك، والمنتج وبند أمر الشراء." + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model,name:account_mass_reconcile_by_purchase_line.model_mass_reconcile_advanced +msgid "mass.reconcile.advanced" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model,name:account_mass_reconcile_by_purchase_line.model_mass_reconcile_advanced_by_purchase_line +msgid "mass.reconcile.advanced.by.purchase.line" +msgstr "" + +#. module: account_mass_reconcile_by_purchase_line +#: model:ir.model,name:account_mass_reconcile_by_purchase_line.model_account_mass_reconcile_method +msgid "reconcile method for account_mass_reconcile" +msgstr "" diff --git a/account_mass_reconcile_by_purchase_line/models/__init__.py b/account_mass_reconcile_by_purchase_line/models/__init__.py new file mode 100644 index 00000000..fbcdbc24 --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/models/__init__.py @@ -0,0 +1,3 @@ +from . import mass_reconcile +from . import base_advanced_reconciliation +from . import advanced_reconciliation diff --git a/account_mass_reconcile_by_purchase_line/models/advanced_reconciliation.py b/account_mass_reconcile_by_purchase_line/models/advanced_reconciliation.py new file mode 100644 index 00000000..aa3e1e7e --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/models/advanced_reconciliation.py @@ -0,0 +1,31 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class MassReconcileAdvancedByPurchaseLine(models.TransientModel): + _name = "mass.reconcile.advanced.by.purchase.line" + _inherit = "mass.reconcile.advanced" + _description = "Mass Reconcile By Purchase Line" + + @staticmethod + def _skip_line(move_line): + """ + When True is returned on some conditions, the credit move line + will be skipped for reconciliation. Can be inherited to + skip on some conditions. ie: ref or partner_id is empty. + """ + return not (move_line.get("product_id") and move_line.get("purchase_line_id")) + + @staticmethod + def _matchers(move_line): + return ( + ("product_id", move_line["product_id"]), + ("purchase_line_id", move_line["purchase_line_id"]), + ) + + @staticmethod + def _opposite_matchers(move_line): + yield ("product_id", move_line["product_id"]) + yield ("purchase_line_id", move_line["purchase_line_id"]) diff --git a/account_mass_reconcile_by_purchase_line/models/base_advanced_reconciliation.py b/account_mass_reconcile_by_purchase_line/models/base_advanced_reconciliation.py new file mode 100644 index 00000000..9ab7c388 --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/models/base_advanced_reconciliation.py @@ -0,0 +1,14 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class MassReconcileAdvanced(models.AbstractModel): + _inherit = "mass.reconcile.advanced" + + def _selection_columns(self): + aml_cols = super(MassReconcileAdvanced, self)._selection_columns() + aml_cols.append("account_move_line.purchase_line_id") + aml_cols.append("account_move_line.product_id") + return aml_cols diff --git a/account_mass_reconcile_by_purchase_line/models/mass_reconcile.py b/account_mass_reconcile_by_purchase_line/models/mass_reconcile.py new file mode 100644 index 00000000..fbc507c0 --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/models/mass_reconcile.py @@ -0,0 +1,18 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class AccountMassReconcileMethod(models.Model): + _inherit = "account.mass.reconcile.method" + + def _selection_name(self): + methods = super(AccountMassReconcileMethod, self)._selection_name() + methods += [ + ( + "mass.reconcile.advanced.by.purchase.line", + "Advanced. Product, purchase order line.", + ), + ] + return methods diff --git a/account_mass_reconcile_by_purchase_line/readme/CONTRIBUTORS.rst b/account_mass_reconcile_by_purchase_line/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..39ebe28f --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Jordi Ballester Alomar +* Miquel Raïch +* Lois Rilo diff --git a/account_mass_reconcile_by_purchase_line/readme/DESCRIPTION.rst b/account_mass_reconcile_by_purchase_line/readme/DESCRIPTION.rst new file mode 100644 index 00000000..cfceadd4 --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module extends the functionality of account_mass_reconcile and +allow an user to reconcile debits and credits of an Account +using the PO Line and Product as key fields. This type of +reconciliation is to be used in the context of the Perpetual Inventory +accounting system, with the accrual account '*Goods Received Not Invoiced*'. diff --git a/account_mass_reconcile_by_purchase_line/readme/USAGE.rst b/account_mass_reconcile_by_purchase_line/readme/USAGE.rst new file mode 100644 index 00000000..cf838212 --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/readme/USAGE.rst @@ -0,0 +1,6 @@ +To use this module, you need to: + +* Go to 'Invoicing / Accounting / Actions / Mass Automatic Reconcile'. + +* Create a new reconciliation profile, and select a new configuration entry + with type 'Advanced. Product, purchase order line'. diff --git a/account_mass_reconcile_by_purchase_line/static/description/icon.png b/account_mass_reconcile_by_purchase_line/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_mass_reconcile_by_purchase_line/static/description/icon.png differ diff --git a/account_mass_reconcile_by_purchase_line/views/mass_reconcile.xml b/account_mass_reconcile_by_purchase_line/views/mass_reconcile.xml new file mode 100644 index 00000000..6491a8a7 --- /dev/null +++ b/account_mass_reconcile_by_purchase_line/views/mass_reconcile.xml @@ -0,0 +1,25 @@ + + + + account.mass.reconcile.form + 20 + account.mass.reconcile + + + + + + + + + + diff --git a/account_reconcile_model_strict_match_amount/models/account_reconcile_model.py b/account_reconcile_model_strict_match_amount/models/account_reconcile_model.py index 16e1a17d..100790d1 100644 --- a/account_reconcile_model_strict_match_amount/models/account_reconcile_model.py +++ b/account_reconcile_model_strict_match_amount/models/account_reconcile_model.py @@ -45,9 +45,9 @@ class AccountReconcileModel(models.Model): , FALSE) AND CASE - WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100 - WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100 - ELSE 100 + WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100.0 + WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100.0 + ELSE 100.0 END >= {match_total_amount_param} AS communication_flag """.format( match_total_amount_param=self.match_total_amount_param @@ -67,9 +67,9 @@ class AccountReconcileModel(models.Model): , FALSE) AND CASE - WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100 - WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100 - ELSE 100 + WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100.0 + WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100.0 + ELSE 100.0 END >= {match_total_amount_param} AS payment_reference_flag """.format( match_total_amount_param=self.match_total_amount_param diff --git a/account_reconcile_model_strict_match_amount/tests/test_account_reconcile_model_strict_match_amount.py b/account_reconcile_model_strict_match_amount/tests/test_account_reconcile_model_strict_match_amount.py index c9582be6..785cbc26 100644 --- a/account_reconcile_model_strict_match_amount/tests/test_account_reconcile_model_strict_match_amount.py +++ b/account_reconcile_model_strict_match_amount/tests/test_account_reconcile_model_strict_match_amount.py @@ -14,9 +14,9 @@ class TestAccountReconcileModelStrictMatchAmount(TestReconciliationMatchingRules cls.partner_5 = cls.env["res.partner"].create({"name": "partner_5"}) cls.partner_6 = cls.env["res.partner"].create({"name": "partner_6"}) cls.invoice_line_5 = cls._create_invoice_line(150, cls.partner_3, "out_invoice") - cls.invoice_line_5.ref = "ABC001XYZ" + cls.invoice_line_5.name = "ABC001XYZ" cls.invoice_line_6 = cls._create_invoice_line(300, cls.partner_4, "out_invoice") - cls.invoice_line_6.name = "ABC002XYZ" + cls.invoice_line_6.move_id.name = "ABC002XYZ" cls.invoice_line_7 = cls._create_invoice_line(450, cls.partner_5, "out_invoice") cls.invoice_line_7.move_id.ref = "ABC003XYZ" cls.invoice_line_8 = cls._create_invoice_line(600, cls.partner_6, "out_invoice") diff --git a/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py b/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py index 6f1e61f1..54fd2957 100644 --- a/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py +++ b/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py @@ -53,12 +53,13 @@ class TestReconciliation(SavepointCase): "journal_id": cls.bank_journal.id, "line_ids": [(0, 0, debit_line_vals), (0, 0, credit_line_vals)], } - return ( + move = ( cls.env["account.move"] .with_context(default_journal_id=cls.bank_journal.id) .create(vals) - .id ) + move.post() + return move.id @classmethod def init_moves(cls): @@ -95,7 +96,7 @@ class TestReconciliation(SavepointCase): self.aml[0].partner_id = self.partner.id with self.assertRaises(UserError): self.aml.reconcile() - # reconciliation forbiden only for certain types of accounts + # reconciliation forbidden only for certain types of accounts account = self.env["account.account"].create( { "code": "CAA1000", diff --git a/setup/account_mass_reconcile_by_purchase_line/odoo/addons/account_mass_reconcile_by_purchase_line b/setup/account_mass_reconcile_by_purchase_line/odoo/addons/account_mass_reconcile_by_purchase_line new file mode 120000 index 00000000..6d19d44f --- /dev/null +++ b/setup/account_mass_reconcile_by_purchase_line/odoo/addons/account_mass_reconcile_by_purchase_line @@ -0,0 +1 @@ +../../../../account_mass_reconcile_by_purchase_line \ No newline at end of file diff --git a/setup/account_mass_reconcile_by_purchase_line/setup.py b/setup/account_mass_reconcile_by_purchase_line/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_mass_reconcile_by_purchase_line/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)