mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] use super instead of function recreated from scratch
This commit is contained in:
@@ -34,47 +34,30 @@ class payment_order_create(orm.TransientModel):
|
|||||||
To be compliant with multi currency
|
To be compliant with multi currency
|
||||||
Allready corrected in V8 but will not be corrected in V7
|
Allready corrected in V8 but will not be corrected in V7
|
||||||
"""
|
"""
|
||||||
order_obj = self.pool.get('payment.order')
|
res = super(payment_order_create, self).create_payment(cr,
|
||||||
|
uid,
|
||||||
|
ids,
|
||||||
|
context=context)
|
||||||
line_obj = self.pool.get('account.move.line')
|
line_obj = self.pool.get('account.move.line')
|
||||||
payment_obj = self.pool.get('payment.line')
|
payment_obj = self.pool.get('payment.line')
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
data = self.browse(cr, uid, ids, context=context)[0]
|
data = self.browse(cr, uid, ids, context=context)[0]
|
||||||
line_ids = [entry.id for entry in data.entries]
|
line_ids = [entry.id for entry in data.entries]
|
||||||
if not line_ids:
|
if not line_ids:
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
return res
|
||||||
|
|
||||||
payment = order_obj.browse(cr, uid, context['active_id'],
|
|
||||||
context=context)
|
|
||||||
line2bank = line_obj.line2bank(cr, uid, line_ids, None, context)
|
|
||||||
|
|
||||||
# Finally populate the current payment with new lines:
|
# Finally populate the current payment with new lines:
|
||||||
for line in line_obj.browse(cr, uid, line_ids, context=context):
|
for line in line_obj.browse(cr, uid, line_ids, context=context):
|
||||||
if payment.date_prefered == "now":
|
payment_line_id = payment_obj.search(cr, uid,
|
||||||
# no payment date => immediate payment
|
[('move_line_id',
|
||||||
date_to_pay = False
|
'=',
|
||||||
elif payment.date_prefered == 'due':
|
line.id)],
|
||||||
date_to_pay = line.date_maturity
|
context=context)
|
||||||
elif payment.date_prefered == 'fixed':
|
if payment_line_id:
|
||||||
date_to_pay = payment.date_scheduled
|
payment_obj.write(
|
||||||
state = 'normal'
|
cr,
|
||||||
if line.invoice and line.invoice.reference_type != 'none':
|
uid,
|
||||||
state = 'structured'
|
payment_line_id,
|
||||||
currency_id = line.invoice.currency_id.id if line.invoice else None
|
{'amount_currency': line.amount_residual_currency},
|
||||||
if not currency_id:
|
context=context
|
||||||
currency_id = line.journal_id.currency.id
|
)
|
||||||
if not currency_id:
|
|
||||||
currency_id = line.journal_id.company_id.currency_id.id
|
return res
|
||||||
payment_obj.create(
|
|
||||||
cr, uid, {
|
|
||||||
'move_line_id': line.id,
|
|
||||||
'amount_currency': line.amount_residual_currency,
|
|
||||||
'bank_id': line2bank.get(line.id),
|
|
||||||
'order_id': payment.id,
|
|
||||||
'partner_id': line.partner_id.id,
|
|
||||||
'communication': line.ref or '/',
|
|
||||||
'state': state,
|
|
||||||
'date': date_to_pay,
|
|
||||||
'currency': currency_id,
|
|
||||||
}, context=context)
|
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user