Odoo9 Custom Print option shows Internal server error - odoo

Inside PDF it shows Internal server error. Any solutions?
1.View
<button name="print_button" string="Print" type="object" states="approved" />
2. Report View
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="print_expense_report"
string="Expenses"
model="custom.expenses"
report_type="qweb-pdf"
file="custom_expenses.report_without_prices"
name="custom_expenses.report_without_prices"
/>
</data>
</openerp>
3. Print View
<?xml version="1.0" encoding="utf-8"?>
<!--Custom report.-->
<openerp>
<data>
<template id="report_without_prices_document">
<div class="page">
<div class="row">
<h3>Title1</h3>
</div>
</div>
</template>
<template id="report_without_prices">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report_without_prices_document" t-lang="doc.partner_id.lang"/>
</t>
</t>
</template>
</data>
</openerp>
3. Module
#api.multi
def print_button(self):
return self.env['report'].get_action(self, 'custom_expenses.report_without_prices')

Related

How do I add a button with function to export the report as either .pdf,.xls or .csv formats in ODOO 8?

I am using odoo 8.0 and I'm making a report for asset list. So far I have created the asset list report:
How do I add a button with function to export the report as either .pdf,.xls or .csv formats?
Here is a snippet code I have for the report view.
<record model="ir.actions.act_window" id="action_fleet_reporting_asset_listing">
<field name="name">Asset Listing</field>
<field name="res_model">fleet.asset</field>
<field name="view_id" ref="fleet_asset_listing_report"></field>
<field name="view_type">tree</field>
<field name="view_mode">tree</field>
<field name="context">{"search_default_parent_false" : True,}</field>
<field name="help" type="html">
<p>
Odoo helps you managing the costs for your different vehicles
Costs are generally created from services and contract and appears here.
</p>
<p>
Thanks to the different filters, Odoo can only print the effective
costs, sort them by type and by vehicle.
</p>
</field>
</record>
<report id="report_fleet_asset_list"
name="fleet.qweb_fleet_asset_list"
model="fleet.asset"
string="Assets"
report_type="qweb-pdf" />
Then created the Template:
<?xml version="1.0" encoding="utf-8"?>
<!--Custom report.-->
<openerp>
<data>
<template id="qweb_fleet_asset_list">
<t t-call="report.html_container">
<t t-call="report.internal_layout">
<div class="page">
<h2>Aseet List</h2>
<div class="row mt4 mb4" t-as="o" t-foreach="docs">
<div class="col-md-6">
<t t-esc="o.name"/>
</div>
<div class="col-md-6">
<t t-esc="o.location" t-if="o.location"/>
<t t-if="not o.location">-</t>
</div>
</div>
</div>
</t>
</t>
</template>
</data>
</openerp>

Odoo 10 how to replace inherited qweb template content

I have tried to insert a tag into an existing template but couldn't get it to work.
Existing template in odoo/addons/mail/static/src/xml/thread.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="mail.ChatThread">
<t t-if="messages.length">
:
<t t-name="mail.ChatComposer.Attachments">
<div class="o_attachments">
<t t-foreach="attachments" t-as='attachment'>
<t t-call="mail.Attachment">
<t t-set="editable" t-value="true"/>
</t>
</t>
</div>
</t>
<t t-name="mail.Attachment">
<div t-attf-class="o_attachment #{attachment.upload ? 'o_attachment_uploading' : ''}" t-att-title="attachment.name">
<a class="o_image" t-att-href='attachment.url' target="_blank" t-att-data-mimetype="attachment.mimetype" t-attf-data-src="/web/image/#{attachment.id}/100x80">
<span class='o_attachment_name'><t t-esc='attachment.name'/></span>
</a>
<t t-if="editable">
<div class="o_attachment_delete">
<i class='fa fa-times-circle' title="Delete this attachment" t-att-data-id="attachment.id"/>
</div>
<div class="o_attachment_progress_bar">
Uploading
</div>
</t>
</div>
</t>
My custom template (odoo/addons/mycustom/static/src/xml/thread.xml):
I want to insert the Hello world after the class o_image in the original template.
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="mycustom.ImageAttachment" t-extend="mail.Attachment">
<t t-jquery="o_image" t-operation="append">
<div>Hello world</div>
</t>
</t>
</templates>
My javascript to render the template (odoo/addons/mycustom/static/src/js/thread.js):
odoo.define('mycustom.thread', function (require) {
"use strict";
var core = require('web.core');
var ajax = require('web.ajax');
var qweb = core.qweb;
ajax.loadXML('/mycustom/static/src/xml/thread.xml', qweb);
console.log("INFO", "Hello World")
});
My assets file (odoo/addons/mycustom/views/assets.xml):
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="my assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/mycustom/static/src/js/thread.js"></script>
</xpath>
</template>
</odoo>
My manifest file (odoo/addons/mycustom/manifest.py):
# -*- coding: utf-8 -*-
{
'name': "test",
'summary': """my test""",
'description': """
This is my test module.
""",
'author': "peter",
'website': "",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/odoo/addons/base/module/module_data.xml
# for the full list
'category': 'Test',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': ['base','mail'],
# always loaded
'data': [
'views/assets.xml',
],
'qweb': [
'static/src/xml/thread.xml',
],
}
The javascript is loaded because I can see the text Hello World written on the browser console.
However, I cannot see the <div>Hello World</div> in the chat thread. What did I miss?
Try this:
<t t-name="mail.Attachment" t-extend="mail.Attachment">
<t t-jquery="o_image" t-operation="inner">
<div>Hello world</div>
</t>
</t>
Hope it will help you.

QWeb pdf report odoo 10

I am new in odoo I want to make a report pdf to my model, I have try all tuto I have find in net youtube, google but no one work for me please give me an advice.
there is my model :
# modelx.py file
from openerp import models, fields, api
class omega(models.Model):
_name = 'omega.model'
_description = 'No Description for now !!'
#api.model
def render_html(self, docids, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('report.external_layout')
docargs = {
'doc_ids': docids,
'doc_model': report.model,
'docs': self,
}
return report_obj.render('report.external_layout', docargs)
state = fields.Selection([
('Nouveau', 'Nouveau'),
('valid', 'Validation Responsable'),
('Termine', 'Termine'),
],default='Nouveau')
#api.one
def confirmer(self):
self.write({
'state': 'valid',
})
employe = fields.Many2one(comodel_name="res.users", string="Employe", required=True, delegate=True)
date = fields.Datetime(string="Date", required=True)
date2 = fields.Date(string="Date2", required=True)
day_number = fields.Integer(string="Nombre de jour", required=True)
transport = fields.Selection(string="Transport", selection=[('1', 'Train'), ('2', 'Voiture de Service'), ('3', 'Avion')])
sujet = fields.Char(string="Sujet", required=True)
lieu = fields.Char(string="Lieu", required=False)
I have also this two file XML:
<!-- report.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<openerp>
<data>
<report
id="action_report_omega"
model="omega.model"
string="Report"
report_type="qweb-pdf"
file="report.external_layout"
name="report.external_layout"
/>
</data>
</openerp>
and this file for template view as I find in net and odoo documentation
<!-- report_template.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<openerp>
<data>
<template id="report_omega_document">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<div class="page">
<div class="oe_structure">
<div class="row">
<H1>Hi there hello</H1>
</div>
</div>
</div>
</t>
</t>
</template>
<template id="report_omega">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<t t-foreach="doc_ids" t-as="doc_id">
<div class="page">
<div class="oe_structure">
<div class="row">
<H3>Hi hello </H3>
</div>
</div>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
when I execute the programme for printing the report I get an empty file, give me any advice please
You need to change file and name attribute of report tag. It always represent module_name.report_template_name
<report
id="action_report_omega"
model="omega.model"
string="Report"
report_type="qweb-pdf"
file="your_module_name.report_omega"
name="your_module_name.report_omega"
/>
Afterwards, upgrade your module and try it. It should work fine.
For more details, you may refer Qweb Reports - Odoo10 Document.

Uncaught Error: QWeb2: Error while extending template 'ClientDetailsNo expression given

Getting this error when trying to extend a qweb template. Has anyone come across something like this. I've not been able to find anything related to this.
Uncaught Error: QWeb2: Error while extending template 'ClientDetailsNo expression given
http://localhost:8069/web/content/246-17d551a/web.assets_common.js:2444Traceback:
Error: QWeb2: Error while extending template 'ClientDetailsNo expression given
at Object.exception (http://localhost:8069/web/content/246-17d551a/web.assets_common.js:2444:7)
at Engine.extend (http://localhost:8069/web/content/246-17d551a/web.assets_common.js:2482:507)
at Engine._render (http://localhost:8069/web/content/246-17d551a/web.assets_common.js:2477:454)
at Engine.render (http://localhost:8069/web/content/246-17d551a/web.assets_common.js:2477:151)
at Class.display_client_details (http://localhost:8069/web/content/313-25bfa95/point_of_sale.assets.js:337:1375)
at Class.line_select (http://localhost:8069/web/content/313-25bfa95/point_of_sale.assets.js:332:528)
at HTMLTableRowElement.<anonymous> (http://localhost:8069/web/content/313-25bfa95/point_of_sale.assets.js:327:86)
at HTMLTableSectionElement.dispatch (http://localhost:8069/web/content/246-17d551a/web.assets_common.js:740:451)
at HTMLTableSectionElement.elemData.handle (http://localhost:8069/web/content/246-17d551a/web.assets_common.js:713:173)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ClientDetails">
<t t-query="div.client-details-right" t-operation="append">
<div class="client-detail">
<span class="label">RNC</span>
<span class="detail client-phone">Test</span>
</div>
</t>
</t>
There is a typo in the attribute name for the jQuery selector -- it should be t-jquery, not t-query:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ClientDetails">
<t t-jquery="div.client-details-right" t-operation="append">
<div class="client-detail">
<span class="label">RNC</span>
<span class="detail client-phone">Test</span>
</div>
</t>
</t>
</templates>

ParseError: External ID conflict while creating custom qweb report

I created a folder called Student. When i open this module i am getting the above said error. this is my opennerp file,
{
'name': "Student",
'version': '1.0',
'sequence': 7,
'depends': ['base','report'],
'author': "ZD",
'category': 'Testing',
'description': "Module used for testing purpose only",
'data': [
'student_custom_view.xml',
'views/Student_report123.xml',
'Student_report.xml',
],
'installable': True,
'auto_install': False,
}
Then in .py file,
class student(models.Model):
_name = 'student'
name = fields.Char(string='Number', compute='_compute_name')
total2 = fields.Char(string='Total in words', compute='_compute_total')
student_report.xml,
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="Student_report123"
string="Report"
model="student"
report_type="qweb-pdf"
file="Student.Student_report123"
name="Student.Student_report123"
attachment_use="False"
/>
</data>
</openerp>
Inside views folder i created a file called Student_report123.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="Student_report123">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<span t-field="o.total2"></span>
</div>
</div>
</t>
</template>
</data>
</openerp>
Under you student_report.xml file and student_report123.xml file the id provided are xml ids and no two xml ids are allowed same. Xml IDs must be unique throughout the database.
you can try this code:
<t t-name="student_report123">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<h2>Success</h2>
<span t-field="o.total2"/>
</div>
</div>
</t>
</t>