[MIG] account_netting: Migration to 15.0
TT36939
This commit is contained in:
parent
e565f741bd
commit
1864bc402b
@ -14,13 +14,13 @@ Account netting
|
|||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
|
.. |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/14.0/account_netting
|
:target: https://github.com/OCA/account-financial-tools/tree/15.0/account_netting
|
||||||
:alt: OCA/account-financial-tools
|
:alt: OCA/account-financial-tools
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_netting
|
:target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_netting
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||||
:target: https://runbot.odoo-community.org/runbot/92/14.0
|
:target: https://runbot.odoo-community.org/runbot/92/15.0
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|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>`_.
|
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.
|
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
|
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:%2014.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:%2015.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.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
@ -76,8 +76,11 @@ Authors
|
|||||||
Contributors
|
Contributors
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||||
* Vicent Cubells <vicent.cubells@serviciosbaeza.com>
|
|
||||||
|
* Pedro M. Baeza
|
||||||
|
* Vicent Cubells
|
||||||
|
* Víctor Martínez
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
@ -92,6 +95,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_netting>`_ project on GitHub.
|
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/15.0/account_netting>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Account netting",
|
"name": "Account netting",
|
||||||
"version": "14.0.1.0.0",
|
"version": "15.0.1.0.0",
|
||||||
"summary": "Compensate AR/AP accounts from the same partner",
|
"summary": "Compensate AR/AP accounts from the same partner",
|
||||||
"category": "Accounting & Finance",
|
"category": "Accounting & Finance",
|
||||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||||
|
@ -162,9 +162,3 @@ msgstr ""
|
|||||||
#, python-format
|
#, python-format
|
||||||
msgid "You should compensate at least 2 journal entries."
|
msgid "You should compensate at least 2 journal entries."
|
||||||
msgstr "Sie müssen mindestens 2 Journalposten kompensieren."
|
msgstr "Sie müssen mindestens 2 Journalposten kompensieren."
|
||||||
|
|
||||||
#~ msgid "Select the journal where storing the journal entries"
|
|
||||||
#~ msgstr "Wählen Sie das Journal zur Aufnahme der Posten"
|
|
||||||
|
|
||||||
#~ msgid "account.move.make.netting"
|
|
||||||
#~ msgstr "account.move.make.netting"
|
|
||||||
|
@ -162,9 +162,3 @@ msgstr "Asistente para generar movimientos de compensación"
|
|||||||
#, python-format
|
#, python-format
|
||||||
msgid "You should compensate at least 2 journal entries."
|
msgid "You should compensate at least 2 journal entries."
|
||||||
msgstr "Debe compensar al menos 2 apuntes."
|
msgstr "Debe compensar al menos 2 apuntes."
|
||||||
|
|
||||||
#~ msgid "Select the journal where storing the journal entries"
|
|
||||||
#~ msgstr "Seleccione el diario en el que se guardarán los apuntes"
|
|
||||||
|
|
||||||
#~ msgid "account.move.make.netting"
|
|
||||||
#~ msgstr "cuenta.asiento.hacer.neteo"
|
|
||||||
|
@ -162,9 +162,3 @@ msgstr "Assistente para gerar lançamentos de encontros de contas"
|
|||||||
#, python-format
|
#, python-format
|
||||||
msgid "You should compensate at least 2 journal entries."
|
msgid "You should compensate at least 2 journal entries."
|
||||||
msgstr "Deve compensar pelos menos 2 itens de diário."
|
msgstr "Deve compensar pelos menos 2 itens de diário."
|
||||||
|
|
||||||
#~ msgid "Select the journal where storing the journal entries"
|
|
||||||
#~ msgstr "Selecione o Diário onde guardar os lançamentos"
|
|
||||||
|
|
||||||
#~ msgid "account.move.make.netting"
|
|
||||||
#~ msgstr "account.move.make.netting"
|
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||||
* Vicent Cubells <vicent.cubells@serviciosbaeza.com>
|
|
||||||
|
* Pedro M. Baeza
|
||||||
|
* Vicent Cubells
|
||||||
|
* Víctor Martínez
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||||
<title>Account netting</title>
|
<title>Account netting</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ ul.auto-toc {
|
|||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! 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/14.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-14-0/account-financial-tools-14-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/14.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/15.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-15-0/account-financial-tools-15-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/15.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
|
<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
|
balance of a payable account for the same partner, creating a journal item
|
||||||
that reflects this operation.</p>
|
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>.
|
<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.
|
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
|
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:%2014.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:%2015.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>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
@ -421,8 +421,12 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||||||
<div class="section" id="contributors">
|
<div class="section" id="contributors">
|
||||||
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Pedro M. Baeza <<a class="reference external" href="mailto:pedro.baeza@tecnativa.com">pedro.baeza@tecnativa.com</a>></li>
|
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||||
<li>Vicent Cubells <<a class="reference external" href="mailto:vicent.cubells@serviciosbaeza.com">vicent.cubells@serviciosbaeza.com</a>></li>
|
<li>Pedro M. Baeza</li>
|
||||||
|
<li>Vicent Cubells</li>
|
||||||
|
<li>Víctor Martínez</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
@ -432,7 +436,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
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
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/14.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/15.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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,235 +1,116 @@
|
|||||||
# Copyright 2015 Pedro M. Baeza
|
# Copyright 2015 Pedro M. Baeza
|
||||||
# Copyright 2017 Tecnativa - Vicent Cubells
|
# Copyright 2017 Tecnativa - Vicent Cubells
|
||||||
|
# Copyright 2022 Tecnativa - Víctor Martínez
|
||||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import odoo.tests.common as common
|
import odoo.tests.common as common
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tests import Form, tagged
|
||||||
|
|
||||||
|
|
||||||
class TestAccountNetting(common.SavepointCase):
|
@tagged("post_install")
|
||||||
|
class TestAccountNetting(common.TransactionCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestAccountNetting, cls).setUpClass()
|
super().setUpClass()
|
||||||
res_users_account_manager = cls.env.ref("account.group_account_manager")
|
res_users_account_manager = cls.env.ref("account.group_account_manager")
|
||||||
partner_manager = cls.env.ref("base.group_partner_manager")
|
partner_manager = cls.env.ref("base.group_partner_manager")
|
||||||
cls.env.user.write(
|
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])]}
|
||||||
)
|
)
|
||||||
company = cls.env.ref("base.main_company")
|
cls.company = cls.env.ref("base.main_company")
|
||||||
# only adviser can create an account
|
# only adviser can create an account
|
||||||
cls.account_receivable = cls.env["account.account"].create(
|
cls.aa_model = cls.env["account.account"]
|
||||||
|
cls.account_receivable = cls._get_account(cls, "receivable")
|
||||||
|
cls.account_payable = cls._get_account(cls, "payable")
|
||||||
|
cls.account_revenue = cls._get_account(cls, "revenue")
|
||||||
|
cls.account_expense = cls._get_account(cls, "expenses")
|
||||||
|
cls.partner_model = cls.env["res.partner"]
|
||||||
|
cls.partner = cls._create_partner(cls, "Supplier/Customer")
|
||||||
|
cls.partner1 = cls._create_partner(cls, "Supplier/Customer 1")
|
||||||
|
cls.miscellaneous_journal = cls.env["account.journal"].search(
|
||||||
|
[("type", "=", "general")], limit=1
|
||||||
|
)
|
||||||
|
# We need a product with taxes at 0 so that the amounts are as expected.
|
||||||
|
cls.account_tax = cls.env["account.tax"].create(
|
||||||
|
{"name": "0%", "amount_type": "fixed", "type_tax_use": "sale", "amount": 0}
|
||||||
|
)
|
||||||
|
cls.product = cls.env["product.product"].create(
|
||||||
{
|
{
|
||||||
"code": "cust_acc",
|
"name": "Product Test",
|
||||||
"name": "customer account",
|
"list_price": 10,
|
||||||
"user_type_id": cls.env.ref("account.data_account_type_receivable").id,
|
"taxes_id": [(6, 0, [cls.account_tax.id])],
|
||||||
"reconcile": True,
|
|
||||||
"company_id": company.id,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
cls.account_payable = cls.env["account.account"].create(
|
out_invoice_partner = cls._create_move(cls, "out_invoice", cls.partner, 100)
|
||||||
{
|
out_invoice_partner.action_post()
|
||||||
"code": "supp_acc",
|
cls.move_line_1 = out_invoice_partner.line_ids.filtered(
|
||||||
"name": "supplier account",
|
|
||||||
"user_type_id": cls.env.ref("account.data_account_type_payable").id,
|
|
||||||
"reconcile": True,
|
|
||||||
"company_id": company.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
cls.account_revenue = cls.env["account.account"].search(
|
|
||||||
[
|
|
||||||
(
|
|
||||||
"user_type_id",
|
|
||||||
"=",
|
|
||||||
cls.env.ref("account.data_account_type_revenue").id,
|
|
||||||
),
|
|
||||||
("company_id", "=", company.id),
|
|
||||||
],
|
|
||||||
limit=1,
|
|
||||||
)
|
|
||||||
cls.account_expense = cls.env["account.account"].search(
|
|
||||||
[
|
|
||||||
(
|
|
||||||
"user_type_id",
|
|
||||||
"=",
|
|
||||||
cls.env.ref("account.data_account_type_expenses").id,
|
|
||||||
),
|
|
||||||
("company_id", "=", company.id),
|
|
||||||
],
|
|
||||||
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",
|
|
||||||
"company_id": company.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
cls.expenses_journal = cls.env["account.journal"].create(
|
|
||||||
{
|
|
||||||
"name": "Test expense journal",
|
|
||||||
"type": "purchase",
|
|
||||||
"code": "EXP",
|
|
||||||
"company_id": company.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
cls.miscellaneous_journal = cls.env["account.journal"].create(
|
|
||||||
{
|
|
||||||
"name": "Miscellaneus journal",
|
|
||||||
"type": "general",
|
|
||||||
"code": "OTHER",
|
|
||||||
"company_id": company.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
cls.customer_invoice = cls.env["account.move"].create(
|
|
||||||
{
|
|
||||||
"journal_id": cls.journal.id,
|
|
||||||
"move_type": "out_invoice",
|
|
||||||
"partner_id": cls.partner.id,
|
|
||||||
"company_id": company.id,
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"price_unit": 100.0,
|
|
||||||
"account_id": cls.account_revenue.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
|
lambda x: x.account_id == cls.account_receivable
|
||||||
)
|
)
|
||||||
cls.supplier_invoice = cls.env["account.move"].create(
|
in_invoice_partner = cls._create_move(cls, "in_invoice", cls.partner, 1200)
|
||||||
{
|
in_invoice_partner.action_post()
|
||||||
"journal_id": cls.expenses_journal.id,
|
cls.move_line_2 = in_invoice_partner.line_ids.filtered(
|
||||||
"move_type": "in_invoice",
|
|
||||||
"partner_id": cls.partner.id,
|
|
||||||
"company_id": company.id,
|
|
||||||
"invoice_date": datetime.now(),
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"price_unit": 1200.0,
|
|
||||||
"account_id": cls.account_expense.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
|
lambda x: x.account_id == cls.account_payable
|
||||||
)
|
)
|
||||||
cls.move_line_3 = supplier_move.line_ids.filtered(
|
cls.move_line_3 = in_invoice_partner.line_ids.filtered(
|
||||||
lambda x: x.account_id == cls.account_expense
|
lambda x: x.account_id == cls.account_expense
|
||||||
)
|
)
|
||||||
cls.supplier_invoice = cls.env["account.move"].create(
|
in_invoice_partner1 = cls._create_move(cls, "in_invoice", cls.partner1, 200)
|
||||||
{
|
in_invoice_partner1.action_post()
|
||||||
"journal_id": cls.expenses_journal.id,
|
cls.move_line_4 = in_invoice_partner1.line_ids.filtered(
|
||||||
"move_type": "in_invoice",
|
|
||||||
"partner_id": cls.partner1.id,
|
|
||||||
"company_id": company.id,
|
|
||||||
"invoice_date": datetime.now(),
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"price_unit": 200.0,
|
|
||||||
"account_id": cls.account_expense.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
|
lambda x: x.account_id == cls.account_payable
|
||||||
)
|
)
|
||||||
cls.supplier_invoice = cls.env["account.move"].create(
|
in_refund_partner1 = cls._create_move(cls, "in_refund", cls.partner1, 200)
|
||||||
{
|
in_refund_partner1.action_post()
|
||||||
"journal_id": cls.expenses_journal.id,
|
cls.move_line_5 = in_refund_partner1.line_ids.filtered(
|
||||||
"move_type": "in_refund",
|
|
||||||
"partner_id": cls.partner1.id,
|
|
||||||
"company_id": company.id,
|
|
||||||
"invoice_date": datetime.now(),
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"price_unit": 200.0,
|
|
||||||
"account_id": cls.account_expense.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
|
lambda x: x.account_id == cls.account_payable
|
||||||
)
|
)
|
||||||
cls.supplier_invoice = cls.env["account.move"].create(
|
in_refund_partner1 = cls._create_move(cls, "in_refund", cls.partner1, 200)
|
||||||
{
|
in_refund_partner1.action_post()
|
||||||
"journal_id": cls.expenses_journal.id,
|
cls.move_line_6 = in_refund_partner1.line_ids.filtered(
|
||||||
"move_type": "in_refund",
|
|
||||||
"partner_id": cls.partner1.id,
|
|
||||||
"company_id": company.id,
|
|
||||||
"invoice_date": datetime.now(),
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"price_unit": 200.0,
|
|
||||||
"account_id": cls.account_expense.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
|
lambda x: x.account_id == cls.account_payable
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _get_account(self, user_type):
|
||||||
|
user_type_ref = "account.data_account_type_%s" % user_type
|
||||||
|
return self.aa_model.search(
|
||||||
|
[
|
||||||
|
("user_type_id", "=", self.env.ref(user_type_ref).id),
|
||||||
|
("company_id", "=", self.company.id),
|
||||||
|
],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _create_partner(self, name):
|
||||||
|
return self.partner_model.create(
|
||||||
|
{
|
||||||
|
"name": name,
|
||||||
|
"property_account_receivable_id": self.account_receivable.id,
|
||||||
|
"property_account_payable_id": self.account_payable.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def _create_move(self, move_type, partner, price):
|
||||||
|
move_form = Form(
|
||||||
|
self.env["account.move"].with_context(
|
||||||
|
default_move_type=move_type,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
move_form.partner_id = partner
|
||||||
|
move_form.invoice_date = datetime.now()
|
||||||
|
with move_form.invoice_line_ids.new() as line_form:
|
||||||
|
line_form.product_id = self.product
|
||||||
|
line_form.price_unit = price
|
||||||
|
return move_form.save()
|
||||||
|
|
||||||
def test_compensation(self):
|
def test_compensation(self):
|
||||||
# Test exception line 33 from account_move_make_netting
|
# Test exception line 33 from account_move_make_netting
|
||||||
obj = self.env["account.move.make.netting"].with_context(
|
obj = self.env["account.move.make.netting"].with_context(
|
||||||
active_ids=[self.move_line_1.id]
|
active_ids=[self.move_line_1.id]
|
||||||
)
|
)
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(ValidationError):
|
||||||
wizard = obj.create(
|
wizard = obj.create(
|
||||||
{
|
{
|
||||||
"move_line_ids": [(6, 0, [self.move_line_1.id])],
|
"move_line_ids": [(6, 0, [self.move_line_1.id])],
|
||||||
@ -240,7 +121,7 @@ class TestAccountNetting(common.SavepointCase):
|
|||||||
obj = self.env["account.move.make.netting"].with_context(
|
obj = self.env["account.move.make.netting"].with_context(
|
||||||
active_ids=[self.move_line_1.id, self.move_line_3.id]
|
active_ids=[self.move_line_1.id, self.move_line_3.id]
|
||||||
)
|
)
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(ValidationError):
|
||||||
wizard = obj.create(
|
wizard = obj.create(
|
||||||
{
|
{
|
||||||
"move_line_ids": [
|
"move_line_ids": [
|
||||||
@ -253,7 +134,7 @@ class TestAccountNetting(common.SavepointCase):
|
|||||||
obj = self.env["account.move.make.netting"].with_context(
|
obj = self.env["account.move.make.netting"].with_context(
|
||||||
active_ids=[self.move_line_4.id, self.move_line_5.id]
|
active_ids=[self.move_line_4.id, self.move_line_5.id]
|
||||||
)
|
)
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(ValidationError):
|
||||||
wizard = obj.create(
|
wizard = obj.create(
|
||||||
{
|
{
|
||||||
"move_line_ids": [
|
"move_line_ids": [
|
||||||
@ -270,7 +151,7 @@ class TestAccountNetting(common.SavepointCase):
|
|||||||
obj = self.env["account.move.make.netting"].with_context(
|
obj = self.env["account.move.make.netting"].with_context(
|
||||||
active_ids=[self.move_line_4.id, self.move_line_5.id]
|
active_ids=[self.move_line_4.id, self.move_line_5.id]
|
||||||
)
|
)
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(ValidationError):
|
||||||
wizard = obj.create(
|
wizard = obj.create(
|
||||||
{
|
{
|
||||||
"move_line_ids": [
|
"move_line_ids": [
|
||||||
@ -283,7 +164,7 @@ class TestAccountNetting(common.SavepointCase):
|
|||||||
obj = self.env["account.move.make.netting"].with_context(
|
obj = self.env["account.move.make.netting"].with_context(
|
||||||
active_ids=[self.move_line_1.id, self.move_line_6.id]
|
active_ids=[self.move_line_1.id, self.move_line_6.id]
|
||||||
)
|
)
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(ValidationError):
|
||||||
wizard = obj.create(
|
wizard = obj.create(
|
||||||
{
|
{
|
||||||
"move_line_ids": [
|
"move_line_ids": [
|
||||||
|
@ -125,7 +125,9 @@ class AccountMoveMakeNetting(models.TransientModel):
|
|||||||
)
|
)
|
||||||
to_reconcile.reconcile()
|
to_reconcile.reconcile()
|
||||||
# Open created move
|
# Open created move
|
||||||
action = self.env.ref("account.action_move_journal_line").read()[0]
|
action = self.env["ir.actions.act_window"]._for_xml_id(
|
||||||
|
"account.action_move_journal_line"
|
||||||
|
)
|
||||||
action["view_mode"] = "form"
|
action["view_mode"] = "form"
|
||||||
del action["views"]
|
del action["views"]
|
||||||
del action["view_id"]
|
del action["view_id"]
|
||||||
|
Loading…
Reference in New Issue
Block a user