2
0

[MIG] account_netting from v11 to v12

This commit is contained in:
Alexis de Lattre 2019-03-19 23:12:50 +01:00
parent 7ed9a7e0a9
commit 6a35bf5b92
7 changed files with 28 additions and 10 deletions

View File

@ -4,7 +4,7 @@
{
'name': 'Account netting',
'version': '11.0.1.0.0',
'version': '12.0.1.0.0',
'summary': 'Compensate AR/AP accounts from the same partner',
'category': 'Accounting & Finance',
'author': 'Tecnativa, '

View File

@ -0,0 +1,2 @@
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Vicent Cubells <vicent.cubells@serviciosbaeza.com>

View File

@ -0,0 +1,8 @@
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.
**WARNING**: This operation can be forbidden in your country by the accounting
regulations, so you should check current laws before using it. For example, in
Spain, this is not allowed at first instance, unless you document well the
operation from both parties.

View File

@ -0,0 +1,12 @@
From any account journal entries view:
* Accounting/Journal Entries/Journal Items
select all the lines that corresponds to both AR/AP operations from the same
partner. Click on *Action > Compensate*. If the items don't correspond to the
same partner or they aren't AR/AP accounts, you will get an error.
On contrary, a dialog box will be presented with the result of the operation
and a selection of the journal to register the operation. When you click on the
*Compensate* button, a journal entry is created with the corresponding
counterparts of the AR/AP operations.

View File

@ -2,7 +2,7 @@
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
import openerp.tests.common as common
import odoo.tests.common as common
class TestAccountNetting(common.SavepointCase):

View File

@ -7,6 +7,7 @@ from odoo import _, api, exceptions, fields, models
class AccountMoveMakeNetting(models.TransientModel):
_name = "account.move.make.netting"
_description = 'Wizard to generate account moves for netting'
journal_id = fields.Many2one(
comodel_name="account.journal",
@ -28,7 +29,7 @@ class AccountMoveMakeNetting(models.TransientModel):
)
@api.model
def default_get(self, fields):
def default_get(self, fields_list):
if len(self.env.context.get('active_ids', [])) < 2:
raise exceptions.ValidationError(
_("You should compensate at least 2 journal entries."))
@ -51,7 +52,7 @@ class AccountMoveMakeNetting(models.TransientModel):
raise exceptions.ValidationError(
_("All entries should have a partner and the partner must "
"be the same for all."))
res = super(AccountMoveMakeNetting, self).default_get(fields)
res = super(AccountMoveMakeNetting, self).default_get(fields_list)
res['move_line_ids'] = [(6, 0, move_lines.ids)]
balance = (sum(move_lines.mapped('debit')) -
sum(move_lines.mapped('credit')))
@ -59,7 +60,6 @@ class AccountMoveMakeNetting(models.TransientModel):
res['balance_type'] = 'pay' if balance < 0 else 'receive'
return res
@api.multi
def button_compensate(self):
self.ensure_one()
# Create account move
@ -103,8 +103,6 @@ class AccountMoveMakeNetting(models.TransientModel):
move_line_vals = {
field_map[i]: amount,
'partner_id': self.move_line_ids[0].partner_id.id,
'date': move.date,
'journal_id': move.journal_id.id,
'name': move.ref,
'account_id': account_group['account_id'],
}

View File

@ -15,12 +15,10 @@
<field name="model">account.move.make.netting</field>
<field name="arch" type="xml">
<form string="Compensate entries">
<label string="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 account 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"/>
</group>
<group string="Select the journal where storing the journal entries">
<field name="journal_id"/>
</group>
<footer>