Skip to content

Commit

Permalink
[MIG] sale_unreconciled: Migration to v16
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed Sep 17, 2024
1 parent b4d8e5d commit a246efa
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 57 deletions.
10 changes: 5 additions & 5 deletions sale_unreconciled/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Sale 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/sale_unreconciled
:target: https://github.com/OCA/account-financial-tools/tree/16.0/sale_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-sale_unreconciled
:target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-sale_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|
Expand Down Expand Up @@ -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:%20sale_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:%20sale_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.

Expand Down Expand Up @@ -100,6 +100,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/sale_unreconciled>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/sale_unreconciled>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion sale_unreconciled/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Sale 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": "Accounting",
Expand Down
21 changes: 11 additions & 10 deletions sale_unreconciled/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class SaleOrder(models.Model):
)

def _get_account_domain(self):
self.ensure_one()
included_accounts = (
(
self.env["product.category"]
Expand All @@ -39,10 +38,10 @@ def _get_account_domain(self):
def _get_sale_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
Expand All @@ -65,15 +64,17 @@ def _compute_unreconciled(self):
def _search_unreconciled(self, operator, value):
if operator not in ("=", "!=") or not isinstance(value, bool):
raise ValueError(_("Unsupported search operator"))
acc_item = self.env["account.move.line"]
domain = self._get_sale_unreconciled_base_domain()
unreconciled_domain = expression.AND([domain, [("sale_order_id", "!=", False)]])
unreconciled_items = acc_item.search(unreconciled_domain)
unreconciled_sos = unreconciled_items.mapped("sale_order_id")
domain = expression.AND([domain, [("sale_order_id", "!=", False)]])
domain_account = self._get_account_domain()
domain = expression.AND([domain_account, domain])
acc_item = self.env["account.move.line"]
unreconciled_items = acc_item.search(domain)
unreconciled_sos_ids = unreconciled_items.mapped("sale_order_id").ids

Check warning on line 73 in sale_unreconciled/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_unreconciled/models/sale_order.py#L66-L73

Added lines #L66 - L73 were not covered by tests
if value:
return [("id", "in", unreconciled_sos.ids)]
return [("id", "in", unreconciled_sos_ids)]

Check warning on line 75 in sale_unreconciled/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_unreconciled/models/sale_order.py#L75

Added line #L75 was not covered by tests
else:
return [("id", "not in", unreconciled_sos.ids)]
return [("id", "not in", unreconciled_sos_ids)]

Check warning on line 77 in sale_unreconciled/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_unreconciled/models/sale_order.py#L77

Added line #L77 was not covered by tests

def action_view_unreconciled(self):
self.ensure_one()
Expand All @@ -86,7 +87,7 @@ def action_view_unreconciled(self):
unreconciled_domain = expression.AND(

Check warning on line 87 in sale_unreconciled/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_unreconciled/models/sale_order.py#L85-L87

Added lines #L85 - L87 were not covered by tests
[unreconciled_domain, [("sale_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")
Expand Down
18 changes: 10 additions & 8 deletions sale_unreconciled/static/description/index.html
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
: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.
Expand Down Expand Up @@ -275,7 +275,7 @@
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 }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Sale Unreconciled</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0660eae9dc9154a47a87338820960db556d160b50027b7052b0e2e2886afa142
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/sale_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-sale_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&amp;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/sale_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-sale_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&amp;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 field “Unreconciled” on Sales Orders, that allows
to find SO’s with unreconciled journal items related.</p>
<p>This module allows to reconcile those SO in a single click. In accounting
Expand Down Expand Up @@ -406,7 +406,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<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:%20sale_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:%20sale_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">
Expand All @@ -429,13 +429,15 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<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/sale_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/sale_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>
Expand Down
61 changes: 28 additions & 33 deletions sale_unreconciled/tests/test_sale_unreconciled.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def setUpClass(cls):
cls.partner_obj = cls.env["res.partner"]
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")
revenue = cls.env.ref("account.data_account_type_other_income")
expense_type = "expense"
equity_type = "equity"
asset_type = "asset_current"
revenue = "income"
cls.company = cls.env.ref("base.main_company")

# Create partner:
Expand All @@ -38,32 +38,31 @@ def setUpClass(cls):
# 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
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.writeoff_acc = cls.acc_obj.create(
{
"name": "Write-offf account",
"code": 8888,
"user_type_id": expenses.id,
"account_type": acc_type,
"reconcile": True,
}
)
Expand Down Expand Up @@ -100,7 +99,7 @@ def setUpClass(cls):
{
"name": "Test revenue account 2",
"code": 1017,
"user_type_id": revenue.id,
"account_type": revenue,
"reconcile": False,
"company_id": cls.company.id,
}
Expand All @@ -109,7 +108,7 @@ def setUpClass(cls):
{
"name": "Dummy acccount",
"code": 7991,
"user_type_id": expenses.id,
"account_type": expense_type,
"reconcile": False,
"company_id": cls.company.id,
}
Expand All @@ -126,7 +125,7 @@ def _create_account(cls, acc_type, name, code, company, reconcile=False):
{
"name": name,
"code": code,
"user_type_id": acc_type.id,
"account_type": acc_type,
"company_id": company.id,
"reconcile": reconcile,
}
Expand All @@ -145,7 +144,7 @@ def _create_incoming(
"picking_type_id": self.env.ref("stock.picking_type_in").id,
"location_dest_id": self.env.ref("stock.stock_location_stock").id,
"location_id": self.env.ref("stock.stock_location_suppliers").id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand Down Expand Up @@ -187,9 +186,9 @@ def _create_sale(self, line_products):
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
ml.date = date
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):
Expand Down Expand Up @@ -251,45 +250,41 @@ def test_04_sale_mrp_anglo_saxon(self):
"property_cost_method": "fifo",
}
)
account_type = self.env["account.account.type"].create(
{"name": "RCV type", "type": "other", "internal_group": "asset"}
)
self.account_receiv = self.env["account.account"].create(
account_expense = self.env["account.account"].create(
{
"name": "Receivable",
"code": "RCV00",
"user_type_id": account_type.id,
"name": "Expense",
"code": "EXP00",
"account_type": "expense",
"reconcile": True,
}
)
account_expense = self.env["account.account"].create(
account_input = self.env["account.account"].create(
{
"name": "Expense",
"code": "EXP00",
"user_type_id": account_type.id,
"name": "Input",
"code": "IN001",
"account_type": "liability_current",
"reconcile": True,
}
)
account_output = self.env["account.account"].create(
{
"name": "Output",
"code": "OUT00",
"user_type_id": account_type.id,
"account_type": "asset_current",
"reconcile": True,
}
)
account_valuation = self.env["account.account"].create(
{
"name": "Valuation",
"code": "STV00",
"user_type_id": account_type.id,
"account_type": "asset_current",
"reconcile": True,
}
)
self.partner.property_account_receivable_id = self.account_receiv
self.category.property_account_income_categ_id = self.account_receiv
self.category.property_account_income_categ_id = self.account_revenue2
self.category.property_account_expense_categ_id = account_expense
self.category.property_stock_account_input_categ_id = self.account_receiv
self.category.property_stock_account_input_categ_id = account_input
self.category.property_stock_account_output_categ_id = account_output
self.category.property_stock_valuation_account_id = account_valuation
self.category.property_stock_journal = self.env["account.journal"].create(
Expand Down Expand Up @@ -391,7 +386,7 @@ def test_04_sale_mrp_anglo_saxon(self):
pick = self.so.picking_ids
# To check the products on the picking
self.assertEqual(
pick.move_lines.mapped("product_id"), self.component1 | self.component2
pick.move_line_ids.mapped("product_id"), self.component1 | self.component2
)
self._do_picking(
pick.filtered(lambda p: p.state != "done"), fields.Datetime.now()
Expand Down

0 comments on commit a246efa

Please sign in to comment.