mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[DEL] Duplicated files
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import account_move_line
|
||||
from . import account_payment
|
||||
from . import bank_payment_manual
|
||||
from . import payment_mode
|
||||
from . import payment_mode_type
|
||||
from . import payment_order_create
|
||||
@@ -1,105 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2004-2014 OpenERP S.A. (http://www.openerp.com/)
|
||||
# (C) 2014 Akretion (http://www.akretion.com/)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from operator import itemgetter
|
||||
|
||||
|
||||
# All the code below aims at fixing one small issue in _to_pay_search()
|
||||
# But _to_pay_search() is the search function of the field 'amount_to_pay'
|
||||
# which is a field.function and these functions are not inheritable in OpenERP.
|
||||
# So we have to inherit the field 'amount_to_pay' and duplicate the related
|
||||
# functions
|
||||
# If the patch that I proposed in this bug report
|
||||
# https://bugs.launchpad.net/openobject-addons/+bug/1275478
|
||||
# is integrated in addons/account_payment, then we will be able to remove this
|
||||
# file. -- Alexis de Lattre
|
||||
class account_move_line(orm.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
def amount_to_pay(self, cr, uid, ids, name, arg=None, context=None):
|
||||
""" Return the amount still to pay regarding all the payemnt orders
|
||||
(excepting cancelled orders)"""
|
||||
if not ids:
|
||||
return {}
|
||||
cr.execute("""SELECT ml.id,
|
||||
CASE WHEN ml.amount_currency < 0
|
||||
THEN - ml.amount_currency
|
||||
ELSE ml.credit
|
||||
END -
|
||||
(SELECT coalesce(sum(amount_currency),0)
|
||||
FROM payment_line pl
|
||||
INNER JOIN payment_order po
|
||||
ON (pl.order_id = po.id)
|
||||
WHERE move_line_id = ml.id
|
||||
AND po.state != 'cancel') AS amount
|
||||
FROM account_move_line ml
|
||||
WHERE id IN %s""", (tuple(ids),))
|
||||
r = dict(cr.fetchall())
|
||||
return r
|
||||
|
||||
def _to_pay_search(self, cr, uid, obj, name, args, context=None):
|
||||
if not args:
|
||||
return []
|
||||
line_obj = self.pool.get('account.move.line')
|
||||
query = line_obj._query_get(cr, uid, context={})
|
||||
where = ' and '.join(map(lambda x: '''(SELECT
|
||||
CASE WHEN l.amount_currency < 0
|
||||
THEN - l.amount_currency
|
||||
ELSE l.credit
|
||||
END - coalesce(sum(pl.amount_currency), 0)
|
||||
FROM payment_line pl
|
||||
INNER JOIN payment_order po ON (pl.order_id = po.id)
|
||||
WHERE move_line_id = l.id
|
||||
AND po.state != 'cancel'
|
||||
) %(operator)s %%s ''' % {'operator': x[1]}, args))
|
||||
sql_args = tuple(map(itemgetter(2), args))
|
||||
|
||||
cr.execute(
|
||||
('''\
|
||||
SELECT id
|
||||
FROM account_move_line l
|
||||
WHERE account_id IN (select id
|
||||
FROM account_account
|
||||
WHERE type in %s AND active)
|
||||
AND reconcile_id IS null
|
||||
AND credit > 0
|
||||
AND ''' + where + ' and ' + query
|
||||
), (('payable', 'receivable'), ) + sql_args
|
||||
)
|
||||
# The patch we have compared to the original function in
|
||||
# addons/account_payment is just above :
|
||||
# original code : type = 'payable'
|
||||
# fixed code : type in ('payable', 'receivable')
|
||||
|
||||
res = cr.fetchall()
|
||||
if not res:
|
||||
return [('id', '=', '0')]
|
||||
return [('id', 'in', map(lambda x:x[0], res))]
|
||||
|
||||
_columns = {
|
||||
'amount_to_pay': fields.function(
|
||||
amount_to_pay,
|
||||
type='float',
|
||||
string='Amount to pay',
|
||||
fnct_search=_to_pay_search
|
||||
),
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools.translate import _
|
||||
from openerp import netsvc
|
||||
|
||||
|
||||
class payment_order(orm.Model):
|
||||
_inherit = 'payment.order'
|
||||
|
||||
_columns = {
|
||||
'payment_order_type': fields.selection(
|
||||
[('payment', 'Payment'), ('debit', 'Direct debit')],
|
||||
'Payment order type', required=True,
|
||||
readonly=True, states={'draft': [('readonly', False)]},
|
||||
),
|
||||
'mode_type': fields.related(
|
||||
'mode', 'type', type='many2one', relation='payment.mode.type',
|
||||
string='Payment Type'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'payment_order_type': 'payment',
|
||||
}
|
||||
|
||||
def launch_wizard(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Search for a wizard to launch according to the type.
|
||||
If type is manual. just confirm the order.
|
||||
Previously (pre-v6) in account_payment/wizard/wizard_pay.py
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
result = {}
|
||||
orders = self.browse(cr, uid, ids, context)
|
||||
order = orders[0]
|
||||
# check if a wizard is defined for the first order
|
||||
if order.mode.type and order.mode.type.ir_model_id:
|
||||
context['active_ids'] = ids
|
||||
wizard_model = order.mode.type.ir_model_id.model
|
||||
wizard_obj = self.pool.get(wizard_model)
|
||||
wizard_id = wizard_obj.create(cr, uid, {}, context)
|
||||
result = {
|
||||
'name': wizard_obj._description or _('Payment Order Export'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': wizard_model,
|
||||
'domain': [],
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'res_id': wizard_id,
|
||||
'nodestroy': True,
|
||||
}
|
||||
else:
|
||||
# should all be manual orders without type or wizard model
|
||||
for order in orders[1:]:
|
||||
if order.mode.type and order.mode.type.ir_model_id:
|
||||
raise orm.except_orm(
|
||||
_('Error'),
|
||||
_('You can only combine payment orders of the same '
|
||||
'type')
|
||||
)
|
||||
# process manual payments
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for order_id in ids:
|
||||
wf_service.trg_validate(
|
||||
uid, 'payment.order', order_id, 'done', cr
|
||||
)
|
||||
return result
|
||||
@@ -1,65 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
'''
|
||||
This module contains a single "wizard" for confirming manual
|
||||
bank transfers.
|
||||
'''
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from openerp import netsvc
|
||||
|
||||
|
||||
class payment_manual(orm.TransientModel):
|
||||
_name = 'payment.manual'
|
||||
_description = 'Send payment order(s) manually'
|
||||
|
||||
_columns = {
|
||||
'payment_order_ids': fields.many2many(
|
||||
'payment.order',
|
||||
'wiz_manual_payorders_rel',
|
||||
'wizard_id',
|
||||
'payment_order_id',
|
||||
'Payment orders',
|
||||
readonly=True
|
||||
),
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
payment_order_ids = context.get('active_ids', [])
|
||||
vals.update({
|
||||
'payment_order_ids': [[6, 0, payment_order_ids]],
|
||||
})
|
||||
return super(payment_manual, self).create(
|
||||
cr, uid, vals, context=context
|
||||
)
|
||||
|
||||
def button_ok(self, cr, uid, ids, context=None):
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for wiz in self.browse(cr, uid, ids, context=context):
|
||||
for order_id in wiz.payment_order_ids:
|
||||
wf_service.trg_validate(
|
||||
uid, 'payment.order', order_id.id, 'done', cr)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
@@ -1,62 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class payment_mode(orm.Model):
|
||||
''' Restoring the payment type from version 5,
|
||||
used to select the export wizard (if any) '''
|
||||
_inherit = "payment.mode"
|
||||
|
||||
def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None):
|
||||
""" Reinstates functional code for suitable bank type filtering.
|
||||
Current code in account_payment is disfunctional.
|
||||
"""
|
||||
res = []
|
||||
payment_mode = self.browse(
|
||||
cr, uid, payment_mode_id, context)
|
||||
if (payment_mode
|
||||
and payment_mode.type
|
||||
and payment_mode.type.suitable_bank_types):
|
||||
res = [t.code for t in payment_mode.type.suitable_bank_types]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'type': fields.many2one(
|
||||
'payment.mode.type', 'Payment type',
|
||||
required=True,
|
||||
help='Select the Payment Type for the Payment Mode.'
|
||||
),
|
||||
'payment_order_type': fields.related(
|
||||
'type', 'payment_order_type', readonly=True, type='selection',
|
||||
selection=[('payment', 'Payment'), ('debit', 'Direct debit')],
|
||||
string="Payment Order Type"),
|
||||
'active': fields.boolean('Active'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'active': True,
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class payment_mode_type(orm.Model):
|
||||
_name = 'payment.mode.type'
|
||||
_description = 'Payment Mode Type'
|
||||
_columns = {
|
||||
'name': fields.char(
|
||||
'Name', size=64, required=True,
|
||||
help='Payment Type'
|
||||
),
|
||||
'code': fields.char(
|
||||
'Code', size=64, required=True,
|
||||
help='Specify the Code for Payment Type'
|
||||
),
|
||||
'suitable_bank_types': fields.many2many(
|
||||
'res.partner.bank.type',
|
||||
'bank_type_payment_type_rel',
|
||||
'pay_type_id', 'bank_type_id',
|
||||
'Suitable bank types', required=True),
|
||||
'ir_model_id': fields.many2one(
|
||||
'ir.model', 'Payment wizard',
|
||||
help=('Select the Payment Wizard for payments of this type. '
|
||||
'Leave empty for manual processing'),
|
||||
domain=[('osv_memory', '=', True)],
|
||||
),
|
||||
'payment_order_type': fields.selection(
|
||||
[('payment', 'Payment'), ('debit', 'Direct debit')],
|
||||
'Payment order type', required=True,
|
||||
),
|
||||
'active': fields.boolean('Active'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'payment_order_type': 'payment',
|
||||
'active': True,
|
||||
}
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
r = super(payment_mode_type, self)._auto_init(cr, context=context)
|
||||
# migrate xmlid from manual_bank_transfer to avoid dependency on
|
||||
# account_banking
|
||||
cr.execute("""UPDATE ir_model_data
|
||||
SET module='account_banking_payment_export'
|
||||
WHERE module='account_banking' AND
|
||||
name='manual_bank_tranfer' AND
|
||||
model='payment.mode.type'""")
|
||||
return r
|
||||
@@ -1,201 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class payment_order_create(orm.TransientModel):
|
||||
_inherit = 'payment.order.create'
|
||||
|
||||
def extend_payment_order_domain(
|
||||
self, cr, uid, payment_order, domain, context=None):
|
||||
if payment_order.payment_order_type == 'payment':
|
||||
domain += [
|
||||
('account_id.type', 'in', ('payable', 'receivable')),
|
||||
('amount_to_pay', '>', 0)
|
||||
]
|
||||
return True
|
||||
|
||||
def search_entries(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
This method taken from account_payment module.
|
||||
We adapt the domain based on the payment_order_type
|
||||
"""
|
||||
line_obj = self.pool.get('account.move.line')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.read(cr, uid, ids, ['duedate'], context=context)[0]
|
||||
search_due_date = data['duedate']
|
||||
|
||||
# start account_banking_payment
|
||||
payment = self.pool.get('payment.order').browse(
|
||||
cr, uid, context['active_id'], context=context)
|
||||
# Search for move line to pay:
|
||||
domain = [
|
||||
('move_id.state', '=', 'posted'),
|
||||
('reconcile_id', '=', False),
|
||||
('company_id', '=', payment.mode.company_id.id),
|
||||
]
|
||||
self.extend_payment_order_domain(
|
||||
cr, uid, payment, domain, context=context)
|
||||
# end account_direct_debit
|
||||
|
||||
domain = domain + [
|
||||
'|', ('date_maturity', '<=', search_due_date),
|
||||
('date_maturity', '=', False)
|
||||
]
|
||||
line_ids = line_obj.search(cr, uid, domain, context=context)
|
||||
context.update({'line_ids': line_ids})
|
||||
model_data_ids = mod_obj.search(
|
||||
cr, uid, [
|
||||
('model', '=', 'ir.ui.view'),
|
||||
('name', '=', 'view_create_payment_order_lines')],
|
||||
context=context)
|
||||
resource_id = mod_obj.read(
|
||||
cr, uid, model_data_ids, fields=['res_id'],
|
||||
context=context)[0]['res_id']
|
||||
return {
|
||||
'name': _('Entry Lines'),
|
||||
'context': context,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'payment.order.create',
|
||||
'views': [(resource_id, 'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
def _prepare_payment_line(self, cr, uid, payment, line, context=None):
|
||||
'''This function is designed to be inherited
|
||||
The resulting dict is passed to the create method of payment.line'''
|
||||
_today = fields.date.context_today(self, cr, uid, context=context)
|
||||
if payment.date_prefered == "now":
|
||||
# no payment date => immediate payment
|
||||
date_to_pay = False
|
||||
elif payment.date_prefered == 'due':
|
||||
# account_banking
|
||||
# date_to_pay = line.date_maturity
|
||||
date_to_pay = (
|
||||
line.date_maturity
|
||||
if line.date_maturity and line.date_maturity > _today
|
||||
else False)
|
||||
# end account banking
|
||||
elif payment.date_prefered == 'fixed':
|
||||
# account_banking
|
||||
# date_to_pay = payment.date_scheduled
|
||||
date_to_pay = (
|
||||
payment.date_scheduled
|
||||
if payment.date_scheduled and payment.date_scheduled > _today
|
||||
else False)
|
||||
# end account banking
|
||||
|
||||
# account_banking
|
||||
state = 'normal'
|
||||
communication = line.ref or '-'
|
||||
if line.invoice:
|
||||
if line.invoice.type in ('in_invoice', 'in_refund'):
|
||||
if line.invoice.reference_type == 'structured':
|
||||
state = 'structured'
|
||||
communication = line.invoice.reference
|
||||
else:
|
||||
if line.invoice.reference:
|
||||
communication = line.invoice.reference
|
||||
elif line.invoice.supplier_invoice_number:
|
||||
communication = line.invoice.supplier_invoice_number
|
||||
else:
|
||||
# Make sure that the communication includes the
|
||||
# customer invoice number (in the case of debit order)
|
||||
communication = line.invoice.number.replace('/', '')
|
||||
state = 'structured'
|
||||
|
||||
# support debit orders when enabled
|
||||
if (payment.payment_order_type == 'debit'
|
||||
and 'amount_to_receive' in line):
|
||||
amount_currency = line.amount_to_receive
|
||||
else:
|
||||
amount_currency = line.amount_to_pay
|
||||
# end account_banking
|
||||
|
||||
# account banking
|
||||
# t = None
|
||||
# line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
|
||||
line2bank = self.pool['account.move.line'].line2bank(
|
||||
cr, uid, [line.id], payment.mode.id, context)
|
||||
# end account banking
|
||||
|
||||
res = {
|
||||
'move_line_id': line.id,
|
||||
'amount_currency': amount_currency,
|
||||
'bank_id': line2bank.get(line.id),
|
||||
'order_id': payment.id,
|
||||
'partner_id': line.partner_id and line.partner_id.id or False,
|
||||
# account banking
|
||||
# 'communication': line.ref or '/'
|
||||
'communication': communication,
|
||||
'state': state,
|
||||
# end account banking
|
||||
'date': date_to_pay,
|
||||
'currency': (line.invoice and line.invoice.currency_id.id
|
||||
or line.journal_id.currency.id
|
||||
or line.journal_id.company_id.currency_id.id),
|
||||
}
|
||||
return res
|
||||
|
||||
def create_payment(self, cr, uid, ids, context=None):
|
||||
'''
|
||||
This method is a slightly modified version of the existing method on
|
||||
this model in account_payment.
|
||||
- pass the payment mode to line2bank()
|
||||
- allow invoices to create influence on the payment process: not only
|
||||
'Free' references are allowed, but others as well
|
||||
- check date_to_pay is not in the past.
|
||||
'''
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.read(cr, uid, ids, [], context=context)[0]
|
||||
line_ids = data['entries']
|
||||
if not line_ids:
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
payment = self.pool['payment.order'].browse(
|
||||
cr, uid, context['active_id'], context=context)
|
||||
# Populate the current payment with new lines:
|
||||
for line in self.pool['account.move.line'].browse(
|
||||
cr, uid, line_ids, context=context):
|
||||
vals = self._prepare_payment_line(
|
||||
cr, uid, payment, line, context=context)
|
||||
self.pool['payment.line'].create(cr, uid, vals, context=context)
|
||||
# Force reload of payment order view as a workaround for lp:1155525
|
||||
return {
|
||||
'name': _('Payment Orders'),
|
||||
'context': context,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form,tree',
|
||||
'res_model': 'payment.order',
|
||||
'res_id': context['active_id'],
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Sale module for OpenERP
|
||||
# Copyright (C) 2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import sale
|
||||
@@ -1,55 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Sale module for OpenERP
|
||||
# Copyright (C) 2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class sale_order(orm.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
_columns = {
|
||||
'payment_mode_id': fields.many2one(
|
||||
'payment.mode', 'Payment Mode'),
|
||||
}
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part, context=None):
|
||||
res = super(sale_order, self).onchange_partner_id(
|
||||
cr, uid, ids, part, context=context)
|
||||
if part:
|
||||
partner = self.pool['res.partner'].browse(
|
||||
cr, uid, part, context=context)
|
||||
res['value']['payment_mode_id'] = \
|
||||
partner.customer_payment_mode.id or False,
|
||||
else:
|
||||
res['value']['payment_mode_id'] = False
|
||||
return res
|
||||
|
||||
def _prepare_invoice(self, cr, uid, order, lines, context=None):
|
||||
"""Copy bank partner from sale order to invoice"""
|
||||
invoice_vals = super(sale_order, self)._prepare_invoice(
|
||||
cr, uid, order, lines, context=context)
|
||||
invoice_vals.update({
|
||||
'payment_mode_id': order.payment_mode_id.id or False,
|
||||
'partner_bank_id': order.payment_mode_id and
|
||||
order.payment_mode_id.bank_id.id or False,
|
||||
})
|
||||
return invoice_vals
|
||||
Reference in New Issue
Block a user