Extend list view and add custom styling [closed] - odoo

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am working with one2many list view and there is a state column in that i want to add custom css based on state of the object. Like if state is Completed make the text bold and background green somthing like that for other states. I tried but didn't found any way to add custom css or css classes based on condition. So i am now trying to extend list view in javascript and then i will loop through all rows and then add colors on them . Is this possible in Odoo ?

This can help if you want to change the entire row:
<field name="line_ids" >
<tree string="Lines" colors="red:state=='completed'" fonts="bold:state=='completed'">
<field name="name"/>
<field name="employee_id"/>
<field name="state"/>
</tree>
</field>
But if you want to change just one column maybe this post can help you: Bold in listview for many records
I hope I've helped.

Related

How to add new button near the create button in odoo 16 community? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
I'm new to odoo and i want to add button near odoo create button like in picture.
Somebody, please can help me.
Thank you
i don't find a possibility to implement that in my xml tree view
In tree/list views you can add action buttons next to the create button by defining a header right after the <tree> node.
For example from the purchase app of Odoo 16, which adds a button for bills creation:
<tree string="Purchase Order" decoration-info="state in ['draft', 'sent']" decoration-muted="state == 'cancel'" class="o_purchase_order" js_class="purchase_dashboard_list" sample="1">
<header>
<button name="action_create_invoice" type="object" string="Create Bills"/>
</header>
<field name="priority" optional="show" widget="priority" nolabel="1"/>
<!-- ... -->
</tree>
Near create button you cannot add from xml, if you want that you have to add it from js.

Learning Selenium and I have some questions about locating a specific xpath [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I'm trying to play around with elements on Reddit but after searching I am unable to select the 'View More' element. I don't have much experience working with the framework and I thought I understood Xpaths but I am unable to figure out where I'm going wrong
I am revising Xpaths right now and will post if I find a solution myself.
Here's an image to hopefully make things clearer:
Here are the paths I have tried:
driver.FindElement(By.XPath(".//class='s13lw6dy-6 cOyQoR']//*[text()='View more']")).Click();
I am using the following imports:
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;
If you right-click the HTML element and click 'Inspect,' you can get an Xpath for that element in the page. You should be able use that in your selenium code, if it isn't dynamic (doesn't change from one page load to another).
xpath = "//*[#id="SHORTCUT_FOCUSABLE_DIV"]/div[2]/div/div/div/div[2]/div[3]/div[1]/div[2]/div/a"
button = find_element_by_xpath(xpath)
# another possible xpath:
# button = find_element_by_xpath("//a[contains(text(),'View more')]")
button.click()

How make my custom module visible in app switcher odoo12 through code

I am new to the odoo and I developed a small custom module in odoo12. The problem is I am not able to see my custom module in the app switcher page after installing the module. (Below I gave the image link, where I am not able to see the module I have created after installing).
This is the link
The first step is you must define a menuitem, if you do not set a "parent" it will be a root menu and will therefore appear in the app drawer.
<menuitem
id="model_menu_root"
name="Module Menu"
web_icon="module_name,static/description/icon.png"
groups="base.group_user"
sequence="6"
/>
You will probably want to have submenus to access your models, they will use this menu as their parent.
<menuitem name="Model Name" id="menu_1_list" parent="model_menu_root"
action="action_window"/>
And the menu refers to the window action, which controls how your model is displayed.
<record model="ir.actions.act_window" id="action_window">
<field name="name">Model Name</field>
<field name="res_model">module_name.model_name</field>
<field name="view_mode">tree,form</field>
</record>
You will need to define some security rules, otherwise the menu will not appear. These are controlled in the ir.model.access.csv file which must be declared in the __manifest__.py file. In previous versions skipping this step would be fine for testing purposes as the admin user would be able to see all models but this seems to have changed in v12 and you will need to define security rules before the menu becomes visible. Security rules are explained in the odoo developer docs https://www.odoo.com/documentation/12.0/reference/security.html
By the way, for a problem like this, usually the first place I would look would be the Odoo source code on GitHub. You can see how they have implemented the root menu and security rules on each of their modules and emulate it for your module.

Odoo switches pages when they become visible

I added additional pages (tabs) to a form view. Also I have a boolean field. For example.: lets say at view_partner_form when I click is a customer = True, additional page I added next to sales and purchases becomes visible. The problem is that odoo opens that pages that became visible. I don't want that, I consider it bug. I want to stay at Sales and Purchases.
If there is anyone with similar problems please share your solution.
Thanks!!!
You have a possibility to use the autofocus in the XML.
Example
<page autofocus="autofocus">
<field name="customer"/>
...
</page>

How to add a custom fields created in Employee Module to Leave Request Module in openerp 8?

I had created two new fields in for Employee Model via the database structure and modified the form view of employee model to display both the fields. They are displaying perfectly. Now I want to refer to these new fields in the Leave Request Module. I don't know how to display it. I tried adding it similarly like I did for Employee Model but it doesn't help. Could you help in achieving this?
what is the code you've got so far?
are you using xpath?
this might be the solulation for your problem.
<xpath expr="//field[#name='thenameofthefieldfromcurrentview']" position="after">
<field name="thenameofthefieldyouwanthere"/>
</xpath>