diff --git a/account_banking_payment_blocking/__openerp__.py b/account_banking_payment_blocking/__openerp__.py index 024d79cf0..7f882573b 100644 --- a/account_banking_payment_blocking/__openerp__.py +++ b/account_banking_payment_blocking/__openerp__.py @@ -34,6 +34,7 @@ 'account_banking_payment_export' ], 'data': [ + 'view/account_invoice_view.xml' ], 'test': [ ], diff --git a/account_banking_payment_blocking/model/__init__.py b/account_banking_payment_blocking/model/__init__.py index ae51395a6..437ba1cb6 100644 --- a/account_banking_payment_blocking/model/__init__.py +++ b/account_banking_payment_blocking/model/__init__.py @@ -21,3 +21,4 @@ ############################################################################## import payment_order_create +from . import account_invoice diff --git a/account_banking_payment_blocking/model/account_invoice.py b/account_banking_payment_blocking/model/account_invoice.py new file mode 100644 index 000000000..ec83e5c73 --- /dev/null +++ b/account_banking_payment_blocking/model/account_invoice.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +# +# +# Authors: Adrien Peiffer +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 . +# +# + +from openerp.osv import orm, fields + + +class account_invoice(orm.Model): + _inherit = "account.invoice" + + 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_obj = self.pool.get('account.move.line') + move_line_ids = move_line_obj\ + .search(cr, uid, [('account_id.type', 'in', + ['payable', 'receivable']), + ('invoice.id', '=', invoice.id)]) + assert len(move_line_ids) == 1 + # work with account_constraints from OCA/AFT: + context.update({'from_parent_object': True}) + move_line_obj.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_obj = self.pool.get('account.move.line') + move_line_ids = move_line_obj\ + .search(cr, uid, [('account_id.type', 'in', + ['payable', 'receivable']), + ('invoice.id', '=', invoice.id)]) + assert len(move_line_ids) == 1 + move_line = move_line_obj.browse(cr, uid, move_line_ids, + context=context)[0] + res[invoice.id] = move_line.blocked + else: + res[invoice.id] = False + return res + + _columns = { + 'move_blocked': fields.function(_get_move_blocked, + fnct_inv=_set_move_blocked, + type='boolean', string='No Follow Up', + states={'draft': [('readonly', + True)]}), + } diff --git a/account_banking_payment_blocking/view/account_invoice_view.xml b/account_banking_payment_blocking/view/account_invoice_view.xml new file mode 100644 index 000000000..86601a49a --- /dev/null +++ b/account_banking_payment_blocking/view/account_invoice_view.xml @@ -0,0 +1,15 @@ + + + + + account.invoice.supplier.form (account_banking_payment_blocking) + account.invoice + + + + + + + + + \ No newline at end of file