From 11c4299d9a424c9acceca20826dfd1092298b45d Mon Sep 17 00:00:00 2001
From: Alexis de Lattre
Date: Thu, 26 Nov 2020 15:23:56 +0100
Subject: [PATCH] [MIG] account_netting to v14
---
account_netting/__manifest__.py | 11 ++--
account_netting/security/ir.model.access.csv | 2 +
account_netting/tests/test_account_netting.py | 51 +++++++++++++++----
.../wizards/account_move_make_netting.py | 8 +--
.../account_move_make_netting_view.xml | 24 +++++----
.../odoo/addons/account_netting | 1 +
setup/account_netting/setup.py | 6 +++
7 files changed, 76 insertions(+), 27 deletions(-)
create mode 100644 account_netting/security/ir.model.access.csv
create mode 120000 setup/account_netting/odoo/addons/account_netting
create mode 100644 setup/account_netting/setup.py
diff --git a/account_netting/__manifest__.py b/account_netting/__manifest__.py
index d520f0234..5e0eedf17 100644
--- a/account_netting/__manifest__.py
+++ b/account_netting/__manifest__.py
@@ -4,13 +4,16 @@
{
"name": "Account netting",
- "version": "13.0.1.0.0",
+ "version": "14.0.1.0.0",
"summary": "Compensate AR/AP accounts from the same partner",
"category": "Accounting & Finance",
- "author": "Tecnativa, " "Odoo Community Association (OCA)",
+ "author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
- "website": "https://github.com/OCA/account-financial-tools/",
+ "website": "https://github.com/OCA/account-financial-tools",
"depends": ["account"],
- "data": ["wizards/account_move_make_netting_view.xml"],
+ "data": [
+ "security/ir.model.access.csv",
+ "wizards/account_move_make_netting_view.xml",
+ ],
"installable": True,
}
diff --git a/account_netting/security/ir.model.access.csv b/account_netting/security/ir.model.access.csv
new file mode 100644
index 000000000..569589cc9
--- /dev/null
+++ b/account_netting/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_account_move_make_netting,Full access on account.move.make.netting to accountant grp,model_account_move_make_netting,account.group_account_user,1,1,1,1
diff --git a/account_netting/tests/test_account_netting.py b/account_netting/tests/test_account_netting.py
index e183c51c5..acb0b0e28 100644
--- a/account_netting/tests/test_account_netting.py
+++ b/account_netting/tests/test_account_netting.py
@@ -2,6 +2,8 @@
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
+from datetime import datetime
+
import odoo.tests.common as common
@@ -14,6 +16,7 @@ class TestAccountNetting(common.SavepointCase):
cls.env.user.write(
{"groups_id": [(6, 0, [res_users_account_manager.id, partner_manager.id])]}
)
+ company = cls.env.ref("base.main_company")
# only adviser can create an account
cls.account_receivable = cls.env["account.account"].create(
{
@@ -21,6 +24,7 @@ class TestAccountNetting(common.SavepointCase):
"name": "customer account",
"user_type_id": cls.env.ref("account.data_account_type_receivable").id,
"reconcile": True,
+ "company_id": company.id,
}
)
cls.account_payable = cls.env["account.account"].create(
@@ -29,6 +33,7 @@ class TestAccountNetting(common.SavepointCase):
"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(
@@ -37,7 +42,8 @@ class TestAccountNetting(common.SavepointCase):
"user_type_id",
"=",
cls.env.ref("account.data_account_type_revenue").id,
- )
+ ),
+ ("company_id", "=", company.id),
],
limit=1,
)
@@ -47,7 +53,8 @@ class TestAccountNetting(common.SavepointCase):
"user_type_id",
"=",
cls.env.ref("account.data_account_type_expenses").id,
- )
+ ),
+ ("company_id", "=", company.id),
],
limit=1,
)
@@ -66,19 +73,35 @@ class TestAccountNetting(common.SavepointCase):
}
)
cls.journal = cls.env["account.journal"].create(
- {"name": "Test sale journal", "type": "sale", "code": "TEST"}
+ {
+ "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"}
+ {
+ "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"}
+ {
+ "name": "Miscellaneus journal",
+ "type": "general",
+ "code": "OTHER",
+ "company_id": company.id,
+ }
)
cls.customer_invoice = cls.env["account.move"].create(
{
"journal_id": cls.journal.id,
- "type": "out_invoice",
+ "move_type": "out_invoice",
"partner_id": cls.partner.id,
+ "company_id": company.id,
"invoice_line_ids": [
(
0,
@@ -100,8 +123,10 @@ class TestAccountNetting(common.SavepointCase):
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
- "type": "in_invoice",
+ "move_type": "in_invoice",
"partner_id": cls.partner.id,
+ "company_id": company.id,
+ "invoice_date": datetime.now(),
"invoice_line_ids": [
(
0,
@@ -126,8 +151,10 @@ class TestAccountNetting(common.SavepointCase):
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
- "type": "in_invoice",
+ "move_type": "in_invoice",
"partner_id": cls.partner1.id,
+ "company_id": company.id,
+ "invoice_date": datetime.now(),
"invoice_line_ids": [
(
0,
@@ -149,8 +176,10 @@ class TestAccountNetting(common.SavepointCase):
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
- "type": "in_refund",
+ "move_type": "in_refund",
"partner_id": cls.partner1.id,
+ "company_id": company.id,
+ "invoice_date": datetime.now(),
"invoice_line_ids": [
(
0,
@@ -172,8 +201,10 @@ class TestAccountNetting(common.SavepointCase):
cls.supplier_invoice = cls.env["account.move"].create(
{
"journal_id": cls.expenses_journal.id,
- "type": "in_refund",
+ "move_type": "in_refund",
"partner_id": cls.partner1.id,
+ "company_id": company.id,
+ "invoice_date": datetime.now(),
"invoice_line_ids": [
(
0,
diff --git a/account_netting/wizards/account_move_make_netting.py b/account_netting/wizards/account_move_make_netting.py
index e117046c5..839c731a5 100644
--- a/account_netting/wizards/account_move_make_netting.py
+++ b/account_netting/wizards/account_move_make_netting.py
@@ -14,10 +14,11 @@ class AccountMoveMakeNetting(models.TransientModel):
required=True,
domain="[('type', '=', 'general')]",
)
- move_line_ids = fields.Many2many(comodel_name="account.move.line",)
- balance = fields.Float(readonly=True,)
+ 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
@@ -116,6 +117,7 @@ class AccountMoveMakeNetting(models.TransientModel):
break
if move_lines:
move.write({"line_ids": move_lines})
+ move.action_post()
# Make reconciliation
for move_line in move.line_ids:
to_reconcile = move_line + self.move_line_ids.filtered(
diff --git a/account_netting/wizards/account_move_make_netting_view.xml b/account_netting/wizards/account_move_make_netting_view.xml
index ed8978363..fe2b21e6d 100644
--- a/account_netting/wizards/account_move_make_netting_view.xml
+++ b/account_netting/wizards/account_move_make_netting_view.xml
@@ -1,23 +1,27 @@
-
+
+ Compensate
+ account.move.make.netting
+ form
+ new
+
+ list
+
+
Compensate entries
account.move.make.netting
-
+