diff --git a/account_banking_payment_export/models/account_move_line.py b/account_banking_payment_export/models/account_move_line.py index 54adf2ca8..e7c2bdc3d 100644 --- a/account_banking_payment_export/models/account_move_line.py +++ b/account_banking_payment_export/models/account_move_line.py @@ -19,13 +19,27 @@ # ############################################################################## -from openerp.osv import orm +from openerp import models, fields, api -class AccountMoveLine(orm.Model): +class AccountMoveLine(models.Model): _inherit = 'account.move.line' - def get_balance(self, cr, uid, ids, context=None): + @api.one + def _get_journal_entry_ref(self): + if self.move_id.state == 'draft': + if self.invoice.id: + self.journal_entry_ref = self.invoice.number + else: + self.journal_entry_ref = '*' + str(self.move_id.id) + else: + self.journal_entry_ref = self.move_id.name + + journal_entry_ref = fields.Char(compute=_get_journal_entry_ref, + string='Journal Entry Ref') + + @api.multi + def get_balance(self): """ Return the balance of any set of move lines. @@ -33,9 +47,6 @@ class AccountMoveLine(orm.Model): returns the account balance that the move line applies to. """ total = 0.0 - if not ids: - return total - for line in self.read( - cr, uid, ids, ['debit', 'credit'], context=context): - total += (line['debit'] or 0.0) - (line['credit'] or 0.0) + for line in self: + total += (line.debit or 0.0) - (line.credit or 0.0) return total diff --git a/account_banking_payment_export/wizard/payment_order_create.py b/account_banking_payment_export/wizard/payment_order_create.py index 40a98457d..33eaaebc3 100644 --- a/account_banking_payment_export/wizard/payment_order_create.py +++ b/account_banking_payment_export/wizard/payment_order_create.py @@ -109,6 +109,12 @@ class PaymentOrderCreate(models.TransientModel): context = self.env.context.copy() context['line_ids'] = self.filter_lines(lines) context['populate_results'] = self.populate_results + if payment.payment_order_type == 'payment': + context['display_credit'] = True + context['display_debit'] = False + else: + context['display_credit'] = False + context['display_debit'] = True model_datas = model_data_obj.search( [('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')]) diff --git a/account_banking_payment_export/wizard/payment_order_create_view.xml b/account_banking_payment_export/wizard/payment_order_create_view.xml index d70135343..d4d4b44dc 100644 --- a/account_banking_payment_export/wizard/payment_order_create_view.xml +++ b/account_banking_payment_export/wizard/payment_order_create_view.xml @@ -24,11 +24,35 @@ - {'journal_type': 'sale'} + {'display_credit': context.get('display_credit', False),'display_debit': context.get('display_debit', False),'journal_type': 'sale', 'tree_view_ref' : 'account_banking_payment_export.payment_order_populate_view_move_line_tree'} 1 + + payment.order.populate.account.move.line.tree + account.move.line + + + + + + + + + + + + + + + + + + + + +