[ADD] Add blocked field on supplier invoice

This commit is contained in:
Adrien Peiffer
2014-10-06 16:56:16 +02:00
committed by Adrien Peiffer (ACSONE)
parent 1ea580872d
commit 9e76faa478
4 changed files with 95 additions and 0 deletions

View File

@@ -34,6 +34,7 @@
'account_banking_payment_export'
],
'data': [
'view/account_invoice_view.xml'
],
'test': [
],

View File

@@ -21,3 +21,4 @@
##############################################################################
import payment_order_create
from . import account_invoice

View File

@@ -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 <http://www.gnu.org/licenses/>.
#
#
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)]}),
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="invoice_supplier_form" model="ir.ui.view">
<field name="name">account.invoice.supplier.form (account_banking_payment_blocking)</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<field name="move_id" position="after">
<field name="move_blocked"/>
</field>
</field>
</record>
</data>
</openerp>