From 1ea580872d7e5af9872ded1a00d378fc75354e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 15 Sep 2014 15:46:56 +0200 Subject: [PATCH 1/7] [ADD] account_banking_payment_blocking In the payment order creation wizard, do not propose invoices that are under litigation. This is based on the blocked (aka No Followup) flag on the account move lines. --- account_banking_payment_blocking/__init__.py | 23 ++++++++ .../__openerp__.py | 52 +++++++++++++++++++ .../model/__init__.py | 23 ++++++++ .../model/payment_order_create.py | 34 ++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 account_banking_payment_blocking/__init__.py create mode 100644 account_banking_payment_blocking/__openerp__.py create mode 100644 account_banking_payment_blocking/model/__init__.py create mode 100644 account_banking_payment_blocking/model/payment_order_create.py diff --git a/account_banking_payment_blocking/__init__.py b/account_banking_payment_blocking/__init__.py new file mode 100644 index 000000000..248eb311a --- /dev/null +++ b/account_banking_payment_blocking/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Blocking module for OpenERP +# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu) +# @author Stéphane Bidoul +# +# 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 . +# +############################################################################## + +import model diff --git a/account_banking_payment_blocking/__openerp__.py b/account_banking_payment_blocking/__openerp__.py new file mode 100644 index 000000000..024d79cf0 --- /dev/null +++ b/account_banking_payment_blocking/__openerp__.py @@ -0,0 +1,52 @@ +############################################################################## +# +# Copyright (C) ACSONE SA/NV () +# +# 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 . +# +############################################################################## +{ + 'name': 'account banking payment blocking', + 'version': '0.1', + 'category': 'Banking addons', + 'description': """ + Prevent invoices under litigation to be proposed in payment orders + """, + 'author': 'Stéphane Bidoul', + 'website': 'http://acsone.eu', + 'depends': [ + 'base', + 'account_banking_payment_export' + ], + 'data': [ + ], + 'test': [ + ], + 'demo': [ + ], + 'js': [ + ], + 'qweb': [ + ], + 'css': [ + ], + 'installable': True, + 'application': False, + 'auto_install': False, + 'license': 'AGPL-3', +} diff --git a/account_banking_payment_blocking/model/__init__.py b/account_banking_payment_blocking/model/__init__.py new file mode 100644 index 000000000..ae51395a6 --- /dev/null +++ b/account_banking_payment_blocking/model/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Blocking module for OpenERP +# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu) +# @author Stéphane Bidoul +# +# 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 . +# +############################################################################## + +import payment_order_create diff --git a/account_banking_payment_blocking/model/payment_order_create.py b/account_banking_payment_blocking/model/payment_order_create.py new file mode 100644 index 000000000..ef167886a --- /dev/null +++ b/account_banking_payment_blocking/model/payment_order_create.py @@ -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 +# +# 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 + + +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 From 9e76faa47895739e47831d0e720b407a548e3c80 Mon Sep 17 00:00:00 2001 From: Adrien Peiffer Date: Mon, 6 Oct 2014 16:56:16 +0200 Subject: [PATCH 2/7] [ADD] Add blocked field on supplier invoice --- .../__openerp__.py | 1 + .../model/__init__.py | 1 + .../model/account_invoice.py | 78 +++++++++++++++++++ .../view/account_invoice_view.xml | 15 ++++ 4 files changed, 95 insertions(+) create mode 100644 account_banking_payment_blocking/model/account_invoice.py create mode 100644 account_banking_payment_blocking/view/account_invoice_view.xml 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 From 6a78c9d72d123ff0f7b18e9e0b02dbd736bba365 Mon Sep 17 00:00:00 2001 From: Adrien Peiffer Date: Mon, 6 Oct 2014 16:56:33 +0200 Subject: [PATCH 3/7] [ADD] Add test for account banking payment blocking --- account_banking_payment_blocking/__init__.py | 1 + .../tests/__init__.py | 34 +++++++ .../test_account_banking_payment_blocking.py | 88 +++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 account_banking_payment_blocking/tests/__init__.py create mode 100644 account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py diff --git a/account_banking_payment_blocking/__init__.py b/account_banking_payment_blocking/__init__.py index 248eb311a..5e162df26 100644 --- a/account_banking_payment_blocking/__init__.py +++ b/account_banking_payment_blocking/__init__.py @@ -21,3 +21,4 @@ ############################################################################## import model +import tests diff --git a/account_banking_payment_blocking/tests/__init__.py b/account_banking_payment_blocking/tests/__init__.py new file mode 100644 index 000000000..c9d202606 --- /dev/null +++ b/account_banking_payment_blocking/tests/__init__.py @@ -0,0 +1,34 @@ +# -*- 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 . import test_account_banking_payment_blocking + +checks = [ + test_account_banking_payment_blocking, +] diff --git a/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py b/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py new file mode 100644 index 000000000..22cee1c64 --- /dev/null +++ b/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py @@ -0,0 +1,88 @@ +# -*- 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 . +# +# + +import openerp.tests.common as common +from openerp import netsvc + +DB = common.DB +ADMIN_USER_ID = common.ADMIN_USER_ID + + +def create_simple_invoice(self, cr, uid, context=None): + partner_id = self.ref('base.res_partner_2') + product_id = self.ref('product.product_product_4') + return self.registry('account.invoice')\ + .create(cr, uid, {'partner_id': partner_id, + 'account_id': + self.ref('account.a_recv'), + 'journal_id': + self.ref('account.expenses_journal'), + 'invoice_line': [(0, 0, {'name': 'test', + 'account_id': + self.ref('account.a_sale'), + 'price_unit': 2000.00, + 'quantity': 1, + 'product_id': product_id, + } + ) + ], + }) + + +class TestAccountBankingPaymentBlocking(common.TransactionCase): + + def setUp(self): + super(TestAccountBankingPaymentBlocking, self).setUp() + self.context = self.registry("res.users").context_get(self.cr, + self.uid) + + def test_invoice(self): + invoice_obj = self.registry('account.invoice') + move_line_obj = self.registry('account.move.line') + invoice_id = create_simple_invoice(self, self.cr, self.uid, + context=self.context) + netsvc.LocalService("workflow")\ + .trg_validate(self.uid, 'account.invoice', invoice_id, + 'invoice_open', self.cr) + invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id], + context=self.context)[0] + move_line_ids = move_line_obj\ + .search(self.cr, self.uid, [('account_id.type', 'in', + ['payable', 'receivable']), + ('invoice.id', '=', invoice.id)]) + move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0] + self.assertEqual(invoice.move_blocked, move_line.blocked, + 'Blocked values are not equals') + move_line_obj.write(self.cr, self.uid, move_line_ids, + {'blocked': True}) + invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id], + context=self.context)[0] + move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0] + self.assertEqual(invoice.move_blocked, move_line.blocked, + 'Blocked values are not equals') From 966e0c1cdd4464323d078c8a8d73a1514cdce949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 6 Oct 2014 18:57:50 +0200 Subject: [PATCH 4/7] [IMP] account_payment_blocking headers consistency, better description, better imports --- account_banking_payment_blocking/__init__.py | 4 ++-- .../__openerp__.py | 22 ++++++++++++------- .../model/__init__.py | 2 +- .../model/account_invoice.py | 19 +++++----------- .../tests/__init__.py | 19 +++++----------- .../test_account_banking_payment_blocking.py | 19 +++++----------- 6 files changed, 35 insertions(+), 50 deletions(-) diff --git a/account_banking_payment_blocking/__init__.py b/account_banking_payment_blocking/__init__.py index 5e162df26..aa439117c 100644 --- a/account_banking_payment_blocking/__init__.py +++ b/account_banking_payment_blocking/__init__.py @@ -20,5 +20,5 @@ # ############################################################################## -import model -import tests +from . import model +from . import tests diff --git a/account_banking_payment_blocking/__openerp__.py b/account_banking_payment_blocking/__openerp__.py index 7f882573b..1e591a504 100644 --- a/account_banking_payment_blocking/__openerp__.py +++ b/account_banking_payment_blocking/__openerp__.py @@ -1,10 +1,10 @@ +# -*- encoding: utf-8 -*- ############################################################################## # -# Copyright (C) ACSONE SA/NV () -# -# All other contributions are (C) by their respective contributors -# -# All Rights Reserved +# Account Payment Blocking module for OpenERP +# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu) +# @author Stéphane Bidoul +# @author Adrien Peiffer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -25,16 +25,22 @@ 'version': '0.1', 'category': 'Banking addons', 'description': """ - Prevent invoices under litigation to be proposed in payment orders + Prevent invoices under litigation to be proposed in payment orders. + + This module uses the 'blocked' flag that is present on move lines, + to filter out lines proposed in payment orders. + + In addition it exposes this flag on the supplier invoice form + so it is easier to block an invoice. """, - 'author': 'Stéphane Bidoul', + 'author': 'ACSONE SA/NV', 'website': 'http://acsone.eu', 'depends': [ 'base', 'account_banking_payment_export' ], 'data': [ - 'view/account_invoice_view.xml' + '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 437ba1cb6..0ef1a3c56 100644 --- a/account_banking_payment_blocking/model/__init__.py +++ b/account_banking_payment_blocking/model/__init__.py @@ -20,5 +20,5 @@ # ############################################################################## -import payment_order_create +from . 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 index ec83e5c73..dff5c8933 100644 --- a/account_banking_payment_blocking/model/account_invoice.py +++ b/account_banking_payment_blocking/model/account_invoice.py @@ -1,16 +1,9 @@ -# -*- coding: utf-8 -*- +# -*- encoding: 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. +# Account Payment Blocking module for OpenERP +# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu) +# @author Adrien Peiffer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -25,7 +18,7 @@ # 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 diff --git a/account_banking_payment_blocking/tests/__init__.py b/account_banking_payment_blocking/tests/__init__.py index c9d202606..625581235 100644 --- a/account_banking_payment_blocking/tests/__init__.py +++ b/account_banking_payment_blocking/tests/__init__.py @@ -1,16 +1,9 @@ -# -*- coding: utf-8 -*- +# -*- encoding: 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. +# Account Payment Blocking module for OpenERP +# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu) +# @author Adrien Peiffer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -25,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -# +############################################################################## from . import test_account_banking_payment_blocking diff --git a/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py b/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py index 22cee1c64..e1b3498d1 100644 --- a/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py +++ b/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py @@ -1,16 +1,9 @@ -# -*- coding: utf-8 -*- +# -*- encoding: 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. +# Account Payment Blocking module for OpenERP +# Copyright (C) 2014 ACSONE SA/NV (http://acsone.eu) +# @author Adrien Peiffer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -25,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -# +############################################################################## import openerp.tests.common as common from openerp import netsvc From b767cad840210d9bf39a96e421ae0408ff5b077d Mon Sep 17 00:00:00 2001 From: Adrien Peiffer Date: Tue, 7 Oct 2014 11:21:40 +0200 Subject: [PATCH 5/7] [IMP] account_banking_payment_blocking refactoring --- .../model/account_invoice.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/account_banking_payment_blocking/model/account_invoice.py b/account_banking_payment_blocking/model/account_invoice.py index dff5c8933..2c7dbf056 100644 --- a/account_banking_payment_blocking/model/account_invoice.py +++ b/account_banking_payment_blocking/model/account_invoice.py @@ -26,22 +26,26 @@ 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_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)]) + 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}) - move_line_obj.write(cr, uid, move_line_ids, - {'blocked': field_value}, context=context) + 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 = {} @@ -49,14 +53,11 @@ class account_invoice(orm.Model): 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)]) + move_line_ids = self._get_move_line(cr, uid, invoice.id, + context=context) assert len(move_line_ids) == 1 - move_line = move_line_obj.browse(cr, uid, move_line_ids, - context=context)[0] + 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 From 8c8f9b54f48e09714b2f91cfa12ddc2d1af3c4c7 Mon Sep 17 00:00:00 2001 From: Adrien Peiffer Date: Tue, 7 Oct 2014 11:25:03 +0200 Subject: [PATCH 6/7] [IMP] rename move_blocked field to blocked --- .../model/account_invoice.py | 10 +++++----- .../tests/test_account_banking_payment_blocking.py | 4 ++-- .../view/account_invoice_view.xml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/account_banking_payment_blocking/model/account_invoice.py b/account_banking_payment_blocking/model/account_invoice.py index 2c7dbf056..5632c922f 100644 --- a/account_banking_payment_blocking/model/account_invoice.py +++ b/account_banking_payment_blocking/model/account_invoice.py @@ -64,9 +64,9 @@ class account_invoice(orm.Model): 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)]}), + '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/tests/test_account_banking_payment_blocking.py b/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py index e1b3498d1..5551580c0 100644 --- a/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py +++ b/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py @@ -70,12 +70,12 @@ class TestAccountBankingPaymentBlocking(common.TransactionCase): ['payable', 'receivable']), ('invoice.id', '=', invoice.id)]) move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0] - self.assertEqual(invoice.move_blocked, move_line.blocked, + self.assertEqual(invoice.blocked, move_line.blocked, 'Blocked values are not equals') move_line_obj.write(self.cr, self.uid, move_line_ids, {'blocked': True}) invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id], context=self.context)[0] move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0] - self.assertEqual(invoice.move_blocked, move_line.blocked, + self.assertEqual(invoice.blocked, move_line.blocked, 'Blocked values are not equals') diff --git a/account_banking_payment_blocking/view/account_invoice_view.xml b/account_banking_payment_blocking/view/account_invoice_view.xml index 86601a49a..09e6a1ba8 100644 --- a/account_banking_payment_blocking/view/account_invoice_view.xml +++ b/account_banking_payment_blocking/view/account_invoice_view.xml @@ -7,7 +7,7 @@ - + From d82e0d56d3d05c450cde9b4f450e89618d119fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sat, 21 Mar 2015 19:50:34 +0100 Subject: [PATCH 7/7] [REN] account_banking_payment_blocking -> account_payment_blocking --- .../__init__.py | 0 .../__openerp__.py | 0 .../model/__init__.py | 0 .../model/account_invoice.py | 0 .../model/payment_order_create.py | 0 .../tests/__init__.py | 0 .../tests/test_account_banking_payment_blocking.py | 0 .../view/account_invoice_view.xml | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename {account_banking_payment_blocking => account_payment_blocking}/__init__.py (100%) rename {account_banking_payment_blocking => account_payment_blocking}/__openerp__.py (100%) rename {account_banking_payment_blocking => account_payment_blocking}/model/__init__.py (100%) rename {account_banking_payment_blocking => account_payment_blocking}/model/account_invoice.py (100%) rename {account_banking_payment_blocking => account_payment_blocking}/model/payment_order_create.py (100%) rename {account_banking_payment_blocking => account_payment_blocking}/tests/__init__.py (100%) rename {account_banking_payment_blocking => account_payment_blocking}/tests/test_account_banking_payment_blocking.py (100%) rename {account_banking_payment_blocking => account_payment_blocking}/view/account_invoice_view.xml (100%) diff --git a/account_banking_payment_blocking/__init__.py b/account_payment_blocking/__init__.py similarity index 100% rename from account_banking_payment_blocking/__init__.py rename to account_payment_blocking/__init__.py diff --git a/account_banking_payment_blocking/__openerp__.py b/account_payment_blocking/__openerp__.py similarity index 100% rename from account_banking_payment_blocking/__openerp__.py rename to account_payment_blocking/__openerp__.py diff --git a/account_banking_payment_blocking/model/__init__.py b/account_payment_blocking/model/__init__.py similarity index 100% rename from account_banking_payment_blocking/model/__init__.py rename to account_payment_blocking/model/__init__.py diff --git a/account_banking_payment_blocking/model/account_invoice.py b/account_payment_blocking/model/account_invoice.py similarity index 100% rename from account_banking_payment_blocking/model/account_invoice.py rename to account_payment_blocking/model/account_invoice.py diff --git a/account_banking_payment_blocking/model/payment_order_create.py b/account_payment_blocking/model/payment_order_create.py similarity index 100% rename from account_banking_payment_blocking/model/payment_order_create.py rename to account_payment_blocking/model/payment_order_create.py diff --git a/account_banking_payment_blocking/tests/__init__.py b/account_payment_blocking/tests/__init__.py similarity index 100% rename from account_banking_payment_blocking/tests/__init__.py rename to account_payment_blocking/tests/__init__.py diff --git a/account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py b/account_payment_blocking/tests/test_account_banking_payment_blocking.py similarity index 100% rename from account_banking_payment_blocking/tests/test_account_banking_payment_blocking.py rename to account_payment_blocking/tests/test_account_banking_payment_blocking.py diff --git a/account_banking_payment_blocking/view/account_invoice_view.xml b/account_payment_blocking/view/account_invoice_view.xml similarity index 100% rename from account_banking_payment_blocking/view/account_invoice_view.xml rename to account_payment_blocking/view/account_invoice_view.xml