mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[RFR] Rename field 'debit_move_line_id'
This commit is contained in:
@@ -214,7 +214,7 @@ class payment_order(orm.Model):
|
||||
line_ids = []
|
||||
reconcile_id = False
|
||||
for order_line in order.line_ids:
|
||||
for line in order_line.debit_move_line_id.move_id.line_id:
|
||||
for line in order_line.transit_move_line_id.move_id.line_id:
|
||||
if line.account_id.type == 'other' and not line.reconcile_id:
|
||||
line_ids.append(line.id)
|
||||
if self.pool.get('res.currency').is_zero(
|
||||
@@ -330,7 +330,7 @@ class payment_order(orm.Model):
|
||||
# and call reconciliation on it
|
||||
payment_line_obj.write(
|
||||
cr, uid, line.id,
|
||||
{'debit_move_line_id': reconcile_move_line_id},
|
||||
{'transit_move_line_id': reconcile_move_line_id},
|
||||
context=context)
|
||||
|
||||
payment_line_obj.debit_reconcile(
|
||||
|
||||
@@ -59,7 +59,7 @@ class banking_import_transaction(orm.Model):
|
||||
if len(candidates) > 0:
|
||||
# retrieve the common account_id, if any
|
||||
account_id = False
|
||||
for line in candidates[0].line_ids[0].debit_move_line_id.move_id.line_id:
|
||||
for line in candidates[0].line_ids[0].transit_move_line_id.move_id.line_id:
|
||||
if line.account_id.type == 'other':
|
||||
account_id = line.account_id.id
|
||||
break
|
||||
|
||||
@@ -235,10 +235,10 @@ class payment_line(orm.Model):
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
payment_line = self.browse(cr, uid, payment_line_id, context=context)
|
||||
|
||||
debit_move_line = payment_line.debit_move_line_id
|
||||
transit_move_line = payment_line.transit_move_line_id
|
||||
torec_move_line = payment_line.move_line_id
|
||||
|
||||
if (not debit_move_line or not torec_move_line):
|
||||
if (not transit_move_line or not torec_move_line):
|
||||
raise orm.except_orm(
|
||||
_('Can not reconcile'),
|
||||
_('No move line for line %s') % payment_line.name)
|
||||
@@ -248,22 +248,22 @@ class payment_line(orm.Model):
|
||||
_('Move line %s has already been reconciled') %
|
||||
torec_move_line.name
|
||||
)
|
||||
if debit_move_line.reconcile_id or debit_move_line.reconcile_partial_id:
|
||||
if transit_move_line.reconcile_id or transit_move_line.reconcile_partial_id:
|
||||
raise orm.except_orm(
|
||||
_('Error'),
|
||||
_('Move line %s has already been reconciled') %
|
||||
debit_move_line.name
|
||||
transit_move_line.name
|
||||
)
|
||||
|
||||
def is_zero(total):
|
||||
return self.pool.get('res.currency').is_zero(
|
||||
cr, uid, debit_move_line.company_id.currency_id, total)
|
||||
cr, uid, transit_move_line.company_id.currency_id, total)
|
||||
|
||||
line_ids = [debit_move_line.id, torec_move_line.id]
|
||||
line_ids = [transit_move_line.id, torec_move_line.id]
|
||||
if torec_move_line.reconcile_partial_id:
|
||||
line_ids = [
|
||||
x.id for x in
|
||||
debit_move_line.reconcile_partial_id.line_partial_ids
|
||||
transit_move_line.reconcile_partial_id.line_partial_ids
|
||||
] + [torec_move_line.id]
|
||||
|
||||
total = move_line_obj.get_balance(cr, uid, line_ids)
|
||||
@@ -275,7 +275,7 @@ class payment_line(orm.Model):
|
||||
|
||||
if torec_move_line.reconcile_partial_id:
|
||||
reconcile_obj.write(
|
||||
cr, uid, debit_move_line.reconcile_partial_id.id,
|
||||
cr, uid, transit_move_line.reconcile_partial_id.id,
|
||||
vals, context=context)
|
||||
else:
|
||||
reconcile_obj.create(
|
||||
@@ -293,7 +293,7 @@ class payment_line(orm.Model):
|
||||
|
||||
|
||||
_columns = {
|
||||
'debit_move_line_id': fields.many2one(
|
||||
'transit_move_line_id': fields.many2one(
|
||||
# this line is part of the credit side of move 2a
|
||||
# from the documentation
|
||||
'account.move.line', 'Debit move line',
|
||||
|
||||
@@ -175,7 +175,7 @@ msgid "The payment line name must be unique!"
|
||||
msgstr "De betaalregelnaam moet uniek zijn!"
|
||||
|
||||
#. module: account_direct_debit
|
||||
#: field:payment.line,debit_move_line_id:0
|
||||
#: field:payment.line,transit_move_line_id:0
|
||||
msgid "Debit move line"
|
||||
msgstr "Debetboeking"
|
||||
|
||||
@@ -200,7 +200,7 @@ msgid "Invoice"
|
||||
msgstr "Factuur"
|
||||
|
||||
#. module: account_direct_debit
|
||||
#: help:payment.line,debit_move_line_id:0
|
||||
#: help:payment.line,transit_move_line_id:0
|
||||
msgid "Move line through which the debit order pays the invoice"
|
||||
msgstr "Dagboekregel waarmee de incasso-opdracht de factuur voldoet"
|
||||
|
||||
|
||||
@@ -1,6 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2013 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
def rename_columns(cr, column_spec):
|
||||
"""
|
||||
Rename table columns. Taken from OpenUpgrade.
|
||||
|
||||
:param column_spec: a hash with table keys, with lists of tuples as values. \
|
||||
Tuples consist of (old_name, new_name).
|
||||
|
||||
"""
|
||||
for table in column_spec.keys():
|
||||
for (old, new) in column_spec[table]:
|
||||
logger.info("table %s, column %s: renaming to %s",
|
||||
table, old, new)
|
||||
cr.execute('ALTER TABLE "%s" RENAME "%s" TO "%s"' % (table, old, new,))
|
||||
cr.execute('DROP INDEX IF EXISTS "%s_%s_index"' % (table, old))
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
|
||||
# workflow state moved to another module
|
||||
cr.execute(
|
||||
"""
|
||||
@@ -9,4 +49,9 @@ def migrate(cr, version):
|
||||
WHERE name = 'trans_done_sent'
|
||||
AND module = 'account_direct_debit'
|
||||
""")
|
||||
|
||||
|
||||
# rename field debit_move_line_id
|
||||
rename_columns(cr, {
|
||||
'payment_line': [
|
||||
('debit_move_line_id', 'transit_move_line_id'),
|
||||
]})
|
||||
|
||||
@@ -32,25 +32,25 @@ class payment_line(orm.Model):
|
||||
reconcile_obj = self.pool.get('account.move.reconcile')
|
||||
line = self.browse(cr, uid, payment_line_id)
|
||||
reconcile_id = False
|
||||
if (line.debit_move_line_id and not line.storno and
|
||||
if (line.transit_move_line_id and not line.storno and
|
||||
self.pool.get('res.currency').is_zero(
|
||||
cr, uid, currency, (
|
||||
(line.debit_move_line_id.credit or 0.0) -
|
||||
(line.debit_move_line_id.debit or 0.0) + amount))):
|
||||
(line.transit_move_line_id.credit or 0.0) -
|
||||
(line.transit_move_line_id.debit or 0.0) + amount))):
|
||||
# Two different cases, full and partial
|
||||
# Both cases differ subtly in the procedure to follow
|
||||
# Needs refractoring, but why is this not in the OpenERP API?
|
||||
# Actually, given the nature of a direct debit order and storno,
|
||||
# we should not need to take partial into account on the side of
|
||||
# the debit_move_line.
|
||||
if line.debit_move_line_id.reconcile_partial_id:
|
||||
reconcile_id = line.debit_move_line_id.reconcile_partial_id.id
|
||||
# the transit_move_line.
|
||||
if line.transit_move_line_id.reconcile_partial_id:
|
||||
reconcile_id = line.transit_move_line_id.reconcile_partial_id.id
|
||||
attribute = 'reconcile_partial_id'
|
||||
if len(line.debit_move_line_id.reconcile_id.line_partial_ids) == 2:
|
||||
if len(line.transit_move_line_id.reconcile_id.line_partial_ids) == 2:
|
||||
# reuse the simple reconcile for the storno transfer
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
'line_id': [(6, 0, line.debit_move_line_id.id)],
|
||||
'line_id': [(6, 0, line.transit_move_line_id.id)],
|
||||
'line_partial_ids': [(6, 0, [])],
|
||||
}, context=context)
|
||||
else:
|
||||
@@ -58,27 +58,27 @@ class payment_line(orm.Model):
|
||||
# and a new one for reconciling the storno transfer
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
'line_partial_ids': [(3, line.debit_move_line_id.id)],
|
||||
'line_partial_ids': [(3, line.transit_move_line_id.id)],
|
||||
}, context=context)
|
||||
reconcile_id = reconcile_obj.create(
|
||||
cr, uid, {
|
||||
'type': 'auto',
|
||||
'line_id': [(6, 0, line.debit_move_line_id.id)],
|
||||
'line_id': [(6, 0, line.transit_move_line_id.id)],
|
||||
}, context=context)
|
||||
elif line.debit_move_line_id.reconcile_id:
|
||||
reconcile_id = line.debit_move_line_id.reconcile_id.id
|
||||
if len(line.debit_move_line_id.reconcile_id.line_id) == 2:
|
||||
elif line.transit_move_line_id.reconcile_id:
|
||||
reconcile_id = line.transit_move_line_id.reconcile_id.id
|
||||
if len(line.transit_move_line_id.reconcile_id.line_id) == 2:
|
||||
# reuse the simple reconcile for the storno transfer
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
'line_id': [(6, 0, [line.debit_move_line_id.id])]
|
||||
'line_id': [(6, 0, [line.transit_move_line_id.id])]
|
||||
}, context=context)
|
||||
else:
|
||||
# split up the original reconcile in a partial one
|
||||
# and a new one for reconciling the storno transfer
|
||||
partial_ids = [
|
||||
x.id for x in line.debit_move_line_id.reconcile_id.line_id
|
||||
if x.id != line.debit_move_line_id.id
|
||||
x.id for x in line.transit_move_line_id.reconcile_id.line_id
|
||||
if x.id != line.transit_move_line_id.id
|
||||
]
|
||||
reconcile_obj.write(
|
||||
cr, uid, reconcile_id, {
|
||||
@@ -88,7 +88,7 @@ class payment_line(orm.Model):
|
||||
reconcile_id = reconcile_obj.create(
|
||||
cr, uid, {
|
||||
'type': 'auto',
|
||||
'line_id': [(6, 0, line.debit_move_line_id.id)],
|
||||
'line_id': [(6, 0, line.transit_move_line_id.id)],
|
||||
}, context=context)
|
||||
# mark the payment line for storno processed
|
||||
if reconcile_id:
|
||||
@@ -119,12 +119,12 @@ class payment_line(orm.Model):
|
||||
|
||||
line = self.browse(cr, uid, payment_line_id)
|
||||
account_id = False
|
||||
if (line.debit_move_line_id and not line.storno and
|
||||
if (line.transit_move_line_id and not line.storno and
|
||||
self.pool.get('res.currency').is_zero(
|
||||
cr, uid, currency, (
|
||||
(line.debit_move_line_id.credit or 0.0) -
|
||||
(line.debit_move_line_id.debit or 0.0) + amount))):
|
||||
account_id = line.debit_move_line_id.account_id.id
|
||||
(line.transit_move_line_id.credit or 0.0) -
|
||||
(line.transit_move_line_id.debit or 0.0) + amount))):
|
||||
account_id = line.transit_move_line_id.account_id.id
|
||||
return account_id
|
||||
|
||||
def debit_reconcile(self, cr, uid, payment_line_id, context=None):
|
||||
|
||||
Reference in New Issue
Block a user