I created a report with a table that has columns with the name, in the XML the name is in english but I would like to translate them into other languages, at the moment I tried with Italian but they remain in English. Column names are not the name of any model field.
To create the report I took the odoo addons as an example, then to create the cycle report on docs by passing it partner_id.lang when I call the template.
As can be seen from the image on the screen, the lang value is also shown
call the report with docs loop
<template id="report_certificate">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="lang" t-value="o.partner_id.lang"/>
<t t-call="ngo_payment_certificate.report_certificate_view" t-lang="lang"/>
</t>
</t>
</template>
<template id="report_certificate_view">
<t t-set="o" t-value="o.with_context(lang=lang)" />
<t t-call="web.external_layout">
<t t-set="address">
<address t-field="o.partner_id" t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
<div t-if="o.partner_id.vat" class="mt16"><t t-esc="d.company_id.country_id.vat_label or 'Tax ID'"/>: <span t-field="o.partner_id.vat"/></div>
</t>
<div class="page">
<p t-esc="lang"></p>
<h3 class="text-left mt16">Donations</h3>
</div>
</t>
</template>
I created the po file and added it to the addon by correctly translating the words. I reloaded the language by overwriting and restarted the server but nothing. He does not translate words for me.
Can you help me? After much research I was unable to find a solution.
The rest of the addon, form, treeview etc, are translated correctly
I use Odoo 12 CE Odoo 12.0-20200121
Part of po file exports by settings
#: code:addons/ngo_payment_certificate/wizards/ngo_donor_donation_report_wizard.py:17
#: model:ir.model.fields,field_description:ngo_payment_certificate.field_ngo_donor_donation_report_wizard__annual_donation_ids
#: model_terms:ir.ui.view,arch_db:ngo_payment_certificate.report_certificate_view
#, python-format
msgid "Donations"
msgstr "Donazioni"
I have tried to modify like this (like sale po file)
#. module: ngo_payment_certificate
model_terms:ir.ui.view,arch_db:ngo_payment_certificate.report_certificate_view
msgid "Donations"
msgstr "Donazioni"
Related
I have been trying many different ways for hiding the sidebar button. Below code is working on all forms. However, i just want to hide it on sale order form. Widget.modelName seems not working because it is before the form declaration. I also tried doc_model in [sale.order'] and not working as well. How can I solve it? thanks
<t t-jquery = ".o_cp_left" t-operation = "replace">
<t t-if = "widget.modelName == 'sale.order'">
<div class="o_cp_left hiddenManagerSO">
<div class="o_cp_buttons" role="toolbar" aria-label="Control panel toolbar"/>
<aside class="o_cp_sidebar"/>
</div>
</t>
<t t-if = "widget.modelName !== 'sale.order'">
<div class="o_cp_left hiddenManagerKOO">
<div class="o_cp_buttons" role="toolbar" aria-label="Control panel toolbar"/>
<aside class="o_cp_sidebar"/>
</div>
</t>
</t>
</t>
Im trying to extend the point of sale, template to modify the web ticket and the printed version also.... I want to put a codebar with the id numbe. But reading and testing my code doesn't work.... For testing purpuse I put a text in several parts of the template to watch if it is modify... but it's not.
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="XmlReceipt">
<t t-jquery=".receipt-change" t-operation="inner">
<div><span>hello world</span></div>
</t>
</t>
<t t-extend="PosTicket">
<t t-jquery=".receipt-orderlines .product_line" t-operation="inner">
<div><span>hello world</span></div>
</t>
</t>
<t t-extend="PaymentScreenWidget">
<t t-jquery="div.pos-payment-container" t-operation="inner">
<div>
Payment Screen Modified
</div>
</t>
</t>
</templates>
This code is in a file name pos.xml and I append it from openerp.py like this:
'qweb': ['static/src/xml/pos.xml'],
Why the XmlReceipt or the PosTicket or the payment template are not extending????
Then when I sucessfully extend the template, Im gonna try to replace the hello world with
<barcode encoding="CODE128"><t t-esc="o.id"/></barcode>
Thanks!
[EDIT]
Ok, now I'm extending the template, but I cant generate the barcode from the order.sequence_number
I'm trying like this:
<img class="img-responsive" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', order.sequence_number, 500, 100)" style="width:250px;height:50px;"/>
The barcode its not generate like this... but if I do it like this it is
<img t-att-src="'/report/barcode/Code128/*mycode*'" style="width:250px;height:50px;"/>
So I think the error is in the string rendering.....
This is how I extends the mail chatter in odoo-10 and it's working fine for me.
Take a look, may be its help if still needed.
<templates>
<!--
Chatter composer
-->
<t t-extend="mail.chatter.ChatComposer">
<!-- Insert information before the composer -->
<t t-jquery=".o_composer_suggested_partners" t-operation="replace">
<!-- List of followers -->
<div class="o_composer_suggested_partners">
<t t-foreach='widget.suggested_partners' t-as='recipient'>
<div t-attf-title="Add as recipient and follower (reason: #{recipient.reason})">
<input type="checkbox" t-att-data-fullname="recipient.full_name"/>
<t t-esc="recipient.name"/>
<t t-if="recipient.email_address">(<t t-esc="recipient.email_address"/>)</t>
</div>
</t>
</div>
</t>
</t>
</templates>
I am using Odoo 10e. In tree view or in form view for my particular model, i want to change the create button text to Add New User. How can we achieve this?
I tried to use Xpath for this, but as far as i know Xpath is use to inherit from a view and add something in the view not to change the item in the parent view
Create one xml file and write this below code in it.
For listview and formview it will change the name of create button as per your custom string.
Add this xml file path to qweb section in manifest file.
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery=".o_list_button_add" t-operation="replace">
<button type="button" class="btn btn-primary btn-sm o_list_button_add" accesskey="c">
<t t-if="widget.model === 'sale.order'">
Your String
</t>
<t t-if="widget.model !== 'sale.order'">
<t t-esc="widget.options.addable"/>
</t>
</button>
</t>
</t>
<t t-extend="FormView.buttons">
<t t-jquery=".o_form_button_create" t-operation="replace">
<button t-if="widget.is_action_enabled('create')" type="button"
class="btn btn-default btn-sm o_form_button_create" accesskey="c">
<t t-if="widget.model === 'sale.order'">
Your String
</t>
<t t-if="widget.model !== 'sale.order'">
Create
</t>
</button>
</t>
</t>
</templates>
I hope this answer will help you.
Simply just xpath to that button.
Then give position replace and change the string to Add New User from Create.
Try the code like this.
But remember the name of the button will be as it is.
Thanks
<xpath expr="//button[#name='action_set_create']" position="replace">
<button name="action_set_create" string="Add New User"/>
</xpath>
I am new to odoo, I created a module by inheriting sales_order to create a custom report. I am getting the above error when I am printing the report. Need help please?
Here is the code snippets:
test/my_module.py:
class sale_order(models.Model):
_name = 'sale.order'
_description = 'Inheritance'
_inherit = 'sale.order'
test/views/report_template_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="test_report">
<t t-call="report.html_container">
<t t-call="report.internal_layout">
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})"/>
<div class="page">
<div class="oe_structure"/>
<div> <strong><left>User</left></strong>
<p t-field="doc.user_id"/>
</div>
</div>
</t>
</t>
</template>
</data>
How can I access records in custom_report_template?
i know i'm late but the name of the variable containing the recordSet passed to the template is docs not doc.
and you are trying to get value from a variable that don't have anything.
doc.with_context({'lang':doc.partner_id.lang})
i think you need to do docs not doc because doc is None
This why all template in loop docs :
<t t-foreach="docs" t-as="o">
How to hide the EXPORT Option in the more button for specific user group, and how to hide the 'MORE' button for specific user group in openerp 7.
Hide "Export in More Option"
in OpenERP-7
Create XML File Under static/src/base.xml in your module and add this code:
<templates>
<t t-extend="Sidebar">
<t t-jquery="a.oe_sidebar_action_a" t-operation="replace">
<t t-if="widget.session.uid !== 1">
<a t-if="item.label !== 'Export'" class="oe_sidebar_action_a" t-att-title="item.title or ''" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank">
<t t-raw="item.label"/>
</a>
</t>
<t t-if="widget.session.uid === 1">
<a class="oe_sidebar_action_a" t-att-title="item.title or ''" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank">
<t t-raw="item.label"/>
</a>
</t>
</t>
</t>
</templates>
Add this in File __openerp__.py:
'qweb': [
"static/src/base.xml",
]
Now restart the server and update your database and refresh the page.