Reach field in invoice report - odoo

I need to extend invoice report with field note. but I'm getting error that field does not exist. I'm stuck and don't know how to reach that field. did tried with partner_id.note too but also getting error.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//div[#class='page']/*[last()]" position="after">
<div class="row">
<div class="col-xs-6">
<span t-esc="o.note"/><br/>
<div class="left_sign_block">
<span>Note</span>
</div>
</div>
</div>
</xpath>
</template>
</data>
</openerp>
class AccountInvoiceTax(models.Model):
_inherit = 'account.invoice.tax'
note = fields.Text(related='tax_id.note', string='Note')
QWebException: "'account.invoice' object has no attribute 'note'" while evaluating 'o.note'

You have extended the model account.invoice.tax and not account.invoice. The error message is correct. So either you extend invoice or you have to use note from the invoice tax lines (tax_line_ids).

Related

How do I migrate a module to remove a custom `res.config.settings` field?

Suppose I have a module which defines some custom res.config.settings fields like so:
from odoo import models, fields
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
custom_field = fields.Char(config_parameter="custom.field")
some_other_custom_field = fields.Char(config_parameter="some.other.custom.field")
And then in my XML I have something like this:
<odoo>
<record id="custom_settings_view_form" model="ir.ui.view">
<field name="name">custom.settings.view.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="custom_base_settings_view_form"/>
<field name="arch" type="xml">
<div data-string="custom" position="inside">
<h2>Custom</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="custom_field"/>
<div class="text-muted">Description...</div>
<div class="content-group">
<div class="mt16">
<field name="custom_field"
placeholder="Placeholder..."/>
</div>
</div>
</div>
<div class="o_setting_right_pane">
<label for="some_other_custom_field"/>
<div class="text-muted">Description...</div>
<div class="content-group">
<div class="mt16">
<field name="some_other_custom_field"
placeholder="Placeholder..."/>
</div>
</div>
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>
Suppose that now later I've implemented some new functionality elsewhere that eliminates my need for custom_field. As such, I'd like to remove it entirely. However, as you can see, the custom_settings_view_form also includes some_other_custom_field, which I need to keep. This means that my options are limited:
I cannot just remove the ir.ui.view record, because then I would lose the UI for some_other_custom_field.
I also cannot just uninstall and then install the module again, because it would result in data loss elsewhere.
So specifically I want to remove the following line from my model:
custom_field = fields.Char(config_parameter="custom.field")
And the following block from my XML:
<div class="o_setting_right_pane">
<label for="custom_field"/>
<div class="text-muted">Description...</div>
<div class="content-group">
<div class="mt16">
<field name="custom_field"
placeholder="Placeholder..."/>
</div>
</div>
</div>
However, when I remove that code and then run my Odoo server again with -u <name_of_containing_module>, I get the following error:
odoo.tools.convert.ParseError: "Error while validating view
Field `custom_field` does not exist
Error context:
View `custom.settings.view.form`
[view_id: <id>, xml_id: <name_of_containing_module>.custom_settings_view_form, model: res.config.settings, parent_id: <parent_id>]
...
I just learned that I can create scripts at <module_root>/migrations/<version>/ to help with this sort of situation, but I have no idea what I would need to put in my migration script to deal with this issue. How can I remove fields and modify views in a module without causing errors and without requiring that the module be reinstalled?
You could try this steps:
Remove custom_field from XML view and change the actual id
custom_settings_view_form.
Update your module, that shouldn't produce any error and you won't see custom_field any more.
At this moment you could deside ignore custom_field, nothing will happend. Any way if you are a person that don't like death code inside his project like me, you can continue with the next steps.
Remove custom_field definition for .py file.
Update your module.
If you have the same error reported, you sould execute the 3.1 step bellow.
3.1. Clean the database data for custom_field. By SQL. Continue with 4 and 5 steps.
Please share your comments of the execution of these steps.
I hope this answer can be helpful for you.

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>

I want to print the values of the 'tag (tag_ids)' in the report of 'chart of accounts.'

I am working on the accounts report where i need to print the Tags (which is a many2many widget) in the report of Trial Balance under the option- Chart of Accounts
Image of the section-
I was successful in adding the field of Tags in the report as shown below-
Problem :-
The problem which i'm facing is that i am not able to bring the values of tags over the report under the tags.
Code :-
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Trial Balance Tag print -->
<template id="report_trialbalance" inherit_id="account.report_trialbalance">
<xpath expr="//table[#class='table table-condensed']//thead//tr//th" position="after">
<th>Tags</th>
</xpath>
<xpath expr="//table[#class='table table-condensed']//tbody//tr//td" position="after">
<td t-foreach="Accounts" t-as="account">
<span t-att-style="style" t-esc="account['tag_ids']" t-options="{'widget': 'many2many_tags'}" />
</td>
</xpath>
</template>
</data>
</odoo>
Please if anyone could help me out on bringing the values of tag in report,
Thanks in advance.

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.

Add custom text in qweb report odoo9

How add custom text in inherit qweb?
For example in Sale/view/report_saleorder.xml
below class="oe_structure" i need one table
<p t-field="doc.note" />
<p t-if="doc.payment_term_id.note">
<span t-field="doc.payment_term_id.note"/>
</p>
<p t-if="not doc.payment_term_id and doc.partner_id.property_payment_term_id">
<span t-field="doc.partner_id.property_payment_term_id.note"/>
</p>
<p id="fiscal_position_remark" t-if="doc.fiscal_position_id and doc.fiscal_position_id.note">
<strong>Fiscal Position Remark:</strong>
<span t-field="doc.fiscal_position_id.note"/>
</p>
<div class="oe_structure"/>
<xpath expr="???" position="???">
<table><tr><td>CUSTOM TEXT</td></tr></table>
</xpath>
I am not sure if the above xml is the whole report however you could use something like this.
<xpath expr="//div[#class='oe_structure'][last()]" position="after">
<!-- YOUR TABLE HERE -->
</xpath>
This assumes this is the last instance of oe_structure in the xml you are inheriting from.