From d6c1417536352f68800e96c7fed5a2f57592612b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 10 Feb 2015 00:13:10 +0100 Subject: [PATCH] Improve payable/receivable lines - use a simplified view - add amount function field - use search_value for reconciliation filtering issue4515 review10101003 --- CHANGELOG | 1 + move.py | 25 ++++++++++++++++++++++ move.xml | 17 ++++++++++++++- view/move_line_list_payable_receivable.xml | 13 +++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 view/move_line_list_payable_receivable.xml diff --git a/CHANGELOG b/CHANGELOG index dcbdeb476b..a5e4447461 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Improve payable/receivable lines * Enforce same sign between amount_second_currency and debit - credit * Allow tax modifying the unit price * Add reverse_compute on Tax diff --git a/move.py b/move.py index 066858ab4c..f8650d88c6 100644 --- a/move.py +++ b/move.py @@ -622,6 +622,14 @@ class Line(ModelSQL, ModelView): 'get_currency_digits') second_currency_digits = fields.Function(fields.Integer( 'Second Currency Digits'), 'get_currency_digits') + amount = fields.Function(fields.Numeric('Amount', + digits=(16, Eval('amount_currency_digits', 2)), + depends=['amount_currency_digits']), + 'get_amount') + amount_currency = fields.Function(fields.Many2One('currency.currency', + 'Amount Currency'), 'get_amount_currency') + amount_currency_digits = fields.Function(fields.Integer( + 'Amount Currency Digits'), 'get_amount_currency') @classmethod def __setup__(cls): @@ -1152,6 +1160,23 @@ class Line(ModelSQL, ModelView): order_origin = _order_move_field('origin') order_move_state = _order_move_field('state') + def get_amount(self, name): + sign = 1 if self.account.type.display_balance == 'debit-credit' else -1 + if self.amount_second_currency is not None: + return self.amount_second_currency * sign + else: + return self.debit - self.credit * sign + + def get_amount_currency(self, name): + if self.second_currency: + currency = self.second_currency + else: + currency = self.account.currency + if name == 'amount_currency': + return currency.id + elif name == 'amount_currency_digits': + return currency.digits + def get_rec_name(self, name): if self.debit > self.credit: return self.account.rec_name diff --git a/move.xml b/move.xml index f3fb477476..32b9a7bf5e 100644 --- a/move.xml +++ b/move.xml @@ -163,6 +163,13 @@ this repository contains the full copyright notices and license terms. --> move_line_tree_move + + account.move.line + tree + + move_line_list_payable_receivable + + Account Move Lines account.move.line @@ -192,7 +199,15 @@ this repository contains the full copyright notices and license terms. --> id="act_move_line_payable_receivable"> Payable/Receivable Lines account.move.line - [('party', 'in', Eval('active_ids')), ('account.kind', 'in', ['payable', 'receivable']), ('reconciliation', '=', None)] + [('party', 'in', Eval('active_ids')), ('account.kind', 'in', ['payable', 'receivable'])] + [('reconciliation', '=', None)] + [('date', 'DESC')] + + + + + diff --git a/view/move_line_list_payable_receivable.xml b/view/move_line_list_payable_receivable.xml new file mode 100644 index 0000000000..65f1764079 --- /dev/null +++ b/view/move_line_list_payable_receivable.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + +