mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Transfer move: one transfer move for each payment.order with only 1 line in the transfer account for the total of the account move.
Move the inherit of the 'Invoice' button of payment.order from account_banking_payment_transfer to account_banking_payment_export Demo data: Add a bank account + mandate on Agrolait, to be able to easily test multi-partner SEPA DD
This commit is contained in:
committed by
Stéphane Bidoul
parent
fd479fc894
commit
1a90364d0f
@@ -30,6 +30,14 @@
|
||||
<field name="country" ref="base.fr"/>
|
||||
</record>
|
||||
|
||||
<record id="bank_fortis" model="res.bank">
|
||||
<field name="name">BNP Paribas Fortis Charleroi</field>
|
||||
<field name="bic">GEBABEBB03A</field>
|
||||
<field name="city">Charleroi</field>
|
||||
<field name="country" ref="base.be"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="main_company_iban" model="res.partner.bank">
|
||||
<field name="acc_number">FR76 4242 4242 4242 4242 4242 424</field>
|
||||
<field name="state">iban</field>
|
||||
@@ -57,6 +65,15 @@
|
||||
<field name="bank_bic">FTNOFRP1XXX</field>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_2_iban" model="res.partner.bank">
|
||||
<field name="acc_number">BE96 9988 7766 5544</field>
|
||||
<field name="state">iban</field>
|
||||
<field name="bank" ref="bank_fortis"/>
|
||||
<field name="partner_id" ref="base.res_partner_2" />
|
||||
<field name="bank_name">BNP Paribas Fortis Charleroi</field>
|
||||
<field name="bank_bic">GEBABEBB03A</field>
|
||||
</record>
|
||||
|
||||
<record id="account_payment.payment_mode_1" model="payment.mode">
|
||||
<field name="type" ref="account_banking_payment_export.manual_bank_tranfer"/>
|
||||
</record>
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
<field name="mode" position="after">
|
||||
<field name="mode_type" invisible="1"/>
|
||||
</field>
|
||||
<xpath expr="//button[@string='Invoices']" position="attributes">
|
||||
<attribute name="attrs">{
|
||||
'invisible': [('state', '!=', 'draft')]}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
'account_banking_payment_export',
|
||||
],
|
||||
'data': [
|
||||
# TODO: 'view/account_payment.xml',
|
||||
'view/account_payment.xml',
|
||||
'view/payment_mode.xml',
|
||||
'workflow/account_payment.xml',
|
||||
],
|
||||
|
||||
@@ -105,6 +105,8 @@ class PaymentOrder(orm.Model):
|
||||
)
|
||||
),
|
||||
'date_sent': fields.date('Send date', readonly=True),
|
||||
'move_id': fields.many2one(
|
||||
'account.move', 'Transfer Move', readonly=True),
|
||||
}
|
||||
|
||||
def _write_payment_lines(self, cr, uid, ids, **kwargs):
|
||||
@@ -168,47 +170,42 @@ class PaymentOrder(orm.Model):
|
||||
return not self.test_done(cr, uid, ids, context=context)
|
||||
|
||||
def _prepare_transfer_move(
|
||||
self, cr, uid, order, line, labels, context=None):
|
||||
self, cr, uid, order, labels, context=None):
|
||||
vals = {
|
||||
'journal_id': order.mode.transfer_journal_id.id,
|
||||
'ref': '%s %s' % (order.payment_order_type[:3].upper(),
|
||||
line.move_line_id
|
||||
and line.move_line_id.move_id.name
|
||||
or line.communication),
|
||||
'ref': '%s %s' % (
|
||||
order.payment_order_type[:3].upper(), order.reference)
|
||||
}
|
||||
return vals
|
||||
|
||||
def _prepare_move_line_transfer_account(
|
||||
self, cr, uid, order, line, move_id, labels, context=None):
|
||||
self, cr, uid, order, amount, move_id, labels, context=None):
|
||||
vals = {
|
||||
'name': _('%s for %s') % (
|
||||
labels[order.payment_order_type],
|
||||
line.move_line_id and (line.move_line_id.invoice
|
||||
and line.move_line_id.invoice.number
|
||||
or line.move_line_id.name)
|
||||
or line.communication),
|
||||
'name': '%s %s' % (
|
||||
labels[order.payment_order_type], order.reference),
|
||||
'move_id': move_id,
|
||||
'partner_id': line.partner_id.id,
|
||||
'partner_id': False,
|
||||
'account_id': order.mode.transfer_account_id.id,
|
||||
'credit': (order.payment_order_type == 'payment'
|
||||
and line.amount or 0.0),
|
||||
and amount or 0.0),
|
||||
'debit': (order.payment_order_type == 'debit'
|
||||
and line.amount or 0.0),
|
||||
'date': fields.date.context_today(
|
||||
self, cr, uid, context=context),
|
||||
and amount or 0.0),
|
||||
}
|
||||
return vals
|
||||
|
||||
def _update_move_line_partner_account(
|
||||
self, cr, uid, order, line, vals, context=None):
|
||||
vals.update({
|
||||
def _prepare_move_line_partner_account(
|
||||
self, cr, uid, order, line, move_id, labels, context=None):
|
||||
vals = {
|
||||
'name': _('%s line %s') % (
|
||||
labels[order.payment_order_type], line.name),
|
||||
'move_id': move_id,
|
||||
'partner_id': line.partner_id.id,
|
||||
'account_id': line.move_line_id.account_id.id,
|
||||
'credit': (order.payment_order_type == 'debit'
|
||||
and line.amount or 0.0),
|
||||
'debit': (order.payment_order_type == 'payment'
|
||||
and line.amount or 0.0),
|
||||
})
|
||||
}
|
||||
return vals
|
||||
|
||||
def action_sent_no_move_line_hook(self, cr, uid, pay_line, context=None):
|
||||
@@ -232,6 +229,12 @@ class PaymentOrder(orm.Model):
|
||||
if not order.mode.transfer_journal_id \
|
||||
or not order.mode.transfer_account_id:
|
||||
continue
|
||||
|
||||
move_id = account_move_obj.create(
|
||||
cr, uid, self._prepare_transfer_move(
|
||||
cr, uid, order, labels, context=context),
|
||||
context=context)
|
||||
total_amount = 0
|
||||
for line in order.line_ids:
|
||||
if not line.move_line_id:
|
||||
continue
|
||||
@@ -242,30 +245,21 @@ class PaymentOrder(orm.Model):
|
||||
_('Move line %s has already been paid/reconciled')
|
||||
% line.move_line_id.name)
|
||||
|
||||
move_id = account_move_obj.create(
|
||||
cr, uid, self._prepare_transfer_move(
|
||||
cr, uid, order, line, labels, context=context),
|
||||
context=context)
|
||||
|
||||
# TODO: take multicurrency into account
|
||||
|
||||
# create the payment/debit move line on the transfer account
|
||||
ml_vals = self._prepare_move_line_transfer_account(
|
||||
cr, uid, order, line, move_id, labels, context=context)
|
||||
account_move_line_obj.create(cr, uid, ml_vals, context=context)
|
||||
|
||||
# create the payment/debit counterpart move line
|
||||
# on the partner account
|
||||
self._update_move_line_partner_account(
|
||||
cr, uid, order, line, ml_vals, context=context)
|
||||
reconcile_move_line_id = account_move_line_obj.create(
|
||||
cr, uid, ml_vals, context=context)
|
||||
partner_ml_vals = self._prepare_move_line_partner_account(
|
||||
cr, uid, order, line, move_id, labels, context=context)
|
||||
partner_move_line_id = account_move_line_obj.create(
|
||||
cr, uid, partner_ml_vals, context=context)
|
||||
total_amount += line.amount
|
||||
|
||||
# register the payment/debit move line
|
||||
# on the payment line and call reconciliation on it
|
||||
payment_line_obj.write(
|
||||
cr, uid, line.id,
|
||||
{'transit_move_line_id': reconcile_move_line_id},
|
||||
{'transit_move_line_id': partner_move_line_id},
|
||||
context=context)
|
||||
|
||||
if line.move_line_id:
|
||||
@@ -274,7 +268,17 @@ class PaymentOrder(orm.Model):
|
||||
else:
|
||||
self.action_sent_no_move_line_hook(
|
||||
cr, uid, line, context=context)
|
||||
account_move_obj.post(cr, uid, [move_id], context=context)
|
||||
|
||||
# create the payment/debit move line on the transfer account
|
||||
trf_ml_vals = self._prepare_move_line_transfer_account(
|
||||
cr, uid, order, total_amount, move_id, labels,
|
||||
context=context)
|
||||
account_move_line_obj.create(cr, uid, trf_ml_vals, context=context)
|
||||
|
||||
# post account move
|
||||
account_move_obj.post(cr, uid, [move_id], context=context)
|
||||
# link transfer move to payment.order
|
||||
order.write({'move_id': move_id})
|
||||
|
||||
# State field is written by act_sent_wait
|
||||
self.write(cr, uid, ids, {
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Make buttons on payment order sensitive for extra states,
|
||||
restore wizard functionality when making payments
|
||||
-->
|
||||
|
||||
<record id="view_banking_payment_order_form_1" model="ir.ui.view">
|
||||
<field name="name">account.payment.order.form.banking-1</field>
|
||||
<record id="view_payment_order_form" model="ir.ui.view">
|
||||
<field name="name">account_banking_payment_transfer.add_move_id</field>
|
||||
<field name="inherit_id" ref="account_payment.view_payment_order_form" />
|
||||
<field name="model">payment.order</field>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//button[@string='Select Invoices to Pay']"
|
||||
position="attributes">
|
||||
<attribute name="attrs">{
|
||||
'invisible':[('state','!=','draft')]
|
||||
}</attribute>
|
||||
</xpath>
|
||||
</data>
|
||||
<field name="date_scheduled" position="after">
|
||||
<field name="move_id" states="done"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -23,5 +23,13 @@
|
||||
<field name="state">valid</field>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_2_mandate" model="account.banking.mandate">
|
||||
<field name="partner_bank_id" ref="account_banking_payment_export.res_partner_2_iban"/>
|
||||
<field name="type">recurrent</field>
|
||||
<field name="recurrent_sequence_type">first</field>
|
||||
<field name="signature_date" eval="time.strftime('%Y-%m-01')" />
|
||||
<field name="state">valid</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user