Skip to content

Commit

Permalink
[REM] odoo/report: remove deprecated stuff
Browse files Browse the repository at this point in the history
- RML Reports
- Webkit Reports (most part already removed by 13b9982)
- 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
  • Loading branch information
smetl committed May 8, 2017
1 parent 9898b12 commit 3425752
Show file tree
Hide file tree
Showing 116 changed files with 174 additions and 6,069 deletions.
2 changes: 1 addition & 1 deletion addons/account/data/payment_receipt_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 2 additions & 4 deletions addons/account/test/account_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@
-
!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)
-
In order to test the PDF reports defined on a partner, we will print the Overdue Report
-
!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)
-
Expand Down
6 changes: 3 additions & 3 deletions addons/account/views/account_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion addons/base_import_module/tests/test_module/test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion addons/base_setup/models/res_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion addons/event/report/event_event_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion addons/hr_attendance/report/hr_employee_badge.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion addons/hr_expense/report/report_expense_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion addons/hr_holidays/report/hr_holidays_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
11 changes: 4 additions & 7 deletions addons/hr_payroll/tests/test_payslip_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -72,14 +69,14 @@ def test_00_payslip_flow(self):
})

# 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')]}
Expand Down
4 changes: 2 additions & 2 deletions addons/hr_payroll/views/hr_payroll_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>
1 change: 0 additions & 1 deletion addons/l10n_ca/data/res_company_data.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?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>
2 changes: 1 addition & 1 deletion addons/l10n_ch/report/isr_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions addons/l10n_fr/test/l10n_fr_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
5 changes: 2 additions & 3 deletions addons/l10n_in_hr_payroll/tests/test_payment_advice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -38,6 +37,6 @@ def test_00_payment_advice_flow(self):
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)
1 change: 0 additions & 1 deletion addons/l10n_us/data/res_company_data.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?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>
10 changes: 4 additions & 6 deletions addons/mail/models/mail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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

Expand Down Expand Up @@ -155,7 +154,7 @@ def default_get(self, fields):
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")
Expand Down Expand Up @@ -508,10 +507,9 @@ def generate_email(self, res_ids, fields=None):
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)
Expand Down
6 changes: 3 additions & 3 deletions addons/marketing_campaign/models/ir_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
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):
model_id = self.env.context.get('object_id')
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)
6 changes: 3 additions & 3 deletions addons/marketing_campaign/models/marketing_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -343,7 +343,7 @@ def _process_wi_email(self, workitem):
@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):
Expand Down Expand Up @@ -611,7 +611,7 @@ def preview(self):
'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,
}
Expand Down
6 changes: 3 additions & 3 deletions addons/mrp/report/mrp_report_views_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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>

Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion addons/mrp_repair/report/mrp_repair_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
file="mrp_repair.report_mrprepairorder"
report_type="qweb-pdf"
/>
<record id="action_report_mrp_repair_order" model="ir.actions.report.xml">
<record id="action_report_mrp_repair_order" model="ir.actions.report">
<field name="print_report_name">(object.state == 'draft' and 'Repair Quotation'+'-'+(object.name) or 'Repair Order'+'-'+(object.name))</field>
</record>
</data>
Expand Down
3 changes: 2 additions & 1 deletion addons/point_of_sale/tests/test_point_of_sale_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import odoo
from odoo import fields
from odoo.tools import float_compare, mute_logger
from odoo.tools import float_compare, mute_logger, test_reports
from odoo.addons.point_of_sale.tests.common import TestPointOfSaleCommon


@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class TestPointOfSaleFlow(TestPointOfSaleCommon):
Expand Down
4 changes: 2 additions & 2 deletions addons/point_of_sale/views/point_of_sale_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
/>

<!-- used from POS UI, no need to be in print menu -->
<record id="pos_invoice_report" model="ir.actions.report.xml">
<record id="pos_invoice_report" model="ir.actions.report">
<field name="name">Invoice</field>
<field name="model">pos.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">point_of_sale.report_invoice</field>
<field name="print_report_name">'Invoice'+'-'+(object.name)</field>
</record>

<record id="sale_details_report" model="ir.actions.report.xml">
<record id="sale_details_report" model="ir.actions.report">
<field name="name">Sales Details</field>
<field name="model">report.point_of_sale.details</field>
<field name="report_type">qweb-pdf</field>
Expand Down
4 changes: 2 additions & 2 deletions addons/product/report/product_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
report_type="qweb-pdf"
name="product.report_productlabel"
file="product.report_productlabel"/>
<record id="report_product_label" model="ir.actions.report.xml">
<record id="report_product_label" model="ir.actions.report">
<field name="print_report_name">'Products Labels'+'-'+(object.name)</field>
</record>

Expand All @@ -19,7 +19,7 @@
report_type="qweb-pdf"
name="product.report_producttemplatelabel"
file="product.report_producttemplatelabel"/>
<record id="report_product_template_label" model="ir.actions.report.xml">
<record id="report_product_template_label" model="ir.actions.report">
<field name="print_report_name">'Products Labels'+'-'+(object.name)</field>
</record>

Expand Down
Loading

0 comments on commit 3425752

Please sign in to comment.