[MIG] account_netting: Migration to v13.0

This commit is contained in:
Sergio Teruel
2020-03-19 09:13:16 +01:00
committed by Alexis de Lattre
parent b6448b49e7
commit 563c36e158
6 changed files with 48 additions and 47 deletions

View File

@@ -14,13 +14,13 @@ Account netting
: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/12.0/account_netting
:target: https://github.com/OCA/account-financial-tools/tree/13.0/account_netting
: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-12-0/account-financial-tools-12-0-account_netting
:target: https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_netting
: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/12.0
:target: https://runbot.odoo-community.org/runbot/92/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -61,7 +61,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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_netting%0Aversion:%2012.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:%20account_netting%0Aversion:%2013.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.
@@ -92,6 +92,6 @@ 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 <https://github.com/OCA/account-financial-tools/tree/12.0/account_netting>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/13.0/account_netting>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,13 +4,13 @@
{
"name": "Account netting",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"summary": "Compensate AR/AP accounts from the same partner",
"category": "Accounting & Finance",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/account-financial-tools/",
"depends": ["account",],
"data": ["wizards/account_move_make_netting_view.xml",],
"depends": ["account"],
"data": ["wizards/account_move_make_netting_view.xml"],
"installable": True,
}

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/account-financial-tools/tree/12.0/account_netting"><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" href="https://translation.odoo-community.org/projects/account-financial-tools-12-0/account-financial-tools-12-0-account_netting"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/account-financial-tools/tree/13.0/account_netting"><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" href="https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_netting"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to compensate the balance of a receivable account with the
balance of a payable account for the same partner, creating a journal item
that reflects this operation.</p>
@@ -407,7 +407,7 @@ counterparts of the AR/AP operations.</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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_netting%0Aversion:%2012.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:%20account_netting%0Aversion:%2013.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">
@@ -432,7 +432,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/12.0/account_netting">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/13.0/account_netting">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>

View File

@@ -9,16 +9,10 @@ class TestAccountNetting(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestAccountNetting, cls).setUpClass()
cls.partner = cls.env["res.partner"].create(
{"supplier": True, "customer": True, "name": "Supplier/Customer",}
)
cls.partner1 = cls.env["res.partner"].create(
{"supplier": True, "customer": True, "name": "Supplier/Customer 1",}
)
res_users_account_manager = cls.env.ref("account.group_account_manager")
partner_manager = cls.env.ref("base.group_partner_manager")
cls.env.user.write(
{"groups_id": [(6, 0, [res_users_account_manager.id, partner_manager.id])],}
{"groups_id": [(6, 0, [res_users_account_manager.id, partner_manager.id])]}
)
# only adviser can create an account
cls.account_receivable = cls.env["account.account"].create(
@@ -57,21 +51,34 @@ class TestAccountNetting(common.SavepointCase):
],
limit=1,
)
cls.partner = cls.env["res.partner"].create(
{
"name": "Supplier/Customer",
"property_account_receivable_id": cls.account_receivable.id,
"property_account_payable_id": cls.account_payable.id,
}
)
cls.partner1 = cls.env["res.partner"].create(
{
"name": "Supplier/Customer 1",
"property_account_receivable_id": cls.account_receivable.id,
"property_account_payable_id": cls.account_payable.id,
}
)
cls.journal = cls.env["account.journal"].create(
{"name": "Test sale journal", "type": "sale", "code": "TEST",}
{"name": "Test sale journal", "type": "sale", "code": "TEST"}
)
cls.expenses_journal = cls.env["account.journal"].create(
{"name": "Test expense journal", "type": "purchase", "code": "EXP",}
{"name": "Test expense journal", "type": "purchase", "code": "EXP"}
)
cls.miscellaneous_journal = cls.env["account.journal"].create(
{"name": "Miscellaneus journal", "type": "general", "code": "OTHER",}
{"name": "Miscellaneus journal", "type": "general", "code": "OTHER"}
)
cls.customer_invoice = cls.env["account.invoice"].create(
cls.customer_invoice = cls.env["account.move"].create(
{
"journal_id": cls.journal.id,
"type": "out_invoice",
"partner_id": cls.partner.id,
"account_id": cls.account_receivable.id,
"invoice_line_ids": [
(
0,
@@ -85,17 +92,16 @@ class TestAccountNetting(common.SavepointCase):
],
}
)
cls.customer_invoice.action_invoice_open()
customer_move = cls.customer_invoice.move_id
cls.customer_invoice.action_post()
customer_move = cls.customer_invoice
cls.move_line_1 = customer_move.line_ids.filtered(
lambda x: x.account_id == cls.account_receivable
)
cls.supplier_invoice = cls.env["account.invoice"].create(
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
"type": "in_invoice",
"partner_id": cls.partner.id,
"account_id": cls.account_payable.id,
"invoice_line_ids": [
(
0,
@@ -109,20 +115,19 @@ class TestAccountNetting(common.SavepointCase):
],
}
)
cls.supplier_invoice.action_invoice_open()
supplier_move = cls.supplier_invoice.move_id
cls.supplier_invoice.action_post()
supplier_move = cls.supplier_invoice
cls.move_line_2 = supplier_move.line_ids.filtered(
lambda x: x.account_id == cls.account_payable
)
cls.move_line_3 = supplier_move.line_ids.filtered(
lambda x: x.account_id == cls.account_expense
)
cls.supplier_invoice = cls.env["account.invoice"].create(
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
"type": "in_invoice",
"partner_id": cls.partner1.id,
"account_id": cls.account_payable.id,
"invoice_line_ids": [
(
0,
@@ -136,17 +141,16 @@ class TestAccountNetting(common.SavepointCase):
],
}
)
cls.supplier_invoice.action_invoice_open()
supplier_move = cls.supplier_invoice.move_id
cls.supplier_invoice.action_post()
supplier_move = cls.supplier_invoice
cls.move_line_4 = supplier_move.line_ids.filtered(
lambda x: x.account_id == cls.account_payable
)
cls.supplier_invoice = cls.env["account.invoice"].create(
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
"type": "in_refund",
"partner_id": cls.partner1.id,
"account_id": cls.account_payable.id,
"invoice_line_ids": [
(
0,
@@ -160,17 +164,16 @@ class TestAccountNetting(common.SavepointCase):
],
}
)
cls.supplier_invoice.action_invoice_open()
supplier_move = cls.supplier_invoice.move_id
cls.supplier_invoice.action_post()
supplier_move = cls.supplier_invoice
cls.move_line_5 = supplier_move.line_ids.filtered(
lambda x: x.account_id == cls.account_payable
)
cls.supplier_invoice = cls.env["account.invoice"].create(
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
"type": "in_refund",
"partner_id": cls.partner1.id,
"account_id": cls.account_payable.id,
"invoice_line_ids": [
(
0,
@@ -184,8 +187,8 @@ class TestAccountNetting(common.SavepointCase):
],
}
)
cls.supplier_invoice.action_invoice_open()
supplier_move = cls.supplier_invoice.move_id
cls.supplier_invoice.action_post()
supplier_move = cls.supplier_invoice
cls.move_line_6 = supplier_move.line_ids.filtered(
lambda x: x.account_id == cls.account_payable
)

View File

@@ -17,7 +17,7 @@ class AccountMoveMakeNetting(models.TransientModel):
move_line_ids = fields.Many2many(comodel_name="account.move.line",)
balance = fields.Float(readonly=True,)
balance_type = fields.Selection(
selection=[("pay", "To pay"), ("receive", "To receive"),], readonly=True,
selection=[("pay", "To pay"), ("receive", "To receive")], readonly=True,
)
@api.model
@@ -54,7 +54,7 @@ class AccountMoveMakeNetting(models.TransientModel):
"be the same for all."
)
)
res = super(AccountMoveMakeNetting, self).default_get(fields_list)
res = super().default_get(fields_list)
res["move_line_ids"] = [(6, 0, move_lines.ids)]
debit_move_lines_debit = move_lines.filtered("debit")
credit_move_lines_debit = move_lines.filtered("credit")
@@ -69,7 +69,7 @@ class AccountMoveMakeNetting(models.TransientModel):
self.ensure_one()
# Create account move
move = self.env["account.move"].create(
{"ref": _("AR/AP netting"), "journal_id": self.journal_id.id,}
{"ref": _("AR/AP netting"), "journal_id": self.journal_id.id}
)
# Group amounts by account
account_groups = self.move_line_ids.read_group(

View File

@@ -3,11 +3,9 @@
<act_window
name="Compensate"
res_model="account.move.make.netting"
src_model="account.move.line"
binding_model="account.move.line"
view_mode="form"
target="new"
key2="client_action_multi"
multi="True"
id="act_account_move_make_netting"
/>
<record id="view_account_move_make_netting_form" model="ir.ui.view">