From 21be8c48b1c4fedf5464c72ef9ff3300e04322d2 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Tue, 15 Oct 2013 17:40:02 +0200 Subject: [PATCH 01/34] [ADD] account_invoice_production_lot copied from https://code.launchpad.net/~agilebg/account-invoicing/adding_account_invoice_production_lot_7 --- account_invoice_production_lot/__init__.py | 24 ++++++ account_invoice_production_lot/__openerp__.py | 49 ++++++++++++ .../i18n/account_invoice_production_lot.pot | 53 +++++++++++++ account_invoice_production_lot/i18n/it.po | 52 ++++++++++++ account_invoice_production_lot/invoice.py | 79 +++++++++++++++++++ .../invoice_view.xml | 26 ++++++ account_invoice_production_lot/test/sale.yml | 77 ++++++++++++++++++ 7 files changed, 360 insertions(+) create mode 100644 account_invoice_production_lot/__init__.py create mode 100644 account_invoice_production_lot/__openerp__.py create mode 100644 account_invoice_production_lot/i18n/account_invoice_production_lot.pot create mode 100644 account_invoice_production_lot/i18n/it.po create mode 100644 account_invoice_production_lot/invoice.py create mode 100644 account_invoice_production_lot/invoice_view.xml create mode 100644 account_invoice_production_lot/test/sale.yml diff --git a/account_invoice_production_lot/__init__.py b/account_invoice_production_lot/__init__.py new file mode 100644 index 000000000..7fbabcdd4 --- /dev/null +++ b/account_invoice_production_lot/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Author: Lorenzo Battistini +# Copyright (C) 2011 Domsense s.r.l. (). +# Copyright (C) 2013 Agile Business Group sagl () +# +# 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 invoice diff --git a/account_invoice_production_lot/__openerp__.py b/account_invoice_production_lot/__openerp__.py new file mode 100644 index 000000000..a9c8e3155 --- /dev/null +++ b/account_invoice_production_lot/__openerp__.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Author: Lorenzo Battistini +# Copyright (C) 2011 Domsense s.r.l. (). +# Copyright (C) 2013 Agile Business Group sagl () +# +# 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": "Invoice Production Lots", + "version": "1.1", + 'category': 'Generic Modules/Accounting', + "depends": [ + "sale_stock", + "invoice_webkit", + ], + "author": "Agile Business Group", + "summary": "Display delivered serial numbers in invoice", + "description": """ +This module prints, for each (customer) invoice line, the delivered production +lots. The serial numbers are displayed in the "formatted note" field, +introduced by invoice_webkit module""", + 'website': 'http://www.agilebg.com', + 'data': [ + 'invoice_view.xml', + ], + 'demo': [], + 'test': [ + 'test/sale.yml', + ], + 'installable': True, + 'active': False, +} diff --git a/account_invoice_production_lot/i18n/account_invoice_production_lot.pot b/account_invoice_production_lot/i18n/account_invoice_production_lot.pot new file mode 100644 index 000000000..afdbbcb7b --- /dev/null +++ b/account_invoice_production_lot/i18n/account_invoice_production_lot.pot @@ -0,0 +1,53 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_invoice_production_lot +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-08-23 08:50+0000\n" +"PO-Revision-Date: 2013-08-23 08:50+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_invoice_production_lot +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: account_invoice_production_lot +#: view:account.invoice:0 +msgid "Load Lines Lots" +msgstr "" + +#. module: account_invoice_production_lot +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice_line +msgid "Invoice Line" +msgstr "" + +#. module: account_invoice_production_lot +#: field:account.invoice.line,displayed_lot_id:0 +msgid "Lot" +msgstr "" + +#. module: account_invoice_production_lot +#: view:account.invoice.line:0 +#: field:account.invoice.line,prod_lot_ids:0 +msgid "Production Lots" +msgstr "" + +#. module: account_invoice_production_lot +#: field:account.invoice.line,order_lines:0 +msgid "Order Lines" +msgstr "" + +#. module: account_invoice_production_lot +#: view:account.invoice:0 +msgid "This will overwrite the formatted note. Continue?" +msgstr "" + diff --git a/account_invoice_production_lot/i18n/it.po b/account_invoice_production_lot/i18n/it.po new file mode 100644 index 000000000..bd744d05e --- /dev/null +++ b/account_invoice_production_lot/i18n/it.po @@ -0,0 +1,52 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_invoice_production_lot +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-08-23 08:49+0000\n" +"PO-Revision-Date: 2013-08-23 10:51+0100\n" +"Last-Translator: Lorenzo Battistini \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.5.4\n" + +#. module: account_invoice_production_lot +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice +msgid "Invoice" +msgstr "Fattura" + +#. module: account_invoice_production_lot +#: view:account.invoice:0 +msgid "Load Lines Lots" +msgstr "Carica i lotti delle righe" + +#. module: account_invoice_production_lot +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice_line +msgid "Invoice Line" +msgstr "Righe Fattura" + +#. module: account_invoice_production_lot +#: field:account.invoice.line,displayed_lot_id:0 +msgid "Lot" +msgstr "Lotto" + +#. module: account_invoice_production_lot +#: view:account.invoice.line:0 field:account.invoice.line,prod_lot_ids:0 +msgid "Production Lots" +msgstr "Lotti di produzione" + +#. module: account_invoice_production_lot +#: field:account.invoice.line,order_lines:0 +msgid "Order Lines" +msgstr "Righe ordine" + +#. module: account_invoice_production_lot +#: view:account.invoice:0 +msgid "This will overwrite the formatted note. Continue?" +msgstr "Questo sovrascriverà la note formattate. Continuare?" diff --git a/account_invoice_production_lot/invoice.py b/account_invoice_production_lot/invoice.py new file mode 100644 index 000000000..2f4d866f0 --- /dev/null +++ b/account_invoice_production_lot/invoice.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Author: Lorenzo Battistini +# Copyright (C) 2011 Domsense s.r.l. (). +# Copyright (C) 2013 Agile Business Group sagl () +# +# 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 fields, orm + + +class account_invoice_line(orm.Model): + + def _get_prod_lots(self, cr, uid, ids, field_name, arg, context=None): + result = {} + for line in self.browse(cr, uid, ids, context=context): + result[line.id] = [] + for order_line in line.order_lines: + for move in order_line.move_ids: + if move.prodlot_id: + result[line.id].append(move.prodlot_id.id) + return result + + _inherit = "account.invoice.line" + + _columns = { + # order_lines is the reverse of invoice_lines field of sale module + 'order_lines': fields.many2many( + 'sale.order.line', 'sale_order_line_invoice_rel', 'invoice_id', + 'order_line_id', 'Order Lines', readonly=True), + 'prod_lot_ids': fields.function( + _get_prod_lots, method=True, type='many2many', + relation="stock.production.lot", string="Production Lots"), + 'displayed_lot_id': fields.many2one('stock.production.lot', 'Lot'), + } + + def load_line_lots(self, cr, uid, ids, context=None): + for line in self.browse(cr, uid, ids, context): + if line.prod_lot_ids: + note = u'
    ' + note += u' '.join([ + u'
  • S/N {0}
  • '.format(lot.name) + for lot in line.prod_lot_ids + ]) + note += u'
' + line.write({'formatted_note': note}, context=context) + return True + + def create(self, cr, uid, vals, context=None): + res = super(account_invoice_line, self).create(cr, uid, vals, context) + if not vals.get('formatted_note'): + self.load_line_lots(cr, uid, [res], context) + return res + +class account_invoice(orm.Model): + + def load_lines_lots(self, cr, uid, ids, context=None): + invoices = self.browse(cr, uid, ids, context) + inv_line_obj = self.pool.get('account.invoice.line') + for invoice in invoices: + inv_line_obj.load_line_lots(cr, uid, [l.id for l in invoice.invoice_line], context) + return True + + _inherit = "account.invoice" diff --git a/account_invoice_production_lot/invoice_view.xml b/account_invoice_production_lot/invoice_view.xml new file mode 100644 index 000000000..820cfaac4 --- /dev/null +++ b/account_invoice_production_lot/invoice_view.xml @@ -0,0 +1,26 @@ + + + + + account.invoice.line.form.prod_lots + account.invoice.line + + + + + + + + + + account.invoice.form.load_button + account.invoice + + + +