Merge lp:~vauxoo/addons-vauxoo/7.0-invoice_report_per_journal-dev_sabrina into lp:addons-vauxoo/7.0

Proposed by Sabrina Romero - http://www.vauxoo.com
Status: Merged
Merged at revision: 1054
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-invoice_report_per_journal-dev_sabrina
Merge into: lp:addons-vauxoo/7.0
Diff against target: 766 lines (+677/-0)
16 files modified
invoice_report_per_journal/__init__.py (+27/-0)
invoice_report_per_journal/__openerp__.py (+60/-0)
invoice_report_per_journal/data/data.xml (+75/-0)
invoice_report_per_journal/i18n/invoice_report_per_journal.pot (+73/-0)
invoice_report_per_journal/model/__init__.py (+25/-0)
invoice_report_per_journal/model/account_journal.py (+40/-0)
invoice_report_per_journal/report/__init__.py (+25/-0)
invoice_report_per_journal/report/invoice_report_demo.mako (+21/-0)
invoice_report_per_journal/report/invoice_report_demo.py (+52/-0)
invoice_report_per_journal/report/invoice_report_demo.xml (+20/-0)
invoice_report_per_journal/test/invoice_report_per_journal.yml (+62/-0)
invoice_report_per_journal/view/account_invoice_view.xml (+15/-0)
invoice_report_per_journal/view/account_journal_view.xml (+15/-0)
invoice_report_per_journal/wizard/__init__.py (+25/-0)
invoice_report_per_journal/wizard/invoice_report_per_journal.py (+111/-0)
invoice_report_per_journal/wizard/invoice_report_per_journal.xml (+31/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-invoice_report_per_journal-dev_sabrina

Description of the change

Module invoice_report_per_journal added.
This module adds a "Report" field on the journal model and a "Print Invoice" button on the customer invoices view which calls a wizard to print an invoice on a report per journal enviroment.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'invoice_report_per_journal'
=== added file 'invoice_report_per_journal/__init__.py'
--- invoice_report_per_journal/__init__.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/__init__.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,27 @@
1# -*- encoding: utf-8 -*- #
2############################################################################
3# Module Writen to OpenERP, Open Source Management Solution #
4# Copyright (C) Vauxoo (<http://vauxoo.com>). #
5# All Rights Reserved #
6###############Credits######################################################
7# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
8# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
9# Finance by: COMPANY NAME <EMAIL-COMPANY> #
10# Audited by: author NAME LASTNAME <email@vauxoo.com> #
11############################################################################
12# This program is free software: you can redistribute it and/or modify #
13# it under the terms of the GNU General Public License as published by #
14# the Free Software Foundation, either version 3 of the License, or #
15# (at your option) any later version. #
16# #
17# This program is distributed in the hope that it will be useful, #
18# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20# GNU General Public License for more details. #
21# #
22# You should have received a copy of the GNU General Public License #
23# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24############################################################################
25import model
26import wizard
27import report
028
=== added file 'invoice_report_per_journal/__openerp__.py'
--- invoice_report_per_journal/__openerp__.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/__openerp__.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,60 @@
1# -*- encoding: utf-8 -*- #
2############################################################################
3# Module Writen to OpenERP, Open Source Management Solution #
4# Copyright (C) Vauxoo (<http://vauxoo.com>). #
5# All Rights Reserved #
6###############Credits######################################################
7# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
8# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
9# Finance by: COMPANY NAME <EMAIL-COMPANY> #
10# Audited by: author NAME LASTNAME <email@vauxoo.com> #
11############################################################################
12# This program is free software: you can redistribute it and/or modify #
13# it under the terms of the GNU General Public License as published by #
14# the Free Software Foundation, either version 3 of the License, or #
15# (at your option) any later version. #
16# #
17# This program is distributed in the hope that it will be useful, #
18# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20# GNU General Public License for more details. #
21# #
22# You should have received a copy of the GNU General Public License #
23# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24############################################################################
25
26{
27 "name" : "Account Invoice Per Journal Report",
28 "version" : "1.0",
29 "author" : "Vauxoo",
30 "category" : "Generic Modules",
31 "description" :
32 """
33Adds a "Report" field on the journal model and a "Print Invoice" button on the customer invoices view which calls
34a wizard to print an invoice on a report per journal enviroment.
35
36This module allows the generation of txt reports using the following convention:
37
38* Must be a report wizard type to return the txt report.
39* The report wizard type must have the same name as his counterpart in pdf format concatenating the following string ' txt' in the report name.
40
41In this way the module generates both reports, making available for download the report txt.
42 """,
43 "website" : "http://www.vauxoo.com/",
44 "license" : "AGPL-3",
45 "depends" : ["account", "report_webkit"
46 ],
47 "demo" : [],
48 "data" : [
49 "data/data.xml",
50 "view/account_journal_view.xml",
51 "wizard/invoice_report_per_journal.xml",
52 "view/account_invoice_view.xml",
53 "report/invoice_report_demo.xml",
54 ],
55 'test': [
56 'test/invoice_report_per_journal.yml'
57 ],
58 "installable" : True,
59 "active" : False,
60}
061
=== added directory 'invoice_report_per_journal/data'
=== added file 'invoice_report_per_journal/data/data.xml'
--- invoice_report_per_journal/data/data.xml 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/data/data.xml 2014-06-12 15:03:58 +0000
@@ -0,0 +1,75 @@
1<?xml version="1.0" ?>
2<openerp>
3 <data noupdate="0">
4 <record id="ir_header_webkit_invoice_report_demo" model="ir.header_webkit">
5 <field name="footer_html"><![CDATA[<!DOCTYPE><html>
6 <head>
7 <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
8 <script>
9 function subst() {
10 var vars={};
11 var x=document.location.search.substring(1).split('&');
12 for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
13 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
14 for(var i in x) {
15 var y = document.getElementsByClassName(x[i]);
16 for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
17 }
18 }
19 </script>
20 </head>
21 <body style="border:0; margin: 0;" onload="subst()">
22 <table style="border-top: 1px solid black; width: 100%">
23 <tr >
24 <td style="text-align:right;font-size:9;" width="35%">Generado con software libre en OpenERP y Webkit por http://www.vauxoo.com</td>
25 <td style="text-align:right;font-size:12;" width="55%">Page <span class="page"/></td><td style="text-align:left;font-size:12;"> of <span class="topage"/></td>
26 </tr>
27 </table>
28 </body>
29</html>]]></field>
30 <field name="orientation">Portrait</field>
31 <field name="format">Letter</field>
32 <field name="html"><![CDATA[<!DOCTYPE><html>
33 <head>
34 <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
35 <script>
36 function subst() {
37 var vars={};
38 var x=document.location.search.substring(1).split('&');
39 for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
40 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
41 for(var i in x) {
42 var y = document.getElementsByClassName(x[i]);
43 for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
44 }
45 }
46 </script>
47 <style type="text/css">
48 ${css}
49 </style>
50 </head>
51 <body style="border:0; margin: 0;" onload="subst()">
52 ${_debug or ''|n} </body>
53</html>]]>
54</field>
55 <field eval="0.0" name="margin_top"/>
56 <field name="css" ><![CDATA[
57
58body{
59font-family:helvetica;
60font-size:9;
61margin:0;
62padding:0;
63height:100%;
64line-height:12px;
65}
66
67]]> </field>
68 <field name="name">Invoice Demo Report</field>
69 </record>
70 <record id="ir_header_img_companylogo0" model="ir.header_img">
71 <field eval="&quot;&quot;&quot;jpg&quot;&quot;&quot;" name="type"/>
72 <field eval="&quot;&quot;&quot;company_logo&quot;&quot;&quot;" name="name"/>
73 </record>
74 </data>
75</openerp>
076
=== added directory 'invoice_report_per_journal/demo'
=== added directory 'invoice_report_per_journal/i18n'
=== added file 'invoice_report_per_journal/i18n/invoice_report_per_journal.pot'
--- invoice_report_per_journal/i18n/invoice_report_per_journal.pot 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/i18n/invoice_report_per_journal.pot 2014-06-12 15:03:58 +0000
@@ -0,0 +1,73 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * invoice_report_per_journal
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-06-10 18:42+0000\n"
10"PO-Revision-Date: 2014-06-10 18:42+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: invoice_report_per_journal
19#: code:addons/invoice_report_per_journal/wizard/invoice_report_per_journal.py:43
20#, python-format
21msgid "ERROR !"
22msgstr ""
23
24#. module: invoice_report_per_journal
25#: code:addons/invoice_report_per_journal/wizard/invoice_report_per_journal.py:43
26#, python-format
27msgid "There is no journal configured for this invoice."
28msgstr ""
29
30#. module: invoice_report_per_journal
31#: report:addons/invoice_report_per_journal/report/invoice_report_demo.mako:14
32#: model:ir.actions.report.xml,name:invoice_report_per_journal.invoice_report_demo
33msgid "Invoice Demo Report"
34msgstr ""
35
36#. module: invoice_report_per_journal
37#: field:invoice.report.per.journal,journal:0
38#: model:ir.model,name:invoice_report_per_journal.model_account_journal
39msgid "Journal"
40msgstr ""
41
42#. module: invoice_report_per_journal
43#: field:invoice.report.per.journal,report_format:0
44msgid "Report"
45msgstr ""
46
47#. module: invoice_report_per_journal
48#: view:invoice.report.per.journal:0
49#: model:ir.actions.act_window,name:invoice_report_per_journal.invoice_report_per_journal
50msgid "Print"
51msgstr ""
52
53#. module: invoice_report_per_journal
54#: field:account.journal,invoice_report_id:0
55msgid "Invoice Report"
56msgstr ""
57
58#. module: invoice_report_per_journal
59#: view:invoice.report.per.journal:0
60msgid "Cancel"
61msgstr ""
62
63#. module: invoice_report_per_journal
64#: model:ir.model,name:invoice_report_per_journal.model_invoice_report_per_journal
65msgid "invoice.report.per.journal"
66msgstr ""
67
68#. module: invoice_report_per_journal
69#: view:account.invoice:0
70#: view:invoice.report.per.journal:0
71msgid "Print Invoice"
72msgstr ""
73
074
=== added directory 'invoice_report_per_journal/model'
=== added file 'invoice_report_per_journal/model/__init__.py'
--- invoice_report_per_journal/model/__init__.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/model/__init__.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,25 @@
1# -*- encoding: utf-8 -*- #
2############################################################################
3# Module Writen to OpenERP, Open Source Management Solution #
4# Copyright (C) Vauxoo (<http://vauxoo.com>). #
5# All Rights Reserved #
6###############Credits######################################################
7# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
8# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
9# Finance by: COMPANY NAME <EMAIL-COMPANY> #
10# Audited by: author NAME LASTNAME <email@vauxoo.com> #
11############################################################################
12# This program is free software: you can redistribute it and/or modify #
13# it under the terms of the GNU General Public License as published by #
14# the Free Software Foundation, either version 3 of the License, or #
15# (at your option) any later version. #
16# #
17# This program is distributed in the hope that it will be useful, #
18# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20# GNU General Public License for more details. #
21# #
22# You should have received a copy of the GNU General Public License #
23# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24############################################################################
25import account_journal
026
=== added file 'invoice_report_per_journal/model/account_journal.py'
--- invoice_report_per_journal/model/account_journal.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/model/account_journal.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,40 @@
1# -*- encoding: utf-8 -*- #
2############################################################################
3# Module Writen to OpenERP, Open Source Management Solution #
4# Copyright (C) Vauxoo (<http://vauxoo.com>). #
5# All Rights Reserved #
6###############Credits######################################################
7# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
8# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
9# Finance by: COMPANY NAME <EMAIL-COMPANY> #
10# Audited by: author NAME LASTNAME <email@vauxoo.com> #
11############################################################################
12# This program is free software: you can redistribute it and/or modify #
13# it under the terms of the GNU General Public License as published by #
14# the Free Software Foundation, either version 3 of the License, or #
15# (at your option) any later version. #
16# #
17# This program is distributed in the hope that it will be useful, #
18# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20# GNU General Public License for more details. #
21# #
22# You should have received a copy of the GNU General Public License #
23# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24############################################################################
25
26from openerp.osv import fields, osv
27from openerp.tools.translate import _
28
29
30class invoice_report_per_journal(osv.Model):
31 """
32 invoice_report_per_journal
33 """
34
35 _inherit = 'account.journal'
36 _columns = {
37 'invoice_report_id': fields.many2one('ir.actions.report.xml',
38 'Invoice Report', required=False,
39 domain="[('model','=','account.invoice')]"),
40 }
041
=== added directory 'invoice_report_per_journal/report'
=== added file 'invoice_report_per_journal/report/__init__.py'
--- invoice_report_per_journal/report/__init__.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/report/__init__.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,25 @@
1# -*- encoding: utf-8 -*- #
2############################################################################
3# Module Writen to OpenERP, Open Source Management Solution #
4# Copyright (C) Vauxoo (<http://vauxoo.com>). #
5# All Rights Reserved #
6###############Credits######################################################
7# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
8# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
9# Finance by: COMPANY NAME <EMAIL-COMPANY> #
10# Audited by: author NAME LASTNAME <email@vauxoo.com> #
11############################################################################
12# This program is free software: you can redistribute it and/or modify #
13# it under the terms of the GNU General Public License as published by #
14# the Free Software Foundation, either version 3 of the License, or #
15# (at your option) any later version. #
16# #
17# This program is distributed in the hope that it will be useful, #
18# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20# GNU General Public License for more details. #
21# #
22# You should have received a copy of the GNU General Public License #
23# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24############################################################################
25import invoice_report_demo
026
=== added file 'invoice_report_per_journal/report/invoice_report_demo.mako'
--- invoice_report_per_journal/report/invoice_report_demo.mako 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/report/invoice_report_demo.mako 2014-06-12 15:03:58 +0000
@@ -0,0 +1,21 @@
1<!DOCTYPE>
2<html>
3<head>
4 <style type="text/css">
5 ${css}
6 </style>
7</head>
8<body>
9 %for o in objects :
10 <table>
11 <tr>
12 <td>
13 <div>
14 ${_("Invoice Demo Report")}
15 </div>
16 </td>
17 </tr>
18 </table>
19 %endfor
20</body>
21</html>
022
=== added file 'invoice_report_per_journal/report/invoice_report_demo.py'
--- invoice_report_per_journal/report/invoice_report_demo.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/report/invoice_report_demo.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,52 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com/
6# All Rights Reserved.
7# info Vauxoo (info@vauxoo.com)
8############################################################################
9# Coded by: Luis Torres (luis_t@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26
27from openerp.report import report_sxw
28from openerp import pooler
29from openerp.tools.translate import _
30from openerp import tools
31from openerp import tests
32from openerp.osv import osv
33from openerp import netsvc
34import openerp
35from report_webkit import webkit_report
36import datetime
37
38class invoice_report_demo_html(report_sxw.rml_parse):
39 def __init__(self, cr, uid, name, context=None):
40 if context is None:
41 context = {}
42 super(invoice_report_demo_html, self).__init__(
43 cr, uid, name, context=context)
44 self.localcontext.update({
45 })
46
47webkit_report.WebKitParser('report.invoice.report.demo.webkit',
48 'account.invoice',
49 'addons/invoice_report_per_journal/report/invoice_report_demo.mako',
50 parser=invoice_report_demo_html)
51
52# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
053
=== added file 'invoice_report_per_journal/report/invoice_report_demo.xml'
--- invoice_report_per_journal/report/invoice_report_demo.xml 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/report/invoice_report_demo.xml 2014-06-12 15:03:58 +0000
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <report auto="False"
5 menu="False"
6 id="invoice_report_demo"
7 model="account.invoice"
8 name="invoice.report.demo.webkit"
9 file="invoice_report_per_journal/report/invoice_report_demo.mako"
10 string="Invoice Demo Report"
11 report_type="webkit"/>
12
13 <record id="property_invoice_report_demo_webkit" model="ir.property">
14 <field name="name">webkit_header</field>
15 <field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
16 <field eval="'ir.header_webkit,'+str(ref('invoice_report_per_journal.ir_header_webkit_invoice_report_demo'))" model="ir.header_webkit" name="value"/>
17 <field eval="'ir.actions.report.xml,'+str(ref('invoice_report_per_journal.invoice_report_demo'))" model="ir.actions.report.xml" name="res_id"/>
18 </record>
19 </data>
20</openerp>
021
=== added directory 'invoice_report_per_journal/security'
=== added directory 'invoice_report_per_journal/test'
=== added file 'invoice_report_per_journal/test/invoice_report_per_journal.yml'
--- invoice_report_per_journal/test/invoice_report_per_journal.yml 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/test/invoice_report_per_journal.yml 2014-06-12 15:03:58 +0000
@@ -0,0 +1,62 @@
1-
2 Reports Per Journal On Invoice Tests
3-
4 1.- In order to test reports per journal on invoices, we will test the wizard without a report assigned in the journal
5-
6 1.1.- I create a customer invoice
7-
8 !record {model: account.invoice, id: account_invoice_customer0 , view: account.invoice_form}: &account_invoice
9 payment_term: account.account_payment_term_advance
10 journal_id: account.sales_journal
11 partner_id: base.res_partner_3
12 reference_type: none
13 name: 'Test Customer Invoice'
14 invoice_line:
15 - product_id: product.product_product_5
16 quantity: 10.0
17 price_unit: 1
18-
19 1.2.- I overwrite the journal field (It is necessary overwrite the field to make it work! only in test yaml (BUG))
20-
21 !record {model: account.invoice, id: account_invoice_customer0, view: account.invoice_form}:
22 journal_id: account.sales_journal
23-
24 1.3.- I check that initially customer invoice state is "Draft"
25-
26 !assert {model: account.invoice, id: account_invoice_customer0}:
27 - state == 'draft'
28-
29 1.4.- I check that the customer invoice is a "Customer Invoice"
30-
31 !assert {model: account.invoice, id: account_invoice_customer0, string: This is not a customer invoice}:
32 - type == 'out_invoice'
33-
34 1.5.- I change the state of invoice to open by clicking Validate button
35-
36 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0}
37-
38 1.6.- I check that the invoice state is now "Open"
39-
40 !assert {model: account.invoice, id: account_invoice_customer0}:
41 - state == 'open'
42-
43 1.7.- I generate the default invoice report through the wizard
44-
45 !python {model: invoice.report.per.journal}: |
46 context={}
47 context.update({'active_model': 'account.invoice', 'active_ids': [ref('account_invoice_customer0')]})
48 self._get_journal(cr, uid, context)
49 self._get_report(cr, uid, context)
50-
51 2.- In order to test the report defined on an journal, we will set the Invoice Demo Report to the Sale Journal
52-
53 !python {model: account.journal}: |
54 self.write(cr, uid, [ref('account.sales_journal')], {'invoice_report_id': ref('invoice_report_per_journal.invoice_report_demo')})
55-
56 2.1.- I generate the report assigned in the journal through the wizard
57-
58 !python {model: invoice.report.per.journal}: |
59 context={}
60 context.update({'active_model': 'account.invoice', 'active_ids': [ref('account_invoice_customer0')]})
61 self._get_journal(cr, uid, context)
62 self._get_report(cr, uid, context)
063
=== added directory 'invoice_report_per_journal/view'
=== added file 'invoice_report_per_journal/view/account_invoice_view.xml'
--- invoice_report_per_journal/view/account_invoice_view.xml 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/view/account_invoice_view.xml 2014-06-12 15:03:58 +0000
@@ -0,0 +1,15 @@
1<?xml version='1.0' encoding='utf-8'?>
2<openerp>
3 <data>
4 <record model="ir.ui.view" id="view_invoice_report_per_journal_form_inherit">
5 <field name="name">invoice.report.per.journal.form</field>
6 <field name="model">account.invoice</field>
7 <field name="inherit_id" ref="account.invoice_form"/>
8 <field name="arch" type="xml">
9 <xpath expr="//button[@string='Print Invoice']" position="replace">
10 <button name="%(invoice_report_per_journal)d" string="Print Invoice" type="action" icon="gtk-print" states="open,paid,proforma,sale,proforma2"/>
11 </xpath>
12 </field>
13 </record>
14 </data>
15</openerp>
016
=== added file 'invoice_report_per_journal/view/account_journal_view.xml'
--- invoice_report_per_journal/view/account_journal_view.xml 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/view/account_journal_view.xml 2014-06-12 15:03:58 +0000
@@ -0,0 +1,15 @@
1<?xml version='1.0' encoding='utf-8'?>
2<openerp>
3 <data>
4 <record model="ir.ui.view" id="account_journal_form_inherit">
5 <field name="name">account.journal.form.inherit</field>
6 <field name="model">account.journal</field>
7 <field name="inherit_id" ref="account.view_account_journal_form"/>
8 <field name="arch" type="xml">
9 <field name="sequence_id" position="after">
10 <field name="invoice_report_id" attrs="{'invisible': [('type', 'not in', ('sale','sale_refund'))]}" />
11 </field>
12 </field>
13 </record>
14 </data>
15</openerp>
016
=== added directory 'invoice_report_per_journal/wizard'
=== added file 'invoice_report_per_journal/wizard/__init__.py'
--- invoice_report_per_journal/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/wizard/__init__.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,25 @@
1# -*- encoding: utf-8 -*- #
2############################################################################
3# Module Writen to OpenERP, Open Source Management Solution #
4# Copyright (C) Vauxoo (<http://vauxoo.com>). #
5# All Rights Reserved #
6###############Credits######################################################
7# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
8# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
9# Finance by: COMPANY NAME <EMAIL-COMPANY> #
10# Audited by: author NAME LASTNAME <email@vauxoo.com> #
11############################################################################
12# This program is free software: you can redistribute it and/or modify #
13# it under the terms of the GNU General Public License as published by #
14# the Free Software Foundation, either version 3 of the License, or #
15# (at your option) any later version. #
16# #
17# This program is distributed in the hope that it will be useful, #
18# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20# GNU General Public License for more details. #
21# #
22# You should have received a copy of the GNU General Public License #
23# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24############################################################################
25import invoice_report_per_journal
026
=== added file 'invoice_report_per_journal/wizard/invoice_report_per_journal.py'
--- invoice_report_per_journal/wizard/invoice_report_per_journal.py 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/wizard/invoice_report_per_journal.py 2014-06-12 15:03:58 +0000
@@ -0,0 +1,111 @@
1# -*- encoding: utf-8 -*- #
2############################################################################
3# Module Writen to OpenERP, Open Source Management Solution #
4# Copyright (C) Vauxoo (<http://vauxoo.com>). #
5# All Rights Reserved #
6###############Credits######################################################
7# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
8# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
9# Finance by: COMPANY NAME <EMAIL-COMPANY> #
10# Audited by: author NAME LASTNAME <email@vauxoo.com> #
11############################################################################
12# This program is free software: you can redistribute it and/or modify #
13# it under the terms of the GNU General Public License as published by #
14# the Free Software Foundation, either version 3 of the License, or #
15# (at your option) any later version. #
16# #
17# This program is distributed in the hope that it will be useful, #
18# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20# GNU General Public License for more details. #
21# #
22# You should have received a copy of the GNU General Public License #
23# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24############################################################################
25from openerp.osv import fields, osv
26from openerp.tools.translate import _
27
28import base64
29import openerp.netsvc as netsvc
30import logging
31_logger = logging.getLogger(__name__)
32
33class invoice_report_per_journal(osv.TransientModel):
34 """
35 OpenERP Wizard: invoice.report.per.journal
36 """
37 _name = "invoice.report.per.journal"
38
39 def get_journal_object(self, cr, uid, context=None):
40 record_brw = self.pool.get(context['active_model']).browse(
41 cr, uid, context['active_ids'][0])
42 if not record_brw.journal_id:
43 raise except_osv(_('ERROR !'), _(
44 'There is no journal configured for this invoice.'))
45 return record_brw.journal_id
46
47 def _get_journal(self, cr, uid, context=None):
48 return self.get_journal_object(cr, uid, context=context).name
49
50 def _prepare_service(self, cr, uid, report, context=None):
51 service = netsvc.LocalService('report.' + report.report_name)
52 (result, format) = service.create(cr, uid, context[
53 'active_ids'], {'model': context['active_model']}, {})
54 return (result, format)
55
56 def _get_report(self, cr, uid, context=None):
57 report = self.get_journal_object(
58 cr, uid, context=context).invoice_report_id
59 try:
60 (result, format) = self._prepare_service(cr, uid, report, context=context)
61 except:
62 if report:
63 _logger.warning("Error occurred in the report, the report set to the journal will be ignored.")
64 rep_id = self.pool.get("ir.actions.report.xml").search(
65 cr, uid, [('model', '=', 'account.invoice'),], order="id",
66 context=context)[0]
67 report_ = self.pool.get(
68 "ir.actions.report.xml").browse(cr, uid, rep_id, context=context)
69 (result, format) = self._prepare_service(cr, uid, report_, context=context)
70 try:
71 act_id = self.pool.get('ir.actions.act_window').search(cr, uid, [('name','=', report.name + ' txt')], context=context)[0]
72 if act_id:
73 act_brw = self.pool.get('ir.actions.act_window').browse(cr, uid, act_id, context=context)
74 wiz_obj = self.pool.get(act_brw.res_model)
75 wiz_id = wiz_obj.create(cr, uid, {}, context=context)
76 wiz_brw = wiz_obj.browse(cr, uid, wiz_id, context=context)
77 result = base64.decodestring(wiz_brw.fname_txt)
78 except:
79 if report:
80 _logger.info("txt report not defined for the report assigned to journal.")
81 return base64.encodestring(result)
82
83 def _get_report_name(self, cr, uid, context=None):
84 report = self.get_journal_object(cr, uid,
85 context=context).invoice_report_id
86 try:
87 (result, format) = self._prepare_service(cr, uid, report, context=context)
88 except:
89 if report:
90 _logger.warning("Error occurred in the report, the report set to the journal will be ignored.")
91 rep_id = self.pool.get("ir.actions.report.xml").search(
92 cr, uid, [('model', '=', 'account.invoice'),], order="id",
93 context=context)[0]
94 report = self.pool.get(
95 "ir.actions.report.xml").browse(cr, uid, rep_id, context=context)
96 return report.report_name
97
98 def print_invoice(self, cr, uid, ids, context=None):
99 return {'type': 'ir.actions.report.xml',
100 'report_name': self._get_report_name(cr, uid, context=context),
101 'datas': {'ids': context['active_ids']}}
102
103 _columns = {
104 'journal': fields.char('Journal', 64, readonly=True, requied=True),
105 'report_format': fields.binary("Report", readonly=True, required=True)
106 }
107
108 _defaults = {
109 'journal': _get_journal,
110 'report_format': _get_report,
111 }
0112
=== added file 'invoice_report_per_journal/wizard/invoice_report_per_journal.xml'
--- invoice_report_per_journal/wizard/invoice_report_per_journal.xml 1970-01-01 00:00:00 +0000
+++ invoice_report_per_journal/wizard/invoice_report_per_journal.xml 2014-06-12 15:03:58 +0000
@@ -0,0 +1,31 @@
1<?xml version='1.0' encoding='utf-8'?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="wizard_invoice_report_per_journal_form">
6 <field name="name">invoice.report.per.journal.form</field>
7 <field name="model">invoice.report.per.journal</field>
8 <field name="arch" type="xml">
9 <form string="Print" version="7.0">
10 <group col="4" colspan="4">
11 <field name="journal"/>
12 <newline/>
13 <field name="report_format"/>
14 <newline/>
15 <group col="2" colspan="2">
16 <button icon="gtk-cancel" special="cancel" string="Cancel"/>
17 <button icon="gtk-ok" name="print_invoice" type="object" string="Print Invoice"/>
18 </group>
19 </group>
20 </form>
21 </field>
22 </record>
23
24 <act_window id="invoice_report_per_journal"
25 key2="client_action_per" name="Print"
26 res_model="invoice.report.per.journal"
27 view_id="wizard_invoice_report_per_journal_form"
28 view_mode="form" target="new" view_type="form"/>
29
30 </data>
31</openerp>