[SPLIT] report: Split files by model

This commit is contained in:
rka-odoo
2016-07-19 11:56:22 +02:00
committed by Yannick Tivisse
parent 78fc98574e
commit 01ad2f3a90
9 changed files with 106 additions and 97 deletions
+1
View File
@@ -12,6 +12,7 @@ Report
'views/layout_templates.xml',
'views/report_paperformat_views.xml',
'views/report_templates.xml',
'views/res_company_views.xml',
'views/ir_actions_report_views.xml',
],
'qweb' : [
+2 -3
View File
@@ -1,8 +1,7 @@
import abstract_report
import ir_actions
import ir_actions_report_xml
import ir_http
import ir_qweb
import report
import report_paperformat
import abstract_report
import ir_qweb
import res_company
-6
View File
@@ -1,6 +0,0 @@
from openerp import models, fields
class Actions(models.Model):
_inherit = 'ir.actions.report.xml'
print_report_name = fields.Char('Printed Report Name', help="This is the filename of the report going to download. Keep empty to not change the report filename. You can use a python expression with the object and time variables.")
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp.osv import osv, fields
from odoo import fields as new_fields
class ir_actions_report(osv.Model):
_inherit = 'ir.actions.report.xml'
def associated_view(self, cr, uid, ids, context):
"""Used in the ir.actions.report.xml form view in order to search naively after the view(s)
used in the rendering.
"""
try:
report_name = self.browse(cr, uid, ids[0], context).report_name
act_window_obj = self.pool.get('ir.actions.act_window')
view_action = act_window_obj.for_xml_id(cr, uid, 'base', 'action_ui_view', context=context)
view_action['domain'] = [('name', 'ilike', report_name.split('.')[1]), ('type', '=', 'qweb')]
return view_action
except:
return False
_columns = {'paperformat_id': fields.many2one('report.paperformat', 'Paper format')}
class Actions(osv.Model):
_inherit = 'ir.actions.report.xml'
print_report_name = new_fields.Char('Printed Report Name', help="This is the filename of the report going to download. Keep empty to not change the report filename. You can use a python expression with the object and time variables.")
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from functools import partial
from openerp import SUPERUSER_ID
from openerp.osv import osv, fields
@@ -94,44 +91,3 @@ class report_paperformat(osv.Model):
}
class res_company(osv.Model):
_inherit = 'res.company'
_columns = {'paperformat_id': fields.many2one('report.paperformat', 'Paper format')}
def init(self, cr):
# set a default paperformat based on rml one.
ref = partial(self.pool['ir.model.data'].xmlid_to_res_id, cr, SUPERUSER_ID)
ids = self.search(cr, SUPERUSER_ID, [('paperformat_id', '=', False)])
for company in self.browse(cr, SUPERUSER_ID, ids):
paperformat_id = {
'a4': ref('report.paperformat_euro'),
'us_letter': ref('report.paperformat_us'),
}.get(company.rml_paper_format) or ref('report.paperformat_euro')
if paperformat_id:
company.write({'paperformat_id': paperformat_id})
sup = super(res_company, self)
if hasattr(sup, 'init'):
sup.init(cr)
class ir_actions_report(osv.Model):
_inherit = 'ir.actions.report.xml'
def associated_view(self, cr, uid, ids, context):
"""Used in the ir.actions.report.xml form view in order to search naively after the view(s)
used in the rendering.
"""
try:
report_name = self.browse(cr, uid, ids[0], context).report_name
act_window_obj = self.pool.get('ir.actions.act_window')
view_action = act_window_obj.for_xml_id(cr, uid, 'base', 'action_ui_view', context=context)
view_action['domain'] = [('name', 'ilike', report_name.split('.')[1]), ('type', '=', 'qweb')]
return view_action
except:
return False
_columns = {'paperformat_id': fields.many2one('report.paperformat', 'Paper format')}
+28 -2
View File
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp.osv import osv
from functools import partial
from openerp.osv import osv, fields
from openerp import SUPERUSER_ID
class ResCompany(osv.Model):
_inherit = 'res.company'
@@ -26,3 +27,28 @@ class ResCompany(osv.Model):
def edit_internal_header(self, cr, uid, ids, context=None):
return self._prepare_report_view_action(cr, uid, 'report.internal_layout')
class res_company(osv.Model):
_inherit = 'res.company'
_columns = {'paperformat_id': fields.many2one('report.paperformat', 'Paper format')}
def init(self, cr):
# set a default paperformat based on rml one.
ref = partial(self.pool['ir.model.data'].xmlid_to_res_id, cr, SUPERUSER_ID)
ids = self.search(cr, SUPERUSER_ID, [('paperformat_id', '=', False)])
for company in self.browse(cr, SUPERUSER_ID, ids):
paperformat_id = {
'a4': ref('report.paperformat_euro'),
'us_letter': ref('report.paperformat_us'),
}.get(company.rml_paper_format) or ref('report.paperformat_euro')
if paperformat_id:
company.write({'paperformat_id': paperformat_id})
sup = super(res_company, self)
if hasattr(sup, 'init'):
sup.init(cr)
@@ -14,5 +14,27 @@
</data>
</field>
</record>
<!-- Add a paperformat and web button to 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='attachment']" position="after">
<field name="paperformat_id" attrs="{'invisible':[('report_type','not in',['qweb-pdf'])]}"/>
<button
type="object"
class="oe_link"
string="Search associated QWeb views"
name="associated_view"
attrs="{'invisible':[('report_type', 'not in', ['qweb-pdf', 'qweb-html'])]}"
/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>
@@ -71,26 +71,6 @@
groups="base.group_no_one"
/>
<!-- Add a paperformat and web button to 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='attachment']" position="after">
<field name="paperformat_id" attrs="{'invisible':[('report_type','not in',['qweb-pdf'])]}"/>
<button
type="object"
class="oe_link"
string="Search associated QWeb views"
name="associated_view"
attrs="{'invisible':[('report_type', 'not in', ['qweb-pdf', 'qweb-html'])]}"
/>
</xpath>
</data>
</field>
</record>
<!-- Customize the company form view by adding paperformat field as well as demo reports -->
<!-- Demo reports definition -->
@@ -125,27 +105,5 @@
string="Preview External Report"
report_type="qweb-pdf"/>
<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="//page[@name='report']/group[1]" position="inside">
<group col="2" colspan="2">
<field name="paperformat_id" />
</group>
<group col="1" colspan="2" groups="base.group_no_one">
<button name="%(action_report_internalpreview)d" string="Preview Internal Report" type="action"/>
<button name="%(action_report_externalpreview)d" string="Preview External Report" type="action"/>
<button name="edit_external_header" string="Edit external header" type="object" class="oe_link"/>
<button name="edit_external_footer" string="Edit external footer" type="object" class="oe_link"/>
<button name="edit_internal_header" string="Edit internal header" type="object" class="oe_link"/>
</group>
</xpath>
</data>
</field>
</record>
</data>
</openerp>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<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="//page[@name='report']/group[1]" position="inside">
<group col="2" colspan="2">
<field name="paperformat_id" />
</group>
<group col="1" colspan="2" groups="base.group_no_one">
<button name="%(action_report_internalpreview)d" string="Preview Internal Report" type="action"/>
<button name="%(action_report_externalpreview)d" string="Preview External Report" type="action"/>
<button name="edit_external_header" string="Edit external header" type="object" class="oe_link"/>
<button name="edit_external_footer" string="Edit external footer" type="object" class="oe_link"/>
<button name="edit_internal_header" string="Edit internal header" type="object" class="oe_link"/>
</group>
</xpath>
</data>
</field>
</record>
</openerp>