How to create report with jasper reports - odoo

i get this WARNNIG when i create my report with jasper reports
'NoneType' object has no attribute 'getitem'
,'NoneType' object has no attribute 'getitem',
import jasper_reports
from openerp import pooler
def jasper_sub_test(cr,uid,ids,data,context=None):
pool=pooler.get_pool(cr,dr)
return{}
jasper_reports.report_jasper('report.decompte_client',
'facturation.attachement',
parser=jasper_sub_test
)
<?xml version="1.0"?>
<openerp>
<data>
<report string="report attachement client"
model="facturation.attachement"
auto="True"
name="decompte_report"
rml="TrvxFacturation/report/report_attach_client.jrxml"
id="report_test"
menu="True"
/>
</data>

Related

Use generics in databinding's xml

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.ihu.intelligentmedicinechest.activity.MainActivity">
<data>
<variable
name="items"
type="java.util.Collection<? extends com.ihu.intelligentmedicinechest.adapter.binder.ItemBinder>"/>
</data>
</layout>
Use generics in data binding XML is wrong. Follow is the exception:
android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:cannot find type argument for ?extendscom.tvvbbb.adapter.binder.ItemBinder in java.util.Collection
loc:56:30 - 56:34
****\ data binding error ****
How can I process it?

Magento 2 change pdf filename

I want to change the filenames of the PDF files in Magento 2.
The default names are not clear and I want invoices to be searchable when saved to a location on my pc.
Is it possible to change the filenames of the PDF-files in Magento 2 to a format like "invoice_1000000123.pdf"?
You should never edit core files. Seriously, don't.
Since /vendor/magento/module-sales/Controller/Adminhtml/Invoice/AbstractInvoice/PrintAction.php is an abstract class you have to use a plugin or preference in your module in order to override it.
What you need to achieve that:
The usual minimum files:
/Vendor/Module/composer.json, /Vendor/Module/registration.php, /Vendor/Module/etc/module.xml
In /Vendor/Module/etc/module.xml you should sequence Magento_Sales
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>
Then you can either use a plugin or a preference in /Vendor/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\PrintAction" type="Vendor\Module\Controller\Adminhtml\Invoice\AbstractInvoice\PrintAction"/>
</config>
Plugin would look something like this:
<type name="Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\PrintAction">
<plugin name="Vendor_Module::aroundPrintInvoice" type="Vendor\Module\Block\Class" sortOrder="0"/>
</type>
Now add a PrintAction.php to the path specified in your preference / plugin (Example for preference)
<?php
namespace Vendor\Module\Controller\Adminhtml\Invoice\AbstractInvoice;
class PrintAction extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\PrintAction
{
/* Write code here */
}
You need override the invoice admin controller.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="\Magento\Sales\Controller\Adminhtml\Order\Invoice"
type="Vendor\Module\Controller\Adminhtml\Order\Invoice" />
</config>
In your custom module admin controller, You need to change the name of Pdf file.
public function execute()
{
$invoiceId = $this->getRequest()->getParam('invoice_id');
return $this->_fileFactory->create(
'invoice_13012020' . $invoiceId . '.pdf', //<== Change the pdf name here.
$pdf->render(),
DirectoryList::VAR_DIR,
'application/pdf'
);
...
}
Reference Link
Yes it is possible to change invoice pdf filename.
Please go to following path:
/vendor/magento/module-sales/Controller/Adminhtml/Invoice/AbstractInvoice/PrintAction.php
You can change filename from above file.

Odoo 10 - Custom module to replace mail templates

I want to write a custom module to replace mail templates.
Those templates are included in base Odoo addons, such as sale:
The sale.order template ìs provided by the file /sale/data/mail_template_data.xml
This template is as follows:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!--Email template -->
<record id="email_template_edi_sale" model="mail.template">
<field name="name">Sales Order - Send by Email</field>¬
...
</odoo>
As the custom module wants to replace this standard base template:
Can a record with the same id be provided by the custom module to replace this mail template?
What shall be writte in <data noupdate>?
What will happen if module sale is updated?
Odoo 10 community edition.
For replacing the Email Templates just add the addon name in-front of the template name followed by dot(.) and make sure that you delete the default email template from the front end. Then update your custom addon. This will replace the old template.
Example:
<record id="sale.email_template_edi_sale" model="mail.template">
<field name="name">Sales Quotation</field>
<field name="email_from">${(object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '')|safe}</field>
<field name="subject">${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' })</field>
<field name="partner_to">${object.partner_invoice_id.id}</field>
....
....
</record>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!--Email template -->
<record id="email_template_edi_sale" model="mail.template">
<field name="name">Sales Order - Send by Email</field>
...
</odoo>
Please add your code to
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<delete model="mail.template" search="
[('id','=',ref('sale.email_template_edi_sale'))]"/>
<!--Email template -->
<record id="sale.email_template_edi_sale" model="mail.template">
<field name="name">Sales Order - Send by Email</field>
...
</odoo>
This will delete the original mail template and add a new template with the same ID so that the odoo functionlity is not disturbed.
Don't delete original template, you will lose the original module field and somethings will stop to work. Instead change noupdate value in ir.model.data for your template.
To do this automatically on module update:
Modify model 'ir.model.data' and add an allow_update method, creating a ir_model_data.py in models folder (modify __init__.py to include new file):
from odoo import models, fields, api
class IrModelData(models.Model):
_inherit = 'ir.model.data'
#api.model
def allow_update(self, module, name, model):
self.search([('module', '=', module), ('name', '=', name), ('model', '=', model)])[0].noupdate = False
Add function call element to allow_update before your record update and pass the original module name, external_id and 'mail.template':
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<function model='ir.model.data' name='allow_update'>
<value>sale</value>
<value>email_template_edi_sale</value>
<value>mail.template</value>
</function>
<record id="sale.email_template_edi_sale" model="mail.template" >
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
% set doc_name = 'quotation' if object.state in ('draft', 'sent') else 'order'
Dear ${object.partner_id.name}

AssertionError: Element odoo has extra content: report, line 7

When i try to give report_name in report tag it throws below error:
AssertionError: Element odoo has extra content: report, line 7
*.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report id="action_report_followup"
model="account_followup.followup"
report_name="PPPPPPPPPPpppp" //Here is the problem
string="Follow-up Report"
report_type="qweb-pdf"
name="payment_followup.report_followup"
file="payment_followup.report_followup"
menu="True"/>
</odoo>
If i remove attribute report_name it will work fine, and use value of string as report name. I need to give other name. How can i resolve this issue?
You can try this once.
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<report
string="Follow-up Report"
id="action_report_followup"
model="account_followup.followup"
report_type="qweb-pdf"
name="payment_followup.report_followup"
file="payment_followup.report_followup"
menu="True"/>
</data>
</odoo>
The attribute that you are trying to use here, "report_name", is the culprit. There is no attribute such as "report_name". Use the attribute "name" instead.
See the example below:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report id="action_report_followup"
model="account_followup.followup"
string="Follow-up Report"
report_type="qweb-pdf"
name="payment_followup.report_followup"
file="payment_followup.report_followup"
menu="True"/>
</odoo>

Custom module issue

I tried creating one new module. For that i created indexController, config.xml, block, layout and other required files, even though i am unable to view the message that i wrote in my block file. Whenever the url is fired (http://mydomain.com/foobar/) the output "it is from foo bar" should be displayed, but at the moment it is not working.
My indexController.php code :
class Foo_Bar_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
Code related to block :
class Foo_Bar_Block_News extends Mage_Core_Block_Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function fetchRow()
{
echo "it is from foo bar";
}
}
code related to config.xml :
<?xml version="1.0"?>
<config>
<modules>
<Foo_Bar>
<version>1.0.0</version>
</Foo_Bar>
</modules>
<frontend>
<routers>
<foobar>
<use>standard</use>
<args>
<module>Foo_Bar</module>
<frontName>foobar</frontName>
</args>
</foobar>
</routers>
<layout>
<updates>
<bar>
<file>foobar.xml</file>
</bar>
</updates>
</layout>
<!--<events>
<catalog_product_load_after>
<observers>
<foo_bar>
<type>model</type>
<class>foo_bar/observer</class>
<method>catalogProductLoadAfter</method>
</foo_bar>
</observers>
</catalog_product_load_after>
</events>-->
</frontend>
<global>
<blocks>
<foobar>
<class>Foo_Bar_Block</class>
</foobar>
</blocks>
</global>
</config>
code related to layout.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<default>
<reference name="content">
</reference>
</default>
<foobar_index_index>
<reference name="content">
<block type="foobar/news" name="news_test" template="bar/check.phtml"/>
</reference>
</foobar_index_index>
</layout>
Code related to template file
<?php
echo $this->fetchRow()
?>
Any help realted to this will be appreciated.
The solution to this issue in my case is to Disable the compilation from admin. Everything else is fine. The desired output is obtained after disabling the compilation from admin.
To disable compilation login to admin side of your magento project and then go to system>>Tools>>Compilation and then click on disable button to disable the compilation.