From 5dd45fa35bfad8e7566055aa864e509da25c771d Mon Sep 17 00:00:00 2001 From: AaronHForgeFlow Date: Mon, 16 Sep 2024 15:47:36 +0200 Subject: [PATCH] [MIG] purchase_unreconciled: migration to version 16.0 --- purchase_unreconciled/README.rst | 10 ++-- purchase_unreconciled/__manifest__.py | 2 +- .../models/purchase_order.py | 25 ++++----- .../static/description/index.html | 18 +++--- .../tests/test_purchase_unreconciled.py | 56 ++++++++++--------- 5 files changed, 55 insertions(+), 56 deletions(-) diff --git a/purchase_unreconciled/README.rst b/purchase_unreconciled/README.rst index b78b2c2b1..f516d433b 100644 --- a/purchase_unreconciled/README.rst +++ b/purchase_unreconciled/README.rst @@ -17,13 +17,13 @@ Purchase Unreconciled :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/purchase_unreconciled + :target: https://github.com/OCA/account-financial-tools/tree/16.0/purchase_unreconciled :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-purchase_unreconciled + :target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-purchase_unreconciled :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -60,7 +60,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 to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -104,6 +104,6 @@ Current `maintainer `__: |maintainer-AaronHForgeFlow| -This module is part of the `OCA/account-financial-tools `_ project on GitHub. +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/purchase_unreconciled/__manifest__.py b/purchase_unreconciled/__manifest__.py index ec61390c2..9d4e84a21 100644 --- a/purchase_unreconciled/__manifest__.py +++ b/purchase_unreconciled/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Purchase Unreconciled", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "author": "ForgeFlow S.L., Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-financial-tools", "category": "Purchases", diff --git a/purchase_unreconciled/models/purchase_order.py b/purchase_unreconciled/models/purchase_order.py index 7d0a85dca..4f566500f 100644 --- a/purchase_unreconciled/models/purchase_order.py +++ b/purchase_unreconciled/models/purchase_order.py @@ -20,7 +20,6 @@ class PurchaseOrder(models.Model): amount_unreconciled = fields.Float(compute="_compute_unreconciled") def _get_account_domain(self): - self.ensure_one() included_accounts = ( ( self.env["product.category"] @@ -36,11 +35,10 @@ class PurchaseOrder(models.Model): def _get_purchase_unreconciled_base_domain(self): unreconciled_domain = [ ("account_id.reconcile", "=", True), - ("account_id.internal_type", "not in", ["receivable", "payable"]), ("move_id.state", "=", "posted"), ("company_id", "in", self.env.companies.ids), # same condition than Odoo Unreconciled filter - ("full_reconcile_id", "=", False), + ("amount_residual", "!=", 0.0), ("balance", "!=", 0.0), ] return unreconciled_domain @@ -65,18 +63,15 @@ class PurchaseOrder(models.Model): raise ValueError(_("Unsupported search operator")) acc_item = self.env["account.move.line"] domain = self._get_purchase_unreconciled_base_domain() - unreconciled_domain = expression.AND( - [domain, [("purchase_order_id", "!=", False)]] - ) - unreconciled_domain = expression.AND( - [unreconciled_domain, [("company_id", "in", self.env.companies.ids)]] - ) - unreconciled_items = acc_item.search(unreconciled_domain) - unreconciled_pos = unreconciled_items.mapped("purchase_order_id") + domain = expression.AND([domain, [("purchase_order_id", "!=", False)]]) + domain_account = self._get_account_domain() + domain = expression.AND([domain_account, domain]) + acc_items = acc_item.search(domain) + unreconciled_pos_ids = acc_items.mapped("purchase_order_id").ids if value: - return [("id", "in", unreconciled_pos.ids)] + return [("id", "in", unreconciled_pos_ids)] else: - return [("id", "not in", unreconciled_pos.ids)] + return [("id", "not in", unreconciled_pos_ids)] def action_view_unreconciled(self): self.ensure_one() @@ -89,7 +84,7 @@ class PurchaseOrder(models.Model): unreconciled_domain = expression.AND( [unreconciled_domain, [("purchase_order_id", "=", self.id)]] ) - unreconciled_domain.remove(("full_reconcile_id", "=", False)) + unreconciled_domain.remove(("amount_residual", "!=", 0.0)) unreconciled_domain.remove("&") unreconciled_items = acc_item.search(unreconciled_domain) action = self.env.ref("account.action_account_moves_all") @@ -104,7 +99,7 @@ class PurchaseOrder(models.Model): ): raise exceptions.ValidationError( _( - "The write-off account and jounral for purchases is missing. An " + "The write-off account and journal for purchases is missing. An " "accountant must fill that information" ) ) diff --git a/purchase_unreconciled/static/description/index.html b/purchase_unreconciled/static/description/index.html index 2499658cb..773c033b5 100644 --- a/purchase_unreconciled/static/description/index.html +++ b/purchase_unreconciled/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.option { span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,7 +369,7 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:8134013d5d37fe8931266d6f916bbc160f48212ac4a9faa43b4efe39d03e6b4c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Alpha License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

+

Alpha License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

This module adds a new fields “Unreconciled” on Purchase Orders, that allows to find PO’s with unreconciled journal items related.

This module allows to reconcile those PO in a single click. In accounting @@ -406,7 +406,7 @@ stock iterim accounts.

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 to smash it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -431,13 +431,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +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.

Current maintainer:

AaronHForgeFlow

-

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

+

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/purchase_unreconciled/tests/test_purchase_unreconciled.py b/purchase_unreconciled/tests/test_purchase_unreconciled.py index 41842a901..54ce36dcc 100644 --- a/purchase_unreconciled/tests/test_purchase_unreconciled.py +++ b/purchase_unreconciled/tests/test_purchase_unreconciled.py @@ -17,12 +17,12 @@ class TestPurchaseUnreconciled(SingleTransactionCase): cls.category_obj = cls.env["product.category"] cls.partner_obj = cls.env["res.partner"] cls.acc_obj = cls.env["account.account"] - cls.invoice_obj = cls.env["account.move"] + cls.account_move_obj = cls.env["account.move"] cls.company = cls.env.ref("base.main_company") cls.company.anglo_saxon_accounting = True - 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") + expense_type = "expense" + equity_type = "equity" + asset_type = "asset_current" # Create partner: cls.partner = cls.partner_obj.create({"name": "Test Vendor"}) # Create product that uses a reconcilable stock input account. @@ -30,7 +30,7 @@ class TestPurchaseUnreconciled(SingleTransactionCase): { "name": "Test stock input account", "code": 9999, - "user_type_id": assets.id, + "account_type": asset_type, "reconcile": True, "company_id": cls.company.id, } @@ -39,7 +39,7 @@ class TestPurchaseUnreconciled(SingleTransactionCase): { "name": "Write-offf account", "code": 8888, - "user_type_id": expenses.id, + "account_type": expense_type, "reconcile": True, "company_id": cls.company.id, } @@ -50,26 +50,26 @@ class TestPurchaseUnreconciled(SingleTransactionCase): # Create account for Goods Received Not Invoiced name = "Goods Received Not Invoiced" code = "grni" - acc_type = equity + acc_type = equity_type 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 + acc_type = expense_type 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 + acc_type = expense_type 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 + acc_type = asset_type cls.account_inventory = cls._create_account(acc_type, name, code, cls.company) cls.product_categ = cls.category_obj.create( { @@ -150,7 +150,7 @@ class TestPurchaseUnreconciled(SingleTransactionCase): { "name": name, "code": code, - "user_type_id": acc_type.id, + "account_type": acc_type, "company_id": company.id, "reconcile": reconcile, } @@ -169,7 +169,7 @@ class TestPurchaseUnreconciled(SingleTransactionCase): "picking_type_id": self.env.ref("stock.picking_type_out").id, "location_id": self.env.ref("stock.stock_location_stock").id, "location_dest_id": self.env.ref("stock.stock_location_customers").id, - "move_lines": [ + "move_ids": [ ( 0, 0, @@ -194,11 +194,10 @@ class TestPurchaseUnreconciled(SingleTransactionCase): def _do_picking(self, picking, date): """Do picking with only one move on the given date.""" picking.action_confirm() - for ml in picking.move_lines: - ml.quantity_done = ml.product_uom_qty - picking._action_done() - for move in picking.move_lines: + for move in picking.move_ids: + move.quantity_done = move.product_uom_qty move.date = date + picking._action_done() def test_01_nothing_to_reconcile(self): po = self.po @@ -327,15 +326,16 @@ class TestPurchaseUnreconciled(SingleTransactionCase): po.button_confirm() self._do_picking(po.picking_ids, fields.Datetime.now()) # Invoice created and validated: - move_form = Form(self.invoice_obj.with_context(default_type="in_invoice")) - move_form.partner_id = self.partner - move_form.purchase_id = po - invoice = move_form.save() + f = Form(self.account_move_obj.with_context(default_move_type="in_invoice")) + f.partner_id = po.partner_id + f.invoice_date = fields.Date().today() + f.purchase_vendor_bill_id = self.env["purchase.bill.union"].browse(-po.id) + invoice = f.save() chicago_journal = self.env["account.journal"].create( { "name": "chicago", "code": "ref", - "type": "sale", + "type": "purchase", "company_id": self.ref("stock.res_company_1"), } ) @@ -389,15 +389,17 @@ class TestPurchaseUnreconciled(SingleTransactionCase): po.button_confirm() self._do_picking(po.picking_ids, fields.Datetime.now()) # Invoice created and validated: - move_form = Form(self.invoice_obj.with_context(default_type="in_invoice")) - move_form.partner_id = self.partner - move_form.purchase_id = po + f = Form(self.account_move_obj.with_context(default_move_type="in_invoice")) + f.partner_id = po.partner_id + f.invoice_date = fields.Date().today() + f.purchase_vendor_bill_id = self.env["purchase.bill.union"].browse(-po.id) + invoice = f.save() # force discrepancies - with move_form.invoice_line_ids.edit(0) as line_form: + with f.invoice_line_ids.edit(0) as line_form: line_form.price_unit = 99 - with move_form.invoice_line_ids.edit(0) as line_form: + with f.invoice_line_ids.edit(0) as line_form: line_form.price_unit = 99 - invoice = move_form.save() + invoice = f.save() invoice._post() # The bill is different price so this is unreconciled po._compute_unreconciled()