mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] account_netting to v14
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
2
account_netting/security/ir.model.access.csv
Normal file
2
account_netting/security/ir.model.access.csv
Normal file
@@ -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
|
||||
|
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<act_window
|
||||
name="Compensate"
|
||||
res_model="account.move.make.netting"
|
||||
binding_model="account.move.line"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
id="act_account_move_make_netting"
|
||||
/>
|
||||
<record id="act_account_move_make_netting" model="ir.actions.act_window">
|
||||
<field name="name">Compensate</field>
|
||||
<field name="res_model">account.move.make.netting</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="binding_model_id" ref="account.model_account_move_line" />
|
||||
<field name="binding_view_types">list</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_move_make_netting_form" model="ir.ui.view">
|
||||
<field name="name">Compensate entries</field>
|
||||
<field name="model">account.move.make.netting</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Compensate entries">
|
||||
<p
|
||||
>This operation will generate account entries that are counterpart of the receivable/payable accounts selected, and reconcile each other, letting this balance in the partner.</p>
|
||||
>This operation will generate journal entries that are counterpart of the receivable/payable accounts selected, and reconcile each other, letting this balance in the partner.</p>
|
||||
<group>
|
||||
<field name="balance" />
|
||||
<field name="balance_type" />
|
||||
<field
|
||||
name="balance_type"
|
||||
attrs="{'invisible': [('balance', '=', 0)]}"
|
||||
/>
|
||||
<field name="journal_id" />
|
||||
</group>
|
||||
<footer>
|
||||
|
||||
1
setup/account_netting/odoo/addons/account_netting
Symbolic link
1
setup/account_netting/odoo/addons/account_netting
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../account_netting
|
||||
6
setup/account_netting/setup.py
Normal file
6
setup/account_netting/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user