Consider normal and refund operations separately

Allow to explore all move lines

Spanish translation

Bugfixes

Show negative lines too

Show move type in account.move views

Tests include new fields
This commit is contained in:
Antonio Espinosa
2016-10-21 15:08:38 +02:00
committed by Borruso
parent a48acb15d4
commit 3b74e4813c
9 changed files with 605 additions and 104 deletions

View File

@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# © 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api
class AccountMove(models.Model):
_inherit = 'account.move'
move_type = fields.Selection(
string="Move type", selection=[
('other', 'Other'),
('liquidity', 'Liquidity'),
('receivable', 'Receivable'),
('receivable_refund', 'Receivable refund'),
('payable', 'Payable'),
('payable_refund', 'Payable refund'),
], compute='_compute_move_type', store=True, readonly=True)
@api.multi
@api.depends('line_ids.account_id.internal_type', 'line_ids.balance')
def _compute_move_type(self):
def _balance_get(line_ids, internal_type):
return sum(line_ids.filtered(
lambda x: x.account_id.internal_type == internal_type).mapped(
'balance'))
for move in self:
internal_types = move.line_ids.mapped('account_id.internal_type')
if 'liquidity' in internal_types:
move.move_type = 'liquidity'
elif 'payable' in internal_types:
balance = _balance_get(move.line_ids, 'payable')
move.move_type = (
'payable' if balance < 0 else 'payable_refund')
elif 'receivable' in internal_types:
balance = _balance_get(move.line_ids, 'receivable')
move.move_type = (
'receivable' if balance > 0 else 'receivable_refund')
else:
move.move_type = 'other'