Skip to content
Snippets Groups Projects
Commit 3425752e authored by Laurent Smet's avatar Laurent Smet
Browse files

[REM] odoo/report: remove deprecated stuff

- RML Reports
- Webkit Reports (most part already removed by 13b9982c)
- LocalService in netsvc.py
- rename attributes like rml_% to report_%
- rename ir.actions.report.xml to ir.actions.report
- allow rendering directly on an ir.actions.report by calling render method
- remove 'controller' report_type
- remove unused res.font stuff
- remove print_report method in models.py (not used)
- restore removed call to pdftotext process in test_reports
parent 9898b125
No related branches found
No related tags found
No related merge requests found
Showing
with 36 additions and 48 deletions
......@@ -6,7 +6,7 @@
<field name="model_id" ref="account.model_account_payment" />
<field name="name">Print Receipt</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.report.xml,' +str(ref('action_report_payment_receipt'))" />
<field name="value" eval="'ir.actions.report,' +str(ref('action_report_payment_receipt'))" />
<field name="key">action</field>
<field name="model">account.payment</field>
</record>
......
......@@ -14,9 +14,8 @@
-
!python {model: account.invoice, id: False}: |
import os
import odoo.report
from odoo import tools
data, format = odoo.report.render_report(self.env.cr, self.env.uid, [ref('account.account_invoice_customer0')], 'account.report_invoice', {}, {})
data, format = ref('account.report_invoice').render(ref('account.account_invoice_customer0'))
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-invoice.'+format), 'wb+').write(data)
-
......@@ -24,9 +23,8 @@
-
!python {model: res.partner, id: False}: |
import os
import odoo.report
from odoo import tools
data, format = odoo.report.render_report(self.env.cr, self.env.uid, [ref('base.res_partner_1'),ref('base.res_partner_2'),ref('base.res_partner_12')], 'account.report_overdue', {}, {})
data, format = ref('account.report_overdue').render([ref('base.res_partner_1'),ref('base.res_partner_2'),ref('base.res_partner_12')])
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-report_overdue.'+format), 'wb+').write(data)
-
......
......@@ -13,7 +13,7 @@
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>
<record id="account_invoices" model="ir.actions.report.xml">
<record id="account_invoices" model="ir.actions.report">
<field name="print_report_name">(object.type == 'out_invoice' and object.state == 'draft' and 'Draft Invoice' or
object.type == 'out_invoice' and object.state in ('open','paid') and 'Invoice'+'-'+(object.number) or
object.type == 'out_refund' and object.state == 'draft' and 'Credit Note' or
......@@ -33,7 +33,7 @@
file="account.report_invoice_duplicate"
attachment_use="False"
/>
<record id="account_invoice_action_report_duplicate" model="ir.actions.report.xml">
<record id="account_invoice_action_report_duplicate" model="ir.actions.report">
<field name="print_report_name">(object.type == 'out_invoice' and object.state == 'draft' and 'Duplicate Invoice' or
object.type == 'out_invoice' and object.state in ('open','paid') and 'Duplicate Invoice'+'-'+(object.number) or
object.type == 'out_refund' and object.state == 'draft' and 'Duplicate Credit Note' or
......@@ -52,7 +52,7 @@
name="account.report_overdue"
file="account.report_overdue"
/>
<record id="action_report_print_overdue" model="ir.actions.report.xml">
<record id="action_report_print_overdue" model="ir.actions.report">
<field name="print_report_name">'Due Payments'+'-'+(object.name)</field>
</record>
......
......@@ -7,7 +7,7 @@
<record id="main_company2" model="res.company">
<field name="name">Hagrid</field>
<field name="rml_header1">My Company Tagline</field>
<field name="report_header">My Company Tagline</field>
<field name="currency_id" ref="base.EUR"/>
</record>
......
......@@ -28,7 +28,7 @@ class BaseConfigSettings(models.TransientModel):
" * Checked : Partners are visible for every companies, even if a company is defined on the partner.\n"
" * Unchecked : Each company can see only its partner (partners where company is defined). Partners not related to a company are visible for all companies.")
default_custom_report_footer = fields.Boolean("Custom Report Footer")
rml_footer = fields.Text(related="company_id.rml_footer", string='Custom Report Footer', help="Footer text displayed at the bottom of all reports.")
report_footer = fields.Text(related="company_id.report_footer", string='Custom Report Footer', help="Footer text displayed at the bottom of all reports.")
group_multi_currency = fields.Boolean(string='Allow multi currencies',
implied_group='base.group_multi_currency',
help="Allows to work in a multi currency environment")
......
......@@ -25,7 +25,7 @@
name="event.event_registration_report_template_badge"
file="event.event_registration_report_template_badge"
paperformat="event.paperformat_euro_lowmargin"/>
<record id="report_event_registration_badge" model="ir.actions.report.xml">
<record id="report_event_registration_badge" model="ir.actions.report">
<field name="print_report_name">'Registration Event'+'-'+(object.name)</field>
</record>
......
......@@ -7,7 +7,7 @@
report_type="qweb-pdf"
name="hr_attendance.print_employee_badge"
file="hr_attendance.print_employee_badge"/>
<record id="hr_employee_print_badge" model="ir.actions.report.xml">
<record id="hr_employee_print_badge" model="ir.actions.report">
<field name="print_report_name">'Print Badge'+'-'+(object.name)</field>
</record>
......
......@@ -106,7 +106,7 @@
name="hr_expense.report_expense_sheet"
file="hr_expense.report_expense_sheet"
/>
<record id="action_report_hr_expense_sheet" model="ir.actions.report.xml">
<record id="action_report_hr_expense_sheet" model="ir.actions.report">
<field name="print_report_name">'Expenses'+'-'+(object.employee_id.name)+'-'+(object.name)</field>
</record>
......
......@@ -10,7 +10,7 @@
file="hr_holidays.report_holidayssummary"
menu="False"/>
<record id="report_holidays_summary" model="ir.actions.report.xml">
<record id="report_holidays_summary" model="ir.actions.report">
<field name="paperformat_id" ref="hr_holidays.paperformat_hrsummary"/>
</record>
......
......@@ -2,10 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import os
from datetime import datetime
from dateutil.relativedelta import relativedelta
from odoo.report import render_report
from odoo.tools import config, test_reports
from odoo.addons.hr_payroll.tests.common import TestPayslipBase
......@@ -72,14 +69,14 @@ class TestPayslipFlow(TestPayslipBase):
})
# I print the payslip report
data, format = render_report(self.env.cr, self.env.uid, richard_payslip.ids, 'hr_payroll.report_payslip', {}, {})
data, data_format = self.env.ref('hr_payroll.action_report_payslip').render(richard_payslip.ids)
if config.get('test_report_directory'):
open(os.path.join(config['test_report_directory'], 'hr_payroll-payslip.'+ format), 'wb+').write(data)
open(os.path.join(config['test_report_directory'], 'hr_payroll-payslip.'+ data_format), 'wb+').write(data)
# I print the payslip details report
data, format = render_report(self.env.cr, self.env.uid, richard_payslip.ids, 'hr_payroll.report_payslipdetails', {}, {})
data, data_format = self.env.ref('hr_payroll.payslip_details_report').render(richard_payslip.ids)
if config.get('test_report_directory'):
open(os.path.join(config['test_report_directory'], 'hr_payroll-payslipdetails.'+ format), 'wb+').write(data)
open(os.path.join(config['test_report_directory'], 'hr_payroll-payslipdetails.'+ data_format), 'wb+').write(data)
# I print the contribution register report
context = {'model': 'hr.contribution.register', 'active_ids': [self.ref('hr_payroll.hr_houserent_register')]}
......
......@@ -17,7 +17,7 @@
name="hr_payroll.report_payslip"
file="hr_payroll.report_payslip"
/>
<record id="action_report_payslip" model="ir.actions.report.xml">
<record id="action_report_payslip" model="ir.actions.report">
<field name="print_report_name">(object.employee_id.name)+'-'+'Payslip'</field>
</record>
<report
......@@ -28,7 +28,7 @@
name="hr_payroll.report_payslipdetails"
file="hr_payroll.report_payslipdetails"
/>
<record id="payslip_details_report" model="ir.actions.report.xml">
<record id="payslip_details_report" model="ir.actions.report">
<field name="print_report_name">(object.name)</field>
</record>
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="res.company" id="base.main_company">
<field name="rml_paper_format">us_letter</field>
<field name="paperformat_id" ref="report.paperformat_us"/>
</record>
</odoo>
......@@ -27,7 +27,7 @@
menu="False"
/>
<record id="l10n_ch_isr_report" model ="ir.actions.report.xml">
<record id="l10n_ch_isr_report" model ="ir.actions.report">
<field name="print_report_name">
'ISR-' + object.number
<!--No additional condition on invoice state or type as this
......
......@@ -3,9 +3,8 @@
-
!python {model: account.move.line, id: False}: |
import os
import odoo.report
from odoo import tools
data, format = odoo.report.render_report(self.env.cr, self.env.uid, [], 'l10n_fr.report_l10nfrbilan', {'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}}, {})
data, format = self.env.ref('l10n_fr.report_l10nfrbilan').render([], data={'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'l10n_fr-bilan_report.'+format), 'wb+').write(data)
......@@ -14,8 +13,7 @@
-
!python {model: account.move.line}: |
import os
import odoo.report
from odoo import tools
data, format = odoo.report.render_report(self.env.cr, self.env.uid, [], 'l10n_fr.report_l10nfrresultat', {'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}}, {})
data, format = self.env.ref('l10n_fr.report_l10nfrresultat').render([], data={'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'l10n_fr-compute_resultant_report.'+format), 'wb+').write(data)
......@@ -3,7 +3,6 @@
import os
from odoo.report import render_report
from odoo.tools import config
from odoo.addons.l10n_in_hr_payroll.tests.common import TestPaymentAdviceBase
......@@ -38,6 +37,6 @@ class TestPaymentAdvice(TestPaymentAdviceBase):
self.assertEqual(payment_advice.state, 'confirm')
# In order to test the PDF report defined on a Payment Advice, we will print a Print Advice Report when NEFT is checked
data, format = render_report(self.env.cr, self.env.uid, payment_advice.ids, 'l10n_in_hr_payroll.report_payrolladvice', {}, {})
data, data_format = self.env.ref('l10n_in_hr_payroll.payroll_advice').render(payment_advice.ids)
if config.get('test_report_directory'):
open(os.path.join(config['test_report_directory'], 'l10n_in_hr_payroll_summary_report' + format), 'wb+').write(data)
open(os.path.join(config['test_report_directory'], 'l10n_in_hr_payroll_summary_report' + data_format), 'wb+').write(data)
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="res.company" id="base.main_company">
<field name="rml_paper_format">us_letter</field>
<field name="paperformat_id" ref="report.paperformat_us"/>
</record>
</odoo>
......@@ -15,7 +15,6 @@ import urlparse
from urllib import urlencode, quote as quote
from odoo import _, api, fields, models, tools
from odoo import report as odoo_report
from odoo.exceptions import UserError
from odoo.tools import pycompat
......@@ -155,7 +154,7 @@ class MailTemplate(models.Model):
report_name = fields.Char('Report Filename', translate=True,
help="Name to use for the generated report file (may contain placeholders)\n"
"The extension can be omitted and will then come from the report type.")
report_template = fields.Many2one('ir.actions.report.xml', 'Optional report to print and attach')
report_template = fields.Many2one('ir.actions.report', 'Optional report to print and attach')
ref_ir_act_window = fields.Many2one('ir.actions.act_window', 'Sidebar action', readonly=True, copy=False,
help="Sidebar action to make this template available on records "
"of the related document model")
......@@ -508,10 +507,9 @@ class MailTemplate(models.Model):
report = template.report_template
report_service = report.report_name
if report.report_type in ['qweb-html', 'qweb-pdf']:
result, format = Template.env['report'].get_pdf([res_id], report_service), 'pdf'
else:
result, format = odoo_report.render_report(self._cr, self._uid, [res_id], report_service, {'model': template.model}, Template._context)
if report.report_type not in ['qweb-html', 'qweb-pdf']:
raise UserError(_('Unsupported report type %s found.') % report.report_type)
result, format = Template.env['report'].get_pdf([res_id], report_service), 'pdf'
# TODO in trunk, change return format to binary to match message_post expected format
result = base64.b64encode(result)
......
......@@ -4,8 +4,8 @@
from odoo import api, models
class IrActionsReportXml(models.Model):
_inherit = 'ir.actions.report.xml'
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
......@@ -13,4 +13,4 @@ class IrActionsReportXml(models.Model):
if model_id:
model = self.env['ir.model'].browse(model_id).model
args.append(('model', '=', model))
return super(IrActionsReportXml, self).search(args, offset=offset, limit=limit, order=order, count=count)
return super(IrActionsReport, self).search(args, offset=offset, limit=limit, order=order, count=count)
......@@ -311,7 +311,7 @@ class MarketingCampaignActivity(models.Model):
"- Report: print an existing Report defined on the resource item and save it into a specific directory \n"
"- Custom Action: execute a predefined action, e.g. to modify the fields of the resource record")
email_template_id = fields.Many2one('mail.template', "Email Template", help='The email to send when this activity is activated')
report_id = fields.Many2one('ir.actions.report.xml', "Report", help='The report to generate when this activity is activated')
report_id = fields.Many2one('ir.actions.report', "Report", help='The report to generate when this activity is activated')
server_action_id = fields.Many2one('ir.actions.server', string='Action',
help="The action to perform when this activity is activated")
to_ids = fields.One2many('marketing.campaign.transition', 'activity_from_id', 'Next Activities')
......@@ -343,7 +343,7 @@ class MarketingCampaignActivity(models.Model):
@api.multi
def _process_wi_report(self, workitem):
self.ensure_one()
return self.report_id.render_report(workitem.res_id, self.report_id.report_name, None)
return self.report_id.render(workitem.res_id)
@api.multi
def _process_wi_action(self, workitem):
......@@ -611,7 +611,7 @@ class MarketingCampaignWorkitem(models.Model):
'model': self.object_id.model
}
res = {
'type': 'ir.actions.report.xml',
'type': 'ir.actions.report',
'report_name': self.activity_id.report_id.report_name,
'datas': datas,
}
......
......@@ -9,7 +9,7 @@
file="mrp.report.mrp_bom_templates"
report_type="qweb-pdf"
/>
<record id="action_report_bom_structure" model="ir.actions.report.xml">
<record id="action_report_bom_structure" model="ir.actions.report">
<field name="print_report_name">'BOM'+'-'+(object.product_id.name or object.product_tmpl_id.name)</field>
</record>
......@@ -21,7 +21,7 @@
file="mrp.report.mrp_production_templates"
report_type="qweb-pdf"
/>
<record id="action_report_production_order" model="ir.actions.report.xml">
<record id="action_report_production_order" model="ir.actions.report">
<field name="print_report_name">'Production Order'+'-'+(object.name)</field>
</record>
......@@ -33,7 +33,7 @@
file="mrp_bom_cost"
report_type="qweb-html"
/>
<record id="action_report_bom_price" model="ir.actions.report.xml">
<record id="action_report_bom_price" model="ir.actions.report">
<field name="print_report_name">'BOM Cost'+'-'+(object.product_id.name or object.product_tmpl_id.name)</field>
</record>
</data>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment