mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[REN] account_banking_payment_blocking -> account_payment_blocking
This commit is contained in:
committed by
Adrien Peiffer (ACSONE)
parent
8c8f9b54f4
commit
d82e0d56d3
24
account_payment_blocking/model/__init__.py
Normal file
24
account_payment_blocking/model/__init__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Blocking module for OpenERP
|
||||
# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu)
|
||||
# @author Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
#
|
||||
# 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 payment_order_create
|
||||
from . import account_invoice
|
||||
72
account_payment_blocking/model/account_invoice.py
Normal file
72
account_payment_blocking/model/account_invoice.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Blocking module for OpenERP
|
||||
# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu)
|
||||
# @author Adrien Peiffer <adrien.peiffer@acsone.eu>
|
||||
#
|
||||
# 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 account_invoice(orm.Model):
|
||||
_inherit = "account.invoice"
|
||||
|
||||
def _get_move_line(self, cr, uid, invoice_id, context=None):
|
||||
return self.pool.get('account.move.line')\
|
||||
.search(cr, uid, [('account_id.type', 'in',
|
||||
['payable', 'receivable']),
|
||||
('invoice.id', '=', invoice_id)])
|
||||
|
||||
def _set_move_blocked(self, cr, uid, ids, name, field_value, arg,
|
||||
context=None):
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
for invoice in self.browse(cr, uid, ids, context=context):
|
||||
if invoice.move_id.id:
|
||||
move_line_ids = self._get_move_line(cr, uid, invoice.id,
|
||||
context=context)
|
||||
assert len(move_line_ids) == 1
|
||||
# work with account_constraints from OCA/AFT:
|
||||
context.update({'from_parent_object': True})
|
||||
self.pool.get('account.move.line')\
|
||||
.write(cr, uid, move_line_ids, {'blocked': field_value},
|
||||
context=context)
|
||||
|
||||
def _get_move_blocked(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
for invoice in self.browse(cr, uid, ids, context=context):
|
||||
if invoice.move_id.id:
|
||||
move_line_ids = self._get_move_line(cr, uid, invoice.id,
|
||||
context=context)
|
||||
assert len(move_line_ids) == 1
|
||||
move_line = self.pool.get('account.move.line')\
|
||||
.browse(cr, uid, move_line_ids, context=context)[0]
|
||||
res[invoice.id] = move_line.blocked
|
||||
else:
|
||||
res[invoice.id] = False
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'blocked': fields.function(_get_move_blocked,
|
||||
fnct_inv=_set_move_blocked,
|
||||
type='boolean', string='No Follow Up',
|
||||
states={'draft': [('readonly',
|
||||
True)]}),
|
||||
}
|
||||
34
account_payment_blocking/model/payment_order_create.py
Normal file
34
account_payment_blocking/model/payment_order_create.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Blocking module for OpenERP
|
||||
# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu)
|
||||
# @author Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
class payment_order_create(orm.TransientModel):
|
||||
_inherit = 'payment.order.create'
|
||||
|
||||
def extend_payment_order_domain(
|
||||
self, cr, uid, payment_order, domain, context=None):
|
||||
super(payment_order_create, self).extend_payment_order_domain(
|
||||
cr, uid, payment_order, domain, context=context)
|
||||
domain += [('blocked', '!=', True)]
|
||||
return True
|
||||
Reference in New Issue
Block a user