Odoo 8 - How change content in div class="page" - odoo

i have Odoo 8 and i trying to edit content of template of invoice/order and more. I managed for now to change the header and footer entering in external_layout and external_layout_header/footer (From backend of Odoo). But i don't know how change content of div class="page".
Which files should i change?
Thanks for any help

I think what you are hoping to do is inherit from a particular report. Once you have inherited from the report you can use xpath to select the node in that report template.
<template id="template_name" inherit_id="other_addon.template_name">
<xpath expr="//div[#class='page']" position="replace">
<!-- YOUR CONTENT HERE -->
</xpath>
</template>

Related

custom layout in form views in Odoo 14

I need a form view and I need its layout to be customized, using directly the Bootstrap 4 styles
How exactly can I do that ?
Also
I need some fields/tabs to appear conditionally (if some values is true) and such conditionally appearing fields need to be in my custom layout
Is this possible ?
How ?
First of all, I could use an example of a custom layout
And then I could use some enlightenment on how the conditional appearing of fields is done, behind the scenes
Thanks in advance
You can create a form view using any html you like. You can also use xpath to load custom css and javascript, such as bootstrap. You should load the xpath straight after your opening form tag.
<xpath expr="." position="inside">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</xpath>
There a couple of ways to show things conditionally. I find the following example easiest when using the form views:
<div id="my-div" attrs="{'invisible': [('field','==',True)]}">Do not show this text if the field is true</div>

(Odoo) Include CSS and JavaScript files on a single page

My question is how can I include/import a couple of JavaScript and CSS files in the header of a single page. I know that you can include the files in the web.assets_frontend or web.assets_backend but that causes those scripts and links to appear on every page across the frontend or backend part of Odoo. This causes the downgrade of the speed of the website.
Thanks
Reject a Deferred object and call any fail Callbacks with the given args.
In your js files, add the following inside your "odoo.define" and right after your "require" statements:
if(!$('.attachment_static').length) {
return $.Deferred().reject("DOM doesn't contain'.attachment_static'");
}
This will only execute the js if it finds any html element with the class "attachment_static" when loading any page of the website
you can use the <script> tag If you are talking about <form> tag in backend view, here is an example for you.
<form string="Product Collection">
<group col="4">
<field class="my_field" name="name"/>
</group>
</form>
<script>
var my_field = $('.my_field')
console.log(my_field)
</script>
It'll only load this JavaScript when your form view is loaded.

How can i upload html5 bootstrap theme to odoo?

I have odooo online account, how can i import bootstrap theme purchased on themeforest, in the odoo? or what i should do to convert current normal theme to be working with odoo?
you could try to add the css file and the js-script file to your assets_common. Odoo will then minimise all the CSS and JS Files into one (or slightly more) files.
In addons/web/views/webclient_templates.xml you can see how the built in bootstrap is added in odoo.
So if you want to add something to all of the javascript files you can do it like this:
<template id="assets_frontend" inherit_id="web.assets_frontend" name="<name of your addition>" priority="15">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="<path to your js file>"</script>
</xpath>
But adding a CSS or JS that isn't built for odoo might cause problems since selectors might be overwritten or you use different bootstrap versions.
I havent't tried it with Bootstrap Themes myself so there might be better solutions.

Fix an element "DIV" in the bottom of the page before the footer QWEB Invoice Report ODOO

I Want to fix a div element in the bottom of the page, just before the footer in the last page, it's a qweb report inherited from the standard invoice report of Odoo, the footer it's already visible only in the last page .
Any Idea ? suggestions ?
Here is a schema of what is wanted
Thanks,
As you mention your report inherits from the standard invoice report, I assume you already know that the standard invoice layout is a Qweb view named report_invoice_document and you have already defined a template like
<template id="your_module.report_invoice_document" priority="50" t-name="Your Module - Modifications to the Standard Invoice Layout" inherit_id="account.report_invoice_document">
<xpath expr="//div[hasclass('page')]" position="inside">
<div>Your content</div>
</xpath>
</template>
So the only issue is to fine tune both the XPath expression and the position. The whole report is inside a <div class="page"> tag, so using the above xpath tag will put your content just before the report's end.

Adding icons to menu items in odoo

I try to set an icon to menuitem, So I find that the attribute icon is supported, but No change happen when I change its value.
I want to know if it is still supported by menuitem in odoo v7/8. If not, how to add an icon to a menu item?
Edit:
I try to customize the view of the menu in odoo. So I override the template that render the menu in "webClient_templates.xml" from web module like this:
<template id="my_menu_link" inherit_id="web.menu_link">
<span position="replace">
<span class="oe_menu_text">
<i class="fa fa-check"></i>
<t t-esc="menu['name']"/>
</span>
</span>
</template>
Likely, all the menu items will have the same icon (i.e. fa-check) from font-awesome lib.
Now, I try to add a specific icon for each menu item, that I can define it somehow in the xml description of menuitem as a kind of attribute or anything else, and retrieve it like this:
<i t-attrs-class="menu['icon']"></i>
I tried to use icon attribute of menuitem, even if it's deprecated, but menu['icon'] is not recognized in the template level.
Please any suggestions ?
AFAIK displaying icons in menu items is deprecated and does not work on the web client. Probably the to achieve you would need to create a module for the web client extending it with that capability.
I'm using odoo v12 now, and there is also an unused field for icons on ir.ui.menu model.
I managed to show icons on backend's menus, here are the difference with your code:
The icon field is named web_icon, it may be specific to v10+ , I don't have a v8 to verify this.
The templating syntax to set attributes is t-att-<name> and not t-attrs-<name>
And most important: the menus in backend are generated using javascript, so the templates to modify are to find in web/static/src/xml/menu.xml
There are 3 places to add an <i> markup in 2 templates:
<t t-name="Menu.link">
Line 47: <span><i t-att-class="menu.web_icon"></i> <t t-esc="menu.name"/></span>
Line 59: <span><i t-att-class="menu.web_icon"></i> <t t-esc="menu.name"/></span>
<t t-name="Menu.sections">
Line 81: <i t-att-class="second_level_menu.web_icon"></i> <t t-esc="second_level_menu.name"/>
The data to set in menu's icon field is the whole font-awesome CSS classes:
fa fa-check
This is good if you add more icons sets, you won't need to modify again the templates.
But if you want to force the usage of font-awesome, or want to use another icon set like font-awesome solid (using fas class), you can use this markup in templates:
<i t-attf-class="fas fa-#{menu.web_icon}"></i>
(note t-attf-<name> to use "attribute function")
And so the data in the field will be only check...
And finally, the best should be to create a module to inherit the templates and make this modification against modifying it directly as I did...
And also add some more CSS styling to align icon and text correctly (here icons are not the same sized).