From 762419f037f0853edce332d06e2076a76da25b48 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 4 Jul 2014 17:59:13 +0200 Subject: [PATCH] Add module account_invoice_picking_label. --- account_invoice_picking_label/__init__.py | 23 ++++++++ account_invoice_picking_label/__openerp__.py | 42 +++++++++++++++ .../account_invoice.py | 52 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 account_invoice_picking_label/__init__.py create mode 100644 account_invoice_picking_label/__openerp__.py create mode 100644 account_invoice_picking_label/account_invoice.py diff --git a/account_invoice_picking_label/__init__.py b/account_invoice_picking_label/__init__.py new file mode 100644 index 0000000..f2bf598 --- /dev/null +++ b/account_invoice_picking_label/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Invoice Picking Label module for OpenERP +# Copyright (C) 2013-2014 Akretion +# @author: Alexis de Lattre +# +# 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 account_invoice diff --git a/account_invoice_picking_label/__openerp__.py b/account_invoice_picking_label/__openerp__.py new file mode 100644 index 0000000..3ef98b0 --- /dev/null +++ b/account_invoice_picking_label/__openerp__.py @@ -0,0 +1,42 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Invoice Picking Label module for OpenERP +# Copyright (C) 2014 Akretion +# @author: Alexis de Lattre +# +# 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 Invoice Picking Label', + 'version': '0.1', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Adds field picking_ids_label on account.invoice', + 'description': """ +Account Invoice Picking Label +============================= + +Adds a function field named *picking_ids_label* on invoices. This field contains the list of pickings related to the invoice as a string. This field is designed to be displayed in the invoice report.""", + 'author': 'Akretion', + 'website': 'http://www.akretion.com/', + 'depends': ['stock_account'], + 'data': [], + 'installable': True, + 'active': False, +} + diff --git a/account_invoice_picking_label/account_invoice.py b/account_invoice_picking_label/account_invoice.py new file mode 100644 index 0000000..c150191 --- /dev/null +++ b/account_invoice_picking_label/account_invoice.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Invoice Picking Label module for OpenERP +# Copyright (C) 2013-2014 Akretion +# @author: Alexis de Lattre +# +# 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 _compute_picking_ids_label( + self, cr, uid, ids, name, arg, context=None): + res = {} + for invoice in self.read( + cr, uid, ids, ['picking_ids'], context=context): + label = '' + if invoice['picking_ids']: + pickings = self.pool['stock.picking'].read( + cr, uid, invoice['picking_ids'], ['name'], + context=context) + first = True + for picking in pickings: + if first: + label += picking['name'] + first = False + else: + label += ', %s' % picking['name'] + res[invoice['id']] = label + return res + + _columns = { + 'picking_ids_label': fields.function( + _compute_picking_ids_label, type='char', string='Pickings'), + }