mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Merge pull request #158 from acsone/8.0-imp-payment-order-journal-item-view-ape
[8.0][account_banking_payment_export] Add a custom view to select journal items that will added on payment order
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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')])
|
||||
|
||||
@@ -24,11 +24,35 @@
|
||||
<field name="inherit_id" ref="account_payment.view_create_payment_order_lines"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="entries" position="attributes">
|
||||
<attribute name="context">{'journal_type': 'sale'}</attribute>
|
||||
<attribute name="context">{'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'}</attribute>
|
||||
<attribute name="nolabel">1</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="payment_order_populate_view_move_line_tree" model="ir.ui.view">
|
||||
<field name="name">payment.order.populate.account.move.line.tree</field>
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Journal Items">
|
||||
<field name="journal_id" />
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field name="partner_id" />
|
||||
<field name="account_id" />
|
||||
<field name="journal_entry_ref" string="Journal Entry" />
|
||||
<field name="debit" sum="Total Debit" invisible="not context.get('display_debit', False)"/>
|
||||
<field name="credit" sum="Total Credit" invisible="not context.get('display_credit', False)"/>
|
||||
<field name="amount_residual" />
|
||||
<field name="date_maturity" invisible="context.get('journal_type', False) not in ['sale','sale_refund','purchase','purchase_refund']" />
|
||||
<field name="reconcile_ref"/>
|
||||
<field name="amount_currency" invisible="not context.get('currency',False)"/>
|
||||
<field name="currency_id" invisible="not context.get('currency',False)" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user