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
1=== added directory 'invoice_report_per_journal'
2=== added file 'invoice_report_per_journal/__init__.py'
3--- invoice_report_per_journal/__init__.py 1970-01-01 00:00:00 +0000
4+++ invoice_report_per_journal/__init__.py 2014-06-12 15:03:58 +0000
5@@ -0,0 +1,27 @@
6+# -*- encoding: utf-8 -*- #
7+############################################################################
8+# Module Writen to OpenERP, Open Source Management Solution #
9+# Copyright (C) Vauxoo (<http://vauxoo.com>). #
10+# All Rights Reserved #
11+###############Credits######################################################
12+# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
13+# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
14+# Finance by: COMPANY NAME <EMAIL-COMPANY> #
15+# Audited by: author NAME LASTNAME <email@vauxoo.com> #
16+############################################################################
17+# This program is free software: you can redistribute it and/or modify #
18+# it under the terms of the GNU General Public License as published by #
19+# the Free Software Foundation, either version 3 of the License, or #
20+# (at your option) any later version. #
21+# #
22+# This program is distributed in the hope that it will be useful, #
23+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
24+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
25+# GNU General Public License for more details. #
26+# #
27+# You should have received a copy of the GNU General Public License #
28+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
29+############################################################################
30+import model
31+import wizard
32+import report
33
34=== added file 'invoice_report_per_journal/__openerp__.py'
35--- invoice_report_per_journal/__openerp__.py 1970-01-01 00:00:00 +0000
36+++ invoice_report_per_journal/__openerp__.py 2014-06-12 15:03:58 +0000
37@@ -0,0 +1,60 @@
38+# -*- encoding: utf-8 -*- #
39+############################################################################
40+# Module Writen to OpenERP, Open Source Management Solution #
41+# Copyright (C) Vauxoo (<http://vauxoo.com>). #
42+# All Rights Reserved #
43+###############Credits######################################################
44+# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
45+# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
46+# Finance by: COMPANY NAME <EMAIL-COMPANY> #
47+# Audited by: author NAME LASTNAME <email@vauxoo.com> #
48+############################################################################
49+# This program is free software: you can redistribute it and/or modify #
50+# it under the terms of the GNU General Public License as published by #
51+# the Free Software Foundation, either version 3 of the License, or #
52+# (at your option) any later version. #
53+# #
54+# This program is distributed in the hope that it will be useful, #
55+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
56+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
57+# GNU General Public License for more details. #
58+# #
59+# You should have received a copy of the GNU General Public License #
60+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
61+############################################################################
62+
63+{
64+ "name" : "Account Invoice Per Journal Report",
65+ "version" : "1.0",
66+ "author" : "Vauxoo",
67+ "category" : "Generic Modules",
68+ "description" :
69+ """
70+Adds a "Report" field on the journal model and a "Print Invoice" button on the customer invoices view which calls
71+a wizard to print an invoice on a report per journal enviroment.
72+
73+This module allows the generation of txt reports using the following convention:
74+
75+* Must be a report wizard type to return the txt report.
76+* The report wizard type must have the same name as his counterpart in pdf format concatenating the following string ' txt' in the report name.
77+
78+In this way the module generates both reports, making available for download the report txt.
79+ """,
80+ "website" : "http://www.vauxoo.com/",
81+ "license" : "AGPL-3",
82+ "depends" : ["account", "report_webkit"
83+ ],
84+ "demo" : [],
85+ "data" : [
86+ "data/data.xml",
87+ "view/account_journal_view.xml",
88+ "wizard/invoice_report_per_journal.xml",
89+ "view/account_invoice_view.xml",
90+ "report/invoice_report_demo.xml",
91+ ],
92+ 'test': [
93+ 'test/invoice_report_per_journal.yml'
94+ ],
95+ "installable" : True,
96+ "active" : False,
97+}
98
99=== added directory 'invoice_report_per_journal/data'
100=== added file 'invoice_report_per_journal/data/data.xml'
101--- invoice_report_per_journal/data/data.xml 1970-01-01 00:00:00 +0000
102+++ invoice_report_per_journal/data/data.xml 2014-06-12 15:03:58 +0000
103@@ -0,0 +1,75 @@
104+<?xml version="1.0" ?>
105+<openerp>
106+ <data noupdate="0">
107+ <record id="ir_header_webkit_invoice_report_demo" model="ir.header_webkit">
108+ <field name="footer_html"><![CDATA[<!DOCTYPE><html>
109+ <head>
110+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
111+ <script>
112+ function subst() {
113+ var vars={};
114+ var x=document.location.search.substring(1).split('&');
115+ for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
116+ var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
117+ for(var i in x) {
118+ var y = document.getElementsByClassName(x[i]);
119+ for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
120+ }
121+ }
122+ </script>
123+ </head>
124+ <body style="border:0; margin: 0;" onload="subst()">
125+ <table style="border-top: 1px solid black; width: 100%">
126+ <tr >
127+ <td style="text-align:right;font-size:9;" width="35%">Generado con software libre en OpenERP y Webkit por http://www.vauxoo.com</td>
128+ <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>
129+ </tr>
130+ </table>
131+ </body>
132+</html>]]></field>
133+ <field name="orientation">Portrait</field>
134+ <field name="format">Letter</field>
135+ <field name="html"><![CDATA[<!DOCTYPE><html>
136+ <head>
137+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
138+ <script>
139+ function subst() {
140+ var vars={};
141+ var x=document.location.search.substring(1).split('&');
142+ for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
143+ var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
144+ for(var i in x) {
145+ var y = document.getElementsByClassName(x[i]);
146+ for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
147+ }
148+ }
149+ </script>
150+ <style type="text/css">
151+ ${css}
152+ </style>
153+ </head>
154+ <body style="border:0; margin: 0;" onload="subst()">
155+ ${_debug or ''|n} </body>
156+</html>]]>
157+</field>
158+ <field eval="0.0" name="margin_top"/>
159+ <field name="css" ><![CDATA[
160+
161+body{
162+font-family:helvetica;
163+font-size:9;
164+margin:0;
165+padding:0;
166+height:100%;
167+line-height:12px;
168+}
169+
170+]]> </field>
171+ <field name="name">Invoice Demo Report</field>
172+ </record>
173+ <record id="ir_header_img_companylogo0" model="ir.header_img">
174+ <field eval="&quot;&quot;&quot;jpg&quot;&quot;&quot;" name="type"/>
175+ <field eval="&quot;&quot;&quot;company_logo&quot;&quot;&quot;" name="name"/>
176+ </record>
177+ </data>
178+</openerp>
179
180=== added directory 'invoice_report_per_journal/demo'
181=== added directory 'invoice_report_per_journal/i18n'
182=== added file 'invoice_report_per_journal/i18n/invoice_report_per_journal.pot'
183--- invoice_report_per_journal/i18n/invoice_report_per_journal.pot 1970-01-01 00:00:00 +0000
184+++ invoice_report_per_journal/i18n/invoice_report_per_journal.pot 2014-06-12 15:03:58 +0000
185@@ -0,0 +1,73 @@
186+# Translation of OpenERP Server.
187+# This file contains the translation of the following modules:
188+# * invoice_report_per_journal
189+#
190+msgid ""
191+msgstr ""
192+"Project-Id-Version: OpenERP Server 7.0\n"
193+"Report-Msgid-Bugs-To: \n"
194+"POT-Creation-Date: 2014-06-10 18:42+0000\n"
195+"PO-Revision-Date: 2014-06-10 18:42+0000\n"
196+"Last-Translator: <>\n"
197+"Language-Team: \n"
198+"MIME-Version: 1.0\n"
199+"Content-Type: text/plain; charset=UTF-8\n"
200+"Content-Transfer-Encoding: \n"
201+"Plural-Forms: \n"
202+
203+#. module: invoice_report_per_journal
204+#: code:addons/invoice_report_per_journal/wizard/invoice_report_per_journal.py:43
205+#, python-format
206+msgid "ERROR !"
207+msgstr ""
208+
209+#. module: invoice_report_per_journal
210+#: code:addons/invoice_report_per_journal/wizard/invoice_report_per_journal.py:43
211+#, python-format
212+msgid "There is no journal configured for this invoice."
213+msgstr ""
214+
215+#. module: invoice_report_per_journal
216+#: report:addons/invoice_report_per_journal/report/invoice_report_demo.mako:14
217+#: model:ir.actions.report.xml,name:invoice_report_per_journal.invoice_report_demo
218+msgid "Invoice Demo Report"
219+msgstr ""
220+
221+#. module: invoice_report_per_journal
222+#: field:invoice.report.per.journal,journal:0
223+#: model:ir.model,name:invoice_report_per_journal.model_account_journal
224+msgid "Journal"
225+msgstr ""
226+
227+#. module: invoice_report_per_journal
228+#: field:invoice.report.per.journal,report_format:0
229+msgid "Report"
230+msgstr ""
231+
232+#. module: invoice_report_per_journal
233+#: view:invoice.report.per.journal:0
234+#: model:ir.actions.act_window,name:invoice_report_per_journal.invoice_report_per_journal
235+msgid "Print"
236+msgstr ""
237+
238+#. module: invoice_report_per_journal
239+#: field:account.journal,invoice_report_id:0
240+msgid "Invoice Report"
241+msgstr ""
242+
243+#. module: invoice_report_per_journal
244+#: view:invoice.report.per.journal:0
245+msgid "Cancel"
246+msgstr ""
247+
248+#. module: invoice_report_per_journal
249+#: model:ir.model,name:invoice_report_per_journal.model_invoice_report_per_journal
250+msgid "invoice.report.per.journal"
251+msgstr ""
252+
253+#. module: invoice_report_per_journal
254+#: view:account.invoice:0
255+#: view:invoice.report.per.journal:0
256+msgid "Print Invoice"
257+msgstr ""
258+
259
260=== added directory 'invoice_report_per_journal/model'
261=== added file 'invoice_report_per_journal/model/__init__.py'
262--- invoice_report_per_journal/model/__init__.py 1970-01-01 00:00:00 +0000
263+++ invoice_report_per_journal/model/__init__.py 2014-06-12 15:03:58 +0000
264@@ -0,0 +1,25 @@
265+# -*- encoding: utf-8 -*- #
266+############################################################################
267+# Module Writen to OpenERP, Open Source Management Solution #
268+# Copyright (C) Vauxoo (<http://vauxoo.com>). #
269+# All Rights Reserved #
270+###############Credits######################################################
271+# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
272+# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
273+# Finance by: COMPANY NAME <EMAIL-COMPANY> #
274+# Audited by: author NAME LASTNAME <email@vauxoo.com> #
275+############################################################################
276+# This program is free software: you can redistribute it and/or modify #
277+# it under the terms of the GNU General Public License as published by #
278+# the Free Software Foundation, either version 3 of the License, or #
279+# (at your option) any later version. #
280+# #
281+# This program is distributed in the hope that it will be useful, #
282+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
283+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
284+# GNU General Public License for more details. #
285+# #
286+# You should have received a copy of the GNU General Public License #
287+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
288+############################################################################
289+import account_journal
290
291=== added file 'invoice_report_per_journal/model/account_journal.py'
292--- invoice_report_per_journal/model/account_journal.py 1970-01-01 00:00:00 +0000
293+++ invoice_report_per_journal/model/account_journal.py 2014-06-12 15:03:58 +0000
294@@ -0,0 +1,40 @@
295+# -*- encoding: utf-8 -*- #
296+############################################################################
297+# Module Writen to OpenERP, Open Source Management Solution #
298+# Copyright (C) Vauxoo (<http://vauxoo.com>). #
299+# All Rights Reserved #
300+###############Credits######################################################
301+# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
302+# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
303+# Finance by: COMPANY NAME <EMAIL-COMPANY> #
304+# Audited by: author NAME LASTNAME <email@vauxoo.com> #
305+############################################################################
306+# This program is free software: you can redistribute it and/or modify #
307+# it under the terms of the GNU General Public License as published by #
308+# the Free Software Foundation, either version 3 of the License, or #
309+# (at your option) any later version. #
310+# #
311+# This program is distributed in the hope that it will be useful, #
312+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
313+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
314+# GNU General Public License for more details. #
315+# #
316+# You should have received a copy of the GNU General Public License #
317+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
318+############################################################################
319+
320+from openerp.osv import fields, osv
321+from openerp.tools.translate import _
322+
323+
324+class invoice_report_per_journal(osv.Model):
325+ """
326+ invoice_report_per_journal
327+ """
328+
329+ _inherit = 'account.journal'
330+ _columns = {
331+ 'invoice_report_id': fields.many2one('ir.actions.report.xml',
332+ 'Invoice Report', required=False,
333+ domain="[('model','=','account.invoice')]"),
334+ }
335
336=== added directory 'invoice_report_per_journal/report'
337=== added file 'invoice_report_per_journal/report/__init__.py'
338--- invoice_report_per_journal/report/__init__.py 1970-01-01 00:00:00 +0000
339+++ invoice_report_per_journal/report/__init__.py 2014-06-12 15:03:58 +0000
340@@ -0,0 +1,25 @@
341+# -*- encoding: utf-8 -*- #
342+############################################################################
343+# Module Writen to OpenERP, Open Source Management Solution #
344+# Copyright (C) Vauxoo (<http://vauxoo.com>). #
345+# All Rights Reserved #
346+###############Credits######################################################
347+# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
348+# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
349+# Finance by: COMPANY NAME <EMAIL-COMPANY> #
350+# Audited by: author NAME LASTNAME <email@vauxoo.com> #
351+############################################################################
352+# This program is free software: you can redistribute it and/or modify #
353+# it under the terms of the GNU General Public License as published by #
354+# the Free Software Foundation, either version 3 of the License, or #
355+# (at your option) any later version. #
356+# #
357+# This program is distributed in the hope that it will be useful, #
358+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
359+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
360+# GNU General Public License for more details. #
361+# #
362+# You should have received a copy of the GNU General Public License #
363+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
364+############################################################################
365+import invoice_report_demo
366
367=== added file 'invoice_report_per_journal/report/invoice_report_demo.mako'
368--- invoice_report_per_journal/report/invoice_report_demo.mako 1970-01-01 00:00:00 +0000
369+++ invoice_report_per_journal/report/invoice_report_demo.mako 2014-06-12 15:03:58 +0000
370@@ -0,0 +1,21 @@
371+<!DOCTYPE>
372+<html>
373+<head>
374+ <style type="text/css">
375+ ${css}
376+ </style>
377+</head>
378+<body>
379+ %for o in objects :
380+ <table>
381+ <tr>
382+ <td>
383+ <div>
384+ ${_("Invoice Demo Report")}
385+ </div>
386+ </td>
387+ </tr>
388+ </table>
389+ %endfor
390+</body>
391+</html>
392
393=== added file 'invoice_report_per_journal/report/invoice_report_demo.py'
394--- invoice_report_per_journal/report/invoice_report_demo.py 1970-01-01 00:00:00 +0000
395+++ invoice_report_per_journal/report/invoice_report_demo.py 2014-06-12 15:03:58 +0000
396@@ -0,0 +1,52 @@
397+# -*- encoding: utf-8 -*-
398+###########################################################################
399+# Module Writen to OpenERP, Open Source Management Solution
400+#
401+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com/
402+# All Rights Reserved.
403+# info Vauxoo (info@vauxoo.com)
404+############################################################################
405+# Coded by: Luis Torres (luis_t@vauxoo.com)
406+############################################################################
407+#
408+# This program is free software: you can redistribute it and/or modify
409+# it under the terms of the GNU Affero General Public License as
410+# published by the Free Software Foundation, either version 3 of the
411+# License, or (at your option) any later version.
412+#
413+# This program is distributed in the hope that it will be useful,
414+# but WITHOUT ANY WARRANTY; without even the implied warranty of
415+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
416+# GNU Affero General Public License for more details.
417+#
418+# You should have received a copy of the GNU Affero General Public License
419+# along with this program. If not, see <http://www.gnu.org/licenses/>.
420+#
421+##############################################################################
422+
423+from openerp.report import report_sxw
424+from openerp import pooler
425+from openerp.tools.translate import _
426+from openerp import tools
427+from openerp import tests
428+from openerp.osv import osv
429+from openerp import netsvc
430+import openerp
431+from report_webkit import webkit_report
432+import datetime
433+
434+class invoice_report_demo_html(report_sxw.rml_parse):
435+ def __init__(self, cr, uid, name, context=None):
436+ if context is None:
437+ context = {}
438+ super(invoice_report_demo_html, self).__init__(
439+ cr, uid, name, context=context)
440+ self.localcontext.update({
441+ })
442+
443+webkit_report.WebKitParser('report.invoice.report.demo.webkit',
444+ 'account.invoice',
445+ 'addons/invoice_report_per_journal/report/invoice_report_demo.mako',
446+ parser=invoice_report_demo_html)
447+
448+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
449
450=== added file 'invoice_report_per_journal/report/invoice_report_demo.xml'
451--- invoice_report_per_journal/report/invoice_report_demo.xml 1970-01-01 00:00:00 +0000
452+++ invoice_report_per_journal/report/invoice_report_demo.xml 2014-06-12 15:03:58 +0000
453@@ -0,0 +1,20 @@
454+<?xml version="1.0" encoding="utf-8"?>
455+<openerp>
456+ <data>
457+ <report auto="False"
458+ menu="False"
459+ id="invoice_report_demo"
460+ model="account.invoice"
461+ name="invoice.report.demo.webkit"
462+ file="invoice_report_per_journal/report/invoice_report_demo.mako"
463+ string="Invoice Demo Report"
464+ report_type="webkit"/>
465+
466+ <record id="property_invoice_report_demo_webkit" model="ir.property">
467+ <field name="name">webkit_header</field>
468+ <field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
469+ <field eval="'ir.header_webkit,'+str(ref('invoice_report_per_journal.ir_header_webkit_invoice_report_demo'))" model="ir.header_webkit" name="value"/>
470+ <field eval="'ir.actions.report.xml,'+str(ref('invoice_report_per_journal.invoice_report_demo'))" model="ir.actions.report.xml" name="res_id"/>
471+ </record>
472+ </data>
473+</openerp>
474
475=== added directory 'invoice_report_per_journal/security'
476=== added directory 'invoice_report_per_journal/test'
477=== added file 'invoice_report_per_journal/test/invoice_report_per_journal.yml'
478--- invoice_report_per_journal/test/invoice_report_per_journal.yml 1970-01-01 00:00:00 +0000
479+++ invoice_report_per_journal/test/invoice_report_per_journal.yml 2014-06-12 15:03:58 +0000
480@@ -0,0 +1,62 @@
481+-
482+ Reports Per Journal On Invoice Tests
483+-
484+ 1.- In order to test reports per journal on invoices, we will test the wizard without a report assigned in the journal
485+-
486+ 1.1.- I create a customer invoice
487+-
488+ !record {model: account.invoice, id: account_invoice_customer0 , view: account.invoice_form}: &account_invoice
489+ payment_term: account.account_payment_term_advance
490+ journal_id: account.sales_journal
491+ partner_id: base.res_partner_3
492+ reference_type: none
493+ name: 'Test Customer Invoice'
494+ invoice_line:
495+ - product_id: product.product_product_5
496+ quantity: 10.0
497+ price_unit: 1
498+-
499+ 1.2.- I overwrite the journal field (It is necessary overwrite the field to make it work! only in test yaml (BUG))
500+-
501+ !record {model: account.invoice, id: account_invoice_customer0, view: account.invoice_form}:
502+ journal_id: account.sales_journal
503+-
504+ 1.3.- I check that initially customer invoice state is "Draft"
505+-
506+ !assert {model: account.invoice, id: account_invoice_customer0}:
507+ - state == 'draft'
508+-
509+ 1.4.- I check that the customer invoice is a "Customer Invoice"
510+-
511+ !assert {model: account.invoice, id: account_invoice_customer0, string: This is not a customer invoice}:
512+ - type == 'out_invoice'
513+-
514+ 1.5.- I change the state of invoice to open by clicking Validate button
515+-
516+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0}
517+-
518+ 1.6.- I check that the invoice state is now "Open"
519+-
520+ !assert {model: account.invoice, id: account_invoice_customer0}:
521+ - state == 'open'
522+-
523+ 1.7.- I generate the default invoice report through the wizard
524+-
525+ !python {model: invoice.report.per.journal}: |
526+ context={}
527+ context.update({'active_model': 'account.invoice', 'active_ids': [ref('account_invoice_customer0')]})
528+ self._get_journal(cr, uid, context)
529+ self._get_report(cr, uid, context)
530+-
531+ 2.- In order to test the report defined on an journal, we will set the Invoice Demo Report to the Sale Journal
532+-
533+ !python {model: account.journal}: |
534+ self.write(cr, uid, [ref('account.sales_journal')], {'invoice_report_id': ref('invoice_report_per_journal.invoice_report_demo')})
535+-
536+ 2.1.- I generate the report assigned in the journal through the wizard
537+-
538+ !python {model: invoice.report.per.journal}: |
539+ context={}
540+ context.update({'active_model': 'account.invoice', 'active_ids': [ref('account_invoice_customer0')]})
541+ self._get_journal(cr, uid, context)
542+ self._get_report(cr, uid, context)
543
544=== added directory 'invoice_report_per_journal/view'
545=== added file 'invoice_report_per_journal/view/account_invoice_view.xml'
546--- invoice_report_per_journal/view/account_invoice_view.xml 1970-01-01 00:00:00 +0000
547+++ invoice_report_per_journal/view/account_invoice_view.xml 2014-06-12 15:03:58 +0000
548@@ -0,0 +1,15 @@
549+<?xml version='1.0' encoding='utf-8'?>
550+<openerp>
551+ <data>
552+ <record model="ir.ui.view" id="view_invoice_report_per_journal_form_inherit">
553+ <field name="name">invoice.report.per.journal.form</field>
554+ <field name="model">account.invoice</field>
555+ <field name="inherit_id" ref="account.invoice_form"/>
556+ <field name="arch" type="xml">
557+ <xpath expr="//button[@string='Print Invoice']" position="replace">
558+ <button name="%(invoice_report_per_journal)d" string="Print Invoice" type="action" icon="gtk-print" states="open,paid,proforma,sale,proforma2"/>
559+ </xpath>
560+ </field>
561+ </record>
562+ </data>
563+</openerp>
564
565=== added file 'invoice_report_per_journal/view/account_journal_view.xml'
566--- invoice_report_per_journal/view/account_journal_view.xml 1970-01-01 00:00:00 +0000
567+++ invoice_report_per_journal/view/account_journal_view.xml 2014-06-12 15:03:58 +0000
568@@ -0,0 +1,15 @@
569+<?xml version='1.0' encoding='utf-8'?>
570+<openerp>
571+ <data>
572+ <record model="ir.ui.view" id="account_journal_form_inherit">
573+ <field name="name">account.journal.form.inherit</field>
574+ <field name="model">account.journal</field>
575+ <field name="inherit_id" ref="account.view_account_journal_form"/>
576+ <field name="arch" type="xml">
577+ <field name="sequence_id" position="after">
578+ <field name="invoice_report_id" attrs="{'invisible': [('type', 'not in', ('sale','sale_refund'))]}" />
579+ </field>
580+ </field>
581+ </record>
582+ </data>
583+</openerp>
584
585=== added directory 'invoice_report_per_journal/wizard'
586=== added file 'invoice_report_per_journal/wizard/__init__.py'
587--- invoice_report_per_journal/wizard/__init__.py 1970-01-01 00:00:00 +0000
588+++ invoice_report_per_journal/wizard/__init__.py 2014-06-12 15:03:58 +0000
589@@ -0,0 +1,25 @@
590+# -*- encoding: utf-8 -*- #
591+############################################################################
592+# Module Writen to OpenERP, Open Source Management Solution #
593+# Copyright (C) Vauxoo (<http://vauxoo.com>). #
594+# All Rights Reserved #
595+###############Credits######################################################
596+# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
597+# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
598+# Finance by: COMPANY NAME <EMAIL-COMPANY> #
599+# Audited by: author NAME LASTNAME <email@vauxoo.com> #
600+############################################################################
601+# This program is free software: you can redistribute it and/or modify #
602+# it under the terms of the GNU General Public License as published by #
603+# the Free Software Foundation, either version 3 of the License, or #
604+# (at your option) any later version. #
605+# #
606+# This program is distributed in the hope that it will be useful, #
607+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
608+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
609+# GNU General Public License for more details. #
610+# #
611+# You should have received a copy of the GNU General Public License #
612+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
613+############################################################################
614+import invoice_report_per_journal
615
616=== added file 'invoice_report_per_journal/wizard/invoice_report_per_journal.py'
617--- invoice_report_per_journal/wizard/invoice_report_per_journal.py 1970-01-01 00:00:00 +0000
618+++ invoice_report_per_journal/wizard/invoice_report_per_journal.py 2014-06-12 15:03:58 +0000
619@@ -0,0 +1,111 @@
620+# -*- encoding: utf-8 -*- #
621+############################################################################
622+# Module Writen to OpenERP, Open Source Management Solution #
623+# Copyright (C) Vauxoo (<http://vauxoo.com>). #
624+# All Rights Reserved #
625+###############Credits######################################################
626+# Coded by: Sabrina Romero (sabrina@vauxoo.com) #
627+# Planified by: Nhomar Hernandez (nhomar@vauxoo.com) #
628+# Finance by: COMPANY NAME <EMAIL-COMPANY> #
629+# Audited by: author NAME LASTNAME <email@vauxoo.com> #
630+############################################################################
631+# This program is free software: you can redistribute it and/or modify #
632+# it under the terms of the GNU General Public License as published by #
633+# the Free Software Foundation, either version 3 of the License, or #
634+# (at your option) any later version. #
635+# #
636+# This program is distributed in the hope that it will be useful, #
637+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
638+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
639+# GNU General Public License for more details. #
640+# #
641+# You should have received a copy of the GNU General Public License #
642+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
643+############################################################################
644+from openerp.osv import fields, osv
645+from openerp.tools.translate import _
646+
647+import base64
648+import openerp.netsvc as netsvc
649+import logging
650+_logger = logging.getLogger(__name__)
651+
652+class invoice_report_per_journal(osv.TransientModel):
653+ """
654+ OpenERP Wizard: invoice.report.per.journal
655+ """
656+ _name = "invoice.report.per.journal"
657+
658+ def get_journal_object(self, cr, uid, context=None):
659+ record_brw = self.pool.get(context['active_model']).browse(
660+ cr, uid, context['active_ids'][0])
661+ if not record_brw.journal_id:
662+ raise except_osv(_('ERROR !'), _(
663+ 'There is no journal configured for this invoice.'))
664+ return record_brw.journal_id
665+
666+ def _get_journal(self, cr, uid, context=None):
667+ return self.get_journal_object(cr, uid, context=context).name
668+
669+ def _prepare_service(self, cr, uid, report, context=None):
670+ service = netsvc.LocalService('report.' + report.report_name)
671+ (result, format) = service.create(cr, uid, context[
672+ 'active_ids'], {'model': context['active_model']}, {})
673+ return (result, format)
674+
675+ def _get_report(self, cr, uid, context=None):
676+ report = self.get_journal_object(
677+ cr, uid, context=context).invoice_report_id
678+ try:
679+ (result, format) = self._prepare_service(cr, uid, report, context=context)
680+ except:
681+ if report:
682+ _logger.warning("Error occurred in the report, the report set to the journal will be ignored.")
683+ rep_id = self.pool.get("ir.actions.report.xml").search(
684+ cr, uid, [('model', '=', 'account.invoice'),], order="id",
685+ context=context)[0]
686+ report_ = self.pool.get(
687+ "ir.actions.report.xml").browse(cr, uid, rep_id, context=context)
688+ (result, format) = self._prepare_service(cr, uid, report_, context=context)
689+ try:
690+ act_id = self.pool.get('ir.actions.act_window').search(cr, uid, [('name','=', report.name + ' txt')], context=context)[0]
691+ if act_id:
692+ act_brw = self.pool.get('ir.actions.act_window').browse(cr, uid, act_id, context=context)
693+ wiz_obj = self.pool.get(act_brw.res_model)
694+ wiz_id = wiz_obj.create(cr, uid, {}, context=context)
695+ wiz_brw = wiz_obj.browse(cr, uid, wiz_id, context=context)
696+ result = base64.decodestring(wiz_brw.fname_txt)
697+ except:
698+ if report:
699+ _logger.info("txt report not defined for the report assigned to journal.")
700+ return base64.encodestring(result)
701+
702+ def _get_report_name(self, cr, uid, context=None):
703+ report = self.get_journal_object(cr, uid,
704+ context=context).invoice_report_id
705+ try:
706+ (result, format) = self._prepare_service(cr, uid, report, context=context)
707+ except:
708+ if report:
709+ _logger.warning("Error occurred in the report, the report set to the journal will be ignored.")
710+ rep_id = self.pool.get("ir.actions.report.xml").search(
711+ cr, uid, [('model', '=', 'account.invoice'),], order="id",
712+ context=context)[0]
713+ report = self.pool.get(
714+ "ir.actions.report.xml").browse(cr, uid, rep_id, context=context)
715+ return report.report_name
716+
717+ def print_invoice(self, cr, uid, ids, context=None):
718+ return {'type': 'ir.actions.report.xml',
719+ 'report_name': self._get_report_name(cr, uid, context=context),
720+ 'datas': {'ids': context['active_ids']}}
721+
722+ _columns = {
723+ 'journal': fields.char('Journal', 64, readonly=True, requied=True),
724+ 'report_format': fields.binary("Report", readonly=True, required=True)
725+ }
726+
727+ _defaults = {
728+ 'journal': _get_journal,
729+ 'report_format': _get_report,
730+ }
731
732=== added file 'invoice_report_per_journal/wizard/invoice_report_per_journal.xml'
733--- invoice_report_per_journal/wizard/invoice_report_per_journal.xml 1970-01-01 00:00:00 +0000
734+++ invoice_report_per_journal/wizard/invoice_report_per_journal.xml 2014-06-12 15:03:58 +0000
735@@ -0,0 +1,31 @@
736+<?xml version='1.0' encoding='utf-8'?>
737+<openerp>
738+ <data>
739+
740+ <record model="ir.ui.view" id="wizard_invoice_report_per_journal_form">
741+ <field name="name">invoice.report.per.journal.form</field>
742+ <field name="model">invoice.report.per.journal</field>
743+ <field name="arch" type="xml">
744+ <form string="Print" version="7.0">
745+ <group col="4" colspan="4">
746+ <field name="journal"/>
747+ <newline/>
748+ <field name="report_format"/>
749+ <newline/>
750+ <group col="2" colspan="2">
751+ <button icon="gtk-cancel" special="cancel" string="Cancel"/>
752+ <button icon="gtk-ok" name="print_invoice" type="object" string="Print Invoice"/>
753+ </group>
754+ </group>
755+ </form>
756+ </field>
757+ </record>
758+
759+ <act_window id="invoice_report_per_journal"
760+ key2="client_action_per" name="Print"
761+ res_model="invoice.report.per.journal"
762+ view_id="wizard_invoice_report_per_journal_form"
763+ view_mode="form" target="new" view_type="form"/>
764+
765+ </data>
766+</openerp>