[IMP] Added a 'paperformat' model that will handle properties of pdf documents that...
authoropenerp-sle <openerp-sle@openerp-sle.home>
Wed, 12 Feb 2014 17:54:12 +0000 (18:54 +0100)
committeropenerp-sle <openerp-sle@openerp-sle.home>
Wed, 12 Feb 2014 17:54:12 +0000 (18:54 +0100)
bzr revid: openerp-sle@openerp-sle.home-20140212175412-aeij8e9ifwjwgc1m

addons/report/__openerp__.py
addons/report/data/paperformat_defaults.xml [new file with mode: 0644]
addons/report/models/__init__.py
addons/report/models/paperformat.py [new file with mode: 0644]
addons/report/security/ir.model.access.csv [new file with mode: 0644]
addons/report/views/paperformat_view.xml [new file with mode: 0644]
addons/report/views/res_company_view.xml [new file with mode: 0644]

index 1993497..94da7b0 100644 (file)
@@ -9,6 +9,10 @@ Report
     'author': 'OpenERP SA',
     'depends': ['base'],
     'data': [
+        'views/paperformat_view.xml',
+        'views/res_company_view.xml',
+        'data/paperformat_defaults.xml',
+        'security/ir.model.access.csv',
     ],
     'installable': True,
 }
diff --git a/addons/report/data/paperformat_defaults.xml b/addons/report/data/paperformat_defaults.xml
new file mode 100644 (file)
index 0000000..71077f1
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="paperformat_euro" model="ir.actions.report.paperformat">
+            <field name="name">European A4</field>
+            <field name="default" eval="True" />
+            <field name="format">A4</field>
+            <field name="page_height">0</field>
+            <field name="page_width">0</field>
+            <field name="orientation">Portrait</field>
+            <field name="margin_top">30</field>
+            <field name="margin_bottom">20</field>
+            <field name="margin_left">7</field>
+            <field name="margin_right">7</field>
+            <field name="header_line" eval="False" />
+            <field name="header_spacing">25</field>
+            <field name="dpi">90</field>
+        </record>
+
+        <record id="paperformat_us" model="ir.actions.report.paperformat">
+            <field name="name">US Letter</field>
+            <field name="default" eval="True" />
+            <field name="format">Letter</field>
+            <field name="page_height">0</field>
+            <field name="page_width">0</field>
+            <field name="orientation">Portrait</field>
+            <field name="margin_top">50</field>
+            <field name="margin_bottom">18</field>
+            <field name="margin_left">10</field>
+            <field name="margin_right">10</field>
+            <field name="header_line" eval="False" />
+            <field name="header_spacing">5</field>
+            <field name="dpi">110</field>
+        </record>
+
+        <record id="base.main_company" model="res.company">
+            <field name="paperformat_id" ref="paperformat_euro"></field>
+        </record>
+    </data>
+</openerp>
\ No newline at end of file
diff --git a/addons/report/models/paperformat.py b/addons/report/models/paperformat.py
new file mode 100644 (file)
index 0000000..ea8cc4e
--- /dev/null
@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2014-Today OpenERP SA (<http://www.openerp.com>).
+#
+#    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 osv, fields
+
+
+class actions_report_paperformat(osv.Model):
+    _name = "ir.actions.report.paperformat"
+    _description = "Allows customization of a report."
+
+    _columns = {'name': fields.char('Name', required=True),
+                'default': fields.boolean('Default paper format ?'),
+                'format': fields.selection([('A0', 'A0  5   841 x 1189 mm'),
+                                            ('A1', 'A1  6   594 x 841 mm'),
+                                            ('A2', 'A2  7   420 x 594 mm'),
+                                            ('A3', 'A3  8   297 x 420 mm'),
+                                            ('A4', 'A4  0   210 x 297 mm, 8.26 x 11.69 inches'),
+                                            ('A5', 'A5  9   148 x 210 mm'),
+                                            ('A6', 'A6  10  105 x 148 mm'),
+                                            ('A7', 'A7  11  74 x 105 mm'),
+                                            ('A8', 'A8  12  52 x 74 mm'),
+                                            ('A9', 'A9  13  37 x 52 mm'),
+                                            ('B0', 'B0  14  1000 x 1414 mm'),
+                                            ('B1', 'B1  15  707 x 1000 mm'),
+                                            ('B2', 'B2  17  500 x 707 mm'),
+                                            ('B3', 'B3  18  353 x 500 mm'),
+                                            ('B4', 'B4  19  250 x 353 mm'),
+                                            ('B5', 'B5  1   176 x 250 mm, 6.93 x 9.84 inches'),
+                                            ('B6', 'B6  20  125 x 176 mm'),
+                                            ('B7', 'B7  21  88 x 125 mm'),
+                                            ('B8', 'B8  22  62 x 88 mm'),
+                                            ('B9', 'B9  23  33 x 62 mm'),
+                                            ('B10', ':B10    16  31 x 44 mm'),
+                                            ('C5E', 'C5E 24  163 x 229 mm'),
+                                            ('Comm10E', 'Comm10E 25  105 x 241 mm, U.S. '
+                                             'Common 10 Envelope'),
+                                            ('DLE', 'DLE 26 110 x 220 mm'),
+                                            ('Executive', 'Executive 4   7.5 x 10 inches, '
+                                             '190.5 x 254 mm'),
+                                            ('Folio', 'Folio 27  210 x 330 mm'),
+                                            ('Ledger', 'Ledger  28  431.8 x 279.4 mm'),
+                                            ('Legal', 'Legal    3   8.5 x 14 inches, '
+                                             '215.9 x 355.6 mm'),
+                                            ('Letter', 'Letter 2 8.5 x 11 inches, '
+                                             '215.9 x 279.4 mm'),
+                                            ('Tabloid', 'Tabloid 29 279.4 x 431.8 mm'),
+                                            ('custom', 'Custom')],
+                                           'Paper size',
+                                           help="Select Proper Paper size"),
+                'margin_top': fields.integer('Top Margin (mm)'),
+                'margin_bottom': fields.integer('Bottom Margin (mm)'),
+                'margin_left': fields.integer('Left Margin (mm)'),
+                'margin_right': fields.integer('Right Margin (mm)'),
+                'page_height': fields.integer('Page height (in)'),
+                'page_width': fields.integer('Page width (in)'),
+                'orientation': fields.selection([('Landscape', 'Landscape'),
+                                                 ('Portrait', 'Portrait')],
+                                                'Orientation'),
+                'header_line': fields.boolean('Display a header line'),
+                'header_spacing': fields.integer('Header spacing'),
+                'dpi': fields.integer('Output DPI'),
+                'report_ids': fields.one2many('ir.actions.report.xml',
+                                              'paperformat_id',
+                                              'Associated reports',
+                                              help="Explicitly associated reports")
+                }
+
+    def _check_format_or_page(self, cr, uid, ids, context=None):
+        for paperformat in self.browse(cr, uid, ids, context=context):
+            if paperformat.format != 'custom' and (paperformat.page_width or paperformat.page_height):
+                return False
+        return True
+
+    _constraints = [
+        (_check_format_or_page, 'Error ! You cannot select a format AND speficic '
+                                'page width/height.', ['format']),
+    ]
+
+
+class res_company(osv.Model):
+    _inherit = 'res.company'
+
+    _columns = {'paperformat_id': fields.many2one('ir.actions.report.paperformat', 'Paper format')}
+
+
+class ir_actions_report(osv.Model):
+    _inherit = 'ir.actions.report.xml'
+
+    _columns = {'paperformat_id': fields.many2one('ir.actions.report.paperformat', 'Paper format')}
diff --git a/addons/report/security/ir.model.access.csv b/addons/report/security/ir.model.access.csv
new file mode 100644 (file)
index 0000000..2b0cf16
--- /dev/null
@@ -0,0 +1,4 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"paperformat_access_portal","ir_actions_report_paperformat group_portal","model_ir_actions_report_paperformat",,1,0,0,0
+"paperformat_access_employee","ir_actions_report_paperformat group_hr_user","model_ir_actions_report_paperformat",,1,0,1,0
+"access_report","access_report","model_report",,1,1,1,1
diff --git a/addons/report/views/paperformat_view.xml b/addons/report/views/paperformat_view.xml
new file mode 100644 (file)
index 0000000..dba1d43
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- Adding a paperformat field inside the report form view -->
+        <record id="act_report_xml_view_inherit" model="ir.ui.view">
+            <field name="name">act_report_xml_view_inherit</field>
+            <field name="inherit_id" ref="base.act_report_xml_view" />
+            <field name="model">ir.actions.report.xml</field>
+            <field name="arch" type="xml">
+                <data>
+                    <xpath expr="//field[@name='report_file']" position="after">
+                        <field name="paperformat_id" />    
+                    </xpath>    
+                </data>
+            </field>
+        </record>
+
+        <record id="paperformat_view_tree" model="ir.ui.view">
+            <field name="name">paper_format_view_tree</field>
+            <field name="model">ir.actions.report.paperformat</field>
+            <field name="arch" type="xml">
+                <tree string="Paper format configuration">
+                    <field name="name" />
+                </tree>
+            </field>
+        </record>
+        
+        <record id="paperformat_view_form" model="ir.ui.view">
+            <field name="name">paper_format_view_form</field>
+            <field name="model">ir.actions.report.paperformat</field>
+            <field name="arch" type="xml">
+                <form string="Paper format configuration" version="7.0">
+                    <group>
+                        <field name="name" />
+                        <field name="format" />
+                        <field name="page_height" attrs="{'invisible': [('format','!=','custom')]}" />
+                        <field name="page_width" attrs="{'invisible': [('format','!=','custom')]}" />
+                        <field name="orientation" />
+                        <field name="margin_top" />
+                        <field name="margin_bottom" />
+                        <field name="margin_left" />
+                        <field name="margin_right" />
+                        <field name="header_line" />
+                        <field name="header_spacing" />
+                        <field name="dpi" />
+                        <field name="report_ids" widget="many2many_tags"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+
+        <record id="paper_format_action" model="ir.actions.act_window">
+            <field name="name">Paper Format General Configuration</field>
+            <field name="res_model">ir.actions.report.paperformat</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+        <record id='reports_action' model='ir.actions.act_window'>
+            <field name="name">Reports</field>
+            <field name="res_model">ir.actions.report.xml</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+
+        <menuitem 
+            id="reporting_menuitem" 
+            name="Reporting" 
+            parent="base.menu_custom" 
+            sequence="0" 
+            groups="base.group_no_one"
+            />
+
+        <menuitem 
+            id="paper_format_menuitem" 
+            name="Paper Format" 
+            parent="reporting_menuitem" 
+            action="paper_format_action" 
+            sequence="2" 
+            groups="base.group_no_one"
+            />
+
+        <menuitem 
+            id="reports_menuitem"
+            name="Reports"
+            parent="reporting_menuitem" 
+            action="reports_action"
+            sequence="3"
+            groups="base.group_no_one"
+            />
+    </data>
+</openerp>
\ No newline at end of file
diff --git a/addons/report/views/res_company_view.xml b/addons/report/views/res_company_view.xml
new file mode 100644 (file)
index 0000000..97abd9f
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="reporting_settings_form_inherited" model="ir.ui.view">
+            <field name="name">view_company_form_inherited</field>
+            <field name="inherit_id" ref="base.view_company_form" />
+            <field name="model">res.company</field>
+            <field name="arch" type="xml">
+                <data>
+                    <xpath expr="//group[@string='Footer Configuration']" position="after">
+                        <group string="QWeb PDF Configuration">
+                            <field name="paperformat_id" />
+                        </group>
+                    </xpath>
+                </data>
+            </field>
+        </record>
+    </data>
+</openerp>
\ No newline at end of file