diff --git a/setup/stock_account_no_auto_reconcile/odoo/addons/stock_account_no_auto_reconcile b/setup/stock_account_no_auto_reconcile/odoo/addons/stock_account_no_auto_reconcile new file mode 120000 index 000000000..a2c17765e --- /dev/null +++ b/setup/stock_account_no_auto_reconcile/odoo/addons/stock_account_no_auto_reconcile @@ -0,0 +1 @@ +../../../../stock_account_no_auto_reconcile \ No newline at end of file diff --git a/setup/stock_account_no_auto_reconcile/setup.py b/setup/stock_account_no_auto_reconcile/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_account_no_auto_reconcile/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_no_auto_reconcile/README.rst b/stock_account_no_auto_reconcile/README.rst new file mode 100644 index 000000000..63854ec54 --- /dev/null +++ b/stock_account_no_auto_reconcile/README.rst @@ -0,0 +1,94 @@ +=============================== +Stock Account No Auto Reconcile +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/15.0/stock_account_no_auto_reconcile + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-stock_account_no_auto_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/92/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Prevent automatically reconciliation when invoicing a stock move or when validating +a stock move. +When receiving in multiple incoming shipments and invoicing periodically, +it is not desirable to reconcile until the order (SO/PO) is closed, otherwise you can get +an error when receiving or delivering another pickng, because of the partial reconcile +https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_move.py#L4463 + +You can use additional modules, like purchase_unreconciled and sale_unreconciled in +order to perform the reconciliation when the order is fully done. + +Technically, this does not depend on purchase and sale, but the symptoms only appear +when the invoce is linked to a PO SO. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +If you want to disable the standard feature of autoreconciling journal items for +interim accounts uncheck the flag "Reconcile Interim Accounts on the fly" in the +accounting settings. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow +* + +Contributors +~~~~~~~~~~~~ + +* ForgeFlow S.L. + + - Aaron Henriquez + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_account_no_auto_reconcile/__init__.py b/stock_account_no_auto_reconcile/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_account_no_auto_reconcile/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_account_no_auto_reconcile/__manifest__.py b/stock_account_no_auto_reconcile/__manifest__.py new file mode 100644 index 000000000..f7f0c612a --- /dev/null +++ b/stock_account_no_auto_reconcile/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Stock Account No Auto Reconcile", + "summary": "Do not try to reconcile stock interim related JE", + "version": "15.0.1.0.0", + "category": "Accounting", + "author": "Odoo Community Association (OCA), ForgeFlow, ", + "license": "AGPL-3", + "website": "https://github.com/OCA/account-financial-tools", + "depends": ["purchase_stock", "sale_stock"], + "data": ["views/res_config_settings_views.xml"], +} diff --git a/stock_account_no_auto_reconcile/models/__init__.py b/stock_account_no_auto_reconcile/models/__init__.py new file mode 100644 index 000000000..53a235a0b --- /dev/null +++ b/stock_account_no_auto_reconcile/models/__init__.py @@ -0,0 +1,3 @@ +from . import account_move +from . import res_config_settings +from . import company diff --git a/stock_account_no_auto_reconcile/models/account_move.py b/stock_account_no_auto_reconcile/models/account_move.py new file mode 100644 index 000000000..a9f325760 --- /dev/null +++ b/stock_account_no_auto_reconcile/models/account_move.py @@ -0,0 +1,17 @@ +# Copyright 2022 ForgeFlow S.L. (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _stock_account_anglo_saxon_reconcile_valuation(self, product=False): + """Warning! Overpassing an standard method, avoiding reconciling interim + account JE. Pass the context to overpass + """ + if self.company_id.anglo_saxon_auto_reconcile: + return super( + AccountMove, self + )._stock_account_anglo_saxon_reconcile_valuation() diff --git a/stock_account_no_auto_reconcile/models/company.py b/stock_account_no_auto_reconcile/models/company.py new file mode 100644 index 000000000..fe411989e --- /dev/null +++ b/stock_account_no_auto_reconcile/models/company.py @@ -0,0 +1,10 @@ +# Copyright 2022 ForgeFlow S.L. (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + anglo_saxon_auto_reconcile = fields.Boolean(default=True) diff --git a/stock_account_no_auto_reconcile/models/res_config_settings.py b/stock_account_no_auto_reconcile/models/res_config_settings.py new file mode 100644 index 000000000..6320cade1 --- /dev/null +++ b/stock_account_no_auto_reconcile/models/res_config_settings.py @@ -0,0 +1,17 @@ +# Copyright 2022 ForgeFlow S.L. (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + anglo_saxon_auto_reconcile = fields.Boolean( + related="company_id.anglo_saxon_auto_reconcile", + readonly=False, + string="Reconcile Interim Accounts on the fly", + help=( + "Reconcile interim journal items when validating pickings or posting invoices" + ), + ) diff --git a/stock_account_no_auto_reconcile/readme/CONTRIBUTORS.rst b/stock_account_no_auto_reconcile/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..63a686066 --- /dev/null +++ b/stock_account_no_auto_reconcile/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* ForgeFlow S.L. + + - Aaron Henriquez diff --git a/stock_account_no_auto_reconcile/readme/DESCRIPTION.rst b/stock_account_no_auto_reconcile/readme/DESCRIPTION.rst new file mode 100644 index 000000000..cf8773a0e --- /dev/null +++ b/stock_account_no_auto_reconcile/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +Prevent automatically reconciliation when invoicing a stock move or when validating +a stock move. +When receiving in multiple incoming shipments and invoicing periodically, +it is not desirable to reconcile until the order (SO/PO) is closed, otherwise you can get +an error when receiving or delivering another pickng, because of the partial reconcile +https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_move.py#L4463 + +You can use additional modules, like purchase_unreconciled and sale_unreconciled in +order to perform the reconciliation when the order is fully done. + +Technically, this does not depend on purchase and sale, but the symptoms only appear +when the invoce is linked to a PO SO. diff --git a/stock_account_no_auto_reconcile/readme/USAGE.rst b/stock_account_no_auto_reconcile/readme/USAGE.rst new file mode 100644 index 000000000..07d7bb16a --- /dev/null +++ b/stock_account_no_auto_reconcile/readme/USAGE.rst @@ -0,0 +1,3 @@ +If you want to disable the standard feature of autoreconciling journal items for +interim accounts uncheck the flag "Reconcile Interim Accounts on the fly" in the +accounting settings. diff --git a/stock_account_no_auto_reconcile/static/description/index.html b/stock_account_no_auto_reconcile/static/description/index.html new file mode 100644 index 000000000..937c853fc --- /dev/null +++ b/stock_account_no_auto_reconcile/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +Stock Account No Auto Reconcile + + + +
+

Stock Account No Auto Reconcile

+ + +

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

+

Prevent automatically reconciliation when invoicing a stock move or when validating +a stock move. +When receiving in multiple incoming shipments and invoicing periodically, +it is not desirable to reconcile until the order (SO/PO) is closed, otherwise you can get +an error when receiving or delivering another pickng, because of the partial reconcile +https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_move.py#L4463

+

You can use additional modules, like purchase_unreconciled and sale_unreconciled in +order to perform the reconciliation when the order is fully done.

+

Technically, this does not depend on purchase and sale, but the symptoms only appear +when the invoce is linked to a PO SO.

+

Table of contents

+ +
+

Usage

+

If you want to disable the standard feature of autoreconciling journal items for +interim accounts uncheck the flag “Reconcile Interim Accounts on the fly” in the +accounting settings.

+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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-financial-tools project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_account_no_auto_reconcile/tests/__init__.py b/stock_account_no_auto_reconcile/tests/__init__.py new file mode 100644 index 000000000..34e858fef --- /dev/null +++ b/stock_account_no_auto_reconcile/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_no_auto_reconcile diff --git a/stock_account_no_auto_reconcile/tests/test_account_no_auto_reconcile.py b/stock_account_no_auto_reconcile/tests/test_account_no_auto_reconcile.py new file mode 100644 index 000000000..b17340fed --- /dev/null +++ b/stock_account_no_auto_reconcile/tests/test_account_no_auto_reconcile.py @@ -0,0 +1,139 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from datetime import datetime + +from odoo import fields +from odoo.tests import common, tagged + + +@tagged("-at_install", "post_install") +class StockAccountNoAutoReconcile(common.SingleTransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_obj = cls.env["product.product"] + cls.category_obj = cls.env["product.category"] + cls.partner_obj = cls.env["res.partner"] + cls.po_obj = cls.env["purchase.order"] + cls.acc_obj = cls.env["account.account"] + cls.categ_unit = cls.env.ref("uom.product_uom_categ_unit") + assets = cls.env.ref("account.data_account_type_current_assets") + expenses = cls.env.ref("account.data_account_type_expenses") + equity = cls.env.ref("account.data_account_type_equity") + cls.company = cls.env.ref("base.main_company") + + # Create partner: + cls.partner = cls.partner_obj.create({"name": "Test Vendor"}) + # Create standard product: + cls.product = cls.product_obj.create( + {"name": "saled Product", "type": "product"} + ) + # Create product that uses a reconcilable stock input account. + cls.stock_journal = cls.env["account.journal"].create( + {"name": "Stock Journal", "code": "STJTEST", "type": "general"} + ) + cls.sale_journal = cls.env["account.journal"].create( + {"name": "Sales Journal", "code": "SLTEST", "type": "sale"} + ) + # Create account for Goods Received Not Invoiced + name = "Goods Received Not Invoiced" + code = "grni" + acc_type = equity + cls.account_grni = cls._create_account( + acc_type, name, code, cls.company, reconcile=True + ) + # Create account for Cost of Goods Sold + name = "Cost of Goods Sold" + code = "cogs" + acc_type = expenses + cls.account_cogs = cls._create_account(acc_type, name, code, cls.company) + # Create account for Goods Delivered Not Invoiced + name = "Goods Delivered Not Invoiced" + code = "gdni" + acc_type = expenses + cls.account_gdni = cls._create_account( + acc_type, name, code, cls.company, reconcile=True + ) + # Create account for Inventory + name = "Inventory" + code = "inventory" + acc_type = assets + cls.account_inventory = cls._create_account(acc_type, name, code, cls.company) + cls.product_categ = cls.category_obj.create( + { + "name": "Test Category", + "property_cost_method": "standard", + "property_stock_valuation_account_id": cls.account_inventory.id, + "property_stock_account_input_categ_id": cls.account_grni.id, + "property_account_expense_categ_id": cls.account_cogs.id, + "property_stock_account_output_categ_id": cls.account_gdni.id, + "property_valuation": "real_time", + "property_stock_journal": cls.stock_journal.id, + } + ) + cls.product_to_reconcile = cls.product_obj.create( + { + "name": "Purchased Product (To reconcile)", + "type": "product", + "standard_price": 100.0, + "categ_id": cls.product_categ.id, + } + ) + + @classmethod + def _create_account(cls, acc_type, name, code, company, reconcile=False): + """Create an account.""" + account = cls.acc_obj.create( + { + "name": name, + "code": code, + "user_type_id": acc_type.id, + "company_id": company.id, + "reconcile": reconcile, + } + ) + return account + + def _do_picking(self, picking, date): + """Do picking with only one move on the given date.""" + picking.action_confirm() + picking.move_lines.quantity_done = picking.move_lines.product_uom_qty + picking._action_done() + for move in picking.move_lines: + move.date = date + + def test_01_no_reconcile_interim(self): + """Tests the case into which we receive the goods first, and then make the invoice.""" + self.company.anglo_saxon_auto_reconcile = False + po = self.po_obj.create( + { + "partner_id": self.partner.id, + "order_line": [ + ( + 0, + 0, + { + "product_id": self.product_to_reconcile.id, + "name": self.product_to_reconcile.name, + "product_qty": 5.0, + "price_unit": 100.0, + "product_uom": self.product_to_reconcile.uom_id.id, + "date_planned": fields.Datetime.now(), + }, + ) + ], + } + ) + po.button_confirm() + self._do_picking(po.picking_ids, fields.Datetime.now()) + # Invoice created and validated: + po.action_create_invoice() + invoice_ids = po.invoice_ids.filtered(lambda i: i.move_type == "in_invoice") + invoice_ids.invoice_date = datetime.now() + invoice_ids.action_post() + # should not be reconciled + stock_moves = po.picking_ids.move_lines + interim_account_id = self.account_grni.id + valuation_line = stock_moves.mapped("account_move_ids.line_ids").filtered( + lambda x: x.account_id.id == interim_account_id + ) + self.assertFalse(valuation_line.reconciled) diff --git a/stock_account_no_auto_reconcile/views/res_config_settings_views.xml b/stock_account_no_auto_reconcile/views/res_config_settings_views.xml new file mode 100644 index 000000000..d9fcf4ebf --- /dev/null +++ b/stock_account_no_auto_reconcile/views/res_config_settings_views.xml @@ -0,0 +1,31 @@ + + + + res.config.settings + + +
+

Reconcile Interim Accounts on the fly

+
+
+
+ +
+
+
+
+
+
+
+
+