mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] purchase_unreconciled: migration to version 16.0
This commit is contained in:
committed by
JasminSForgeFlow
parent
ac27f09732
commit
5dd45fa35b
@@ -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 <https://github.com/OCA/account-financial-tools/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 <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20purchase_unreconciled%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20purchase_unreconciled%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@@ -104,6 +104,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-AaronHForgeFlow|
|
||||
|
||||
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/15.0/purchase_unreconciled>`_ project on GitHub.
|
||||
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/purchase_unreconciled>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
@@ -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
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/15.0/purchase_unreconciled"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-purchase_unreconciled"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/16.0/purchase_unreconciled"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-purchase_unreconciled"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module adds a new fields “Unreconciled” on Purchase Orders, that allows
|
||||
to find PO’s with unreconciled journal items related.</p>
|
||||
<p>This module allows to reconcile those PO in a single click. In accounting
|
||||
@@ -406,7 +406,7 @@ stock iterim accounts.</p>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20purchase_unreconciled%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20purchase_unreconciled%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -431,13 +431,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
</a>
|
||||
<p>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.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<p><a class="reference external image-reference" href="https://github.com/AaronHForgeFlow"><img alt="AaronHForgeFlow" src="https://github.com/AaronHForgeFlow.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/15.0/purchase_unreconciled">OCA/account-financial-tools</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/16.0/purchase_unreconciled">OCA/account-financial-tools</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user