How to add icon in list view Odoo? - odoo

Is it possible add icon instead text in list view?
Example:
<field name="status" />
If status = phone display (icon="fa-phone) else status = fax display (icon="fa-fax).
Field display with string fax or phone.

You need to change icon name.
Try with this:
<field name="status" invisible='1'/>
<button name="status" icon="fa-check text-success" attrs="{'invisible': ['|',('status','=','phone')]}" />
<button name="status" icon="fa-times-circle text-danger" attrs="{'invisible': ['|',('status','=','fax')]}" />

Related

Copy the Order Lines list into a simple text to a custom notebook (tab) in Odoo 13 CE

I got stuck to this customization for weeks. I'm using Odoo 13 CE.
I wanted to copy the Order Lines list into a simple text to a custom notebook (tab) in Odoo.
From this:
To This:
What I did were making the related fields & custom views.
py file:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
partner_id_wa = fields.Many2one(related='partner_id')
phone_wa = fields.Char(related='phone')
amount_total_wa = fields.Monetary(related='amount_total')
order_line_wa = fields.One2many(related='order_line')
order_line_waa = fields.One2many('sale.order.line', 'name', 'Order Lines', related='order_line')
product_id_wa = fields.Many2one(related='order_line.product_id')
product_uom_qty_wa = fields.Float(related='order_line.product_uom_qty')
price_subtotal_wa = fields.Monetary(related='order_line.price_subtotal')
xml file:
<notebook position="inside">
<page string="Special Notes">
<label for="special_notes_1" string="Special Notes"/>
<div class="o_specnotes_format border">
<field name="special_notes_1" placeholder="Header: Dear,..." class="o_specnotes_sn1"/>
<br></br>
<field name="special_notes_2" placeholder="Body: Happy Birthday..." class="o_specnotes_sn2"/>
<br></br>
<field name="special_notes_3" placeholder="Footer: Sincerely,..." class="o_specnotes_sn3"/>
</div>
</page>
<page string = "Invoice WA">
<div>
<field name="partner_id_wa" options="{'no_open': True}" readonly="1"/>
<br></br>
<field name="phone_wa" readonly="1"></field>
<br></br>
<field name="product_id_wa"/> - <field name="product_uom_qty_wa"/>: <field name="price_subtotal_wa"/>
<br></br>
<field name="amount_total_wa"></field>
</div>
</page>
</notebook>
It turned out showing only the first line of the order line, not all (Invoice WA tab).
Is there any other approach to do this better? How to correct it? Thanks!

How can i change address/ street format in customer form view (odoo 11)?

please, i want to change the address format in customer form view odoo? how can i do that?.
I tried to change the code to XML but nothing changes!
<xpath expr="//div[#class='o_address_format']" position="replace">
<div class="o_address_format">
<field name="street" placeholder="Street..." class="o_address_street"/>
<field name="city" placeholder="City" class="o_address_city"/>
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}'/>
<field name="zip" placeholder="Code postal"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
</div>
</xpath>
Finally there was another module that inherited the street field, so my code doesn't work; so the solution is to make the changes I wanted in the first module.
So my problem is solved

how hide button if have same name with different field based on user selection

For example below mentioned code
<button name="invoice_recreate" string="Recreate Invoice"/>
<button name="invoice_corrected" string="Ignore Exception" />
Add the field selection to the view and the attrs attribute to the button like this:
<field name="selection_field" invisible="1" />
<button name="invoice_recreate"
string="Recreate Invoice"
attrs="{'invisible': [('selection_field', '=', 'value')]}" />
<button name="invoice_corrected"
string="Ignore Exception"
attrs="{'invisible': [('selection_field', '!=', 'value')]}" />
I am not sure if this is what you are asking for, let me know if you are asking anything different

Odoo - calculation on add or edit of one2many field

I have customer and deposit field in customer form which is one2many actually but user add a line in deposit and submit or edit some existing. I want to do some calculations on that event . I tried onchange and compute both but its not working.
add or edit One2many fields is FormView.
so you just put the field what you what to do calculate in FormView *.xml
Ex. with my SUM fields
<record model="ir.ui.view" id="view_nstda_bst_dbill_form">
<field name="name">nstda.bst.dbill.form</field>
<field name="model">nstda.bst.dbill</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="nstda_bst_dbill" class="nstda_bst_dbill_form" >
<group>
<field name="status" invisible="1" />
<field name="matno" />
<!-- <field name="matdesc" /> -->
<label for="balance" />
<div>
<field name="balance" style="width: 20%%" />
<field name="uom_1" style="width: 10%%;"
attrs="{'invisible':[('matno','=',False)]}" />
</div>
<label for="balance_rs" />
<div>
<field name="balance_rs" style="color:Red;width: 20%%" />
<field name="uom_2" style="width: 10%%;"
attrs="{'invisible':[('matno','=',False)]}" />
</div>
<label for="qty" />
<div>
<field name="qty" style="width: 20%%"
attrs="{'required':[('status','in',['draft','edit',False])]}" />
<field name="uom" style="width: 10%%;"
attrs="{'invisible':[('matno','=',False)]}" />
</div>
<!-- <field name="unitprice" /> -->
<label for="unitprice" />
<div>
<field name="unitprice" style="width: 20%%" />
<field name="currency" style="width: 10%%;" />
</div>
<field name="sum" invisible="1" />
<field name="dbill_discount_sum" invisible="1" />
</group>
</form>
</field>
</record>
and the *.py side is...
Ex.
#api.one
#api.onchange('qty','matno')
#api.depends('qty','matno')
def _set_sum(self):
self.sum = self.unitprice * self.qty
sum = fields.Float(string="summary", store=True, compute='_set_sum')
matno = fields.Many2one('bst.stock', 'matno')
qty = fields.Integer('qty')

How to display button and status bar items in line

How to display below mentioned two group(marked in red circle) in line?
relevant code for the same is given below
<header>
<button name="mymod_assigned" class="oe_highlight" type="workflow" string="Assigned" state="new" />
<button name="mymod_negotiation" class="oe_highlight" type="workflow" string="In Negotiation" state="assigned" />
<button name="mymod_won" class="oe_highlight" type="workflow" string="Won" state="negotiating"/>
<button name="mymod_lost" class="oe_highlight" type="workflow" string="Lost" state="negotiating"/>
<field name="state" widget="statusbar"
statusbar_visible="new,assigned,negotiation,won,lost"
statusbar_colors='{
"new":"blue",
"assigned":"blue",
"negotiation":"blue",
"won":"red",
"lost":"red"
}'
/>
</header>
Try putting left group of buttons in one div with float:left and right group in another div with float:right.