I want to hide actual field value in xml and make it as href in my xml form.
Just like Visible Link ...
TIA
Odoo forms support an URL widget:
<field name="my_field" widget="url" />
See the field "Website" on the Partners/Customers form.
Related
Currently, I had a view form and there is some field that need to be hide or unhide by click a button.
I tried to use State, Boolean field but unable to achieve the result.
My question is could I do it on Odoo and how?
I used State and Boolean field and set by condition on field, however the result was not good.
When a user clicks a button, hidden field will appear back
Yes, you can do it.
Button action in odoo triggers write method before being executed.
You should be aware of this before implementing your logic and your domains in order to show/hide fields in XML Views.
Your need is to use invisible attribute applied to a domain inside your field.
invisible is normally static, but can be elasticised inside attrs attribute.
Another important thing is, field-based domains requires the field to be present in view in order to access it. A good practice is to make these fields invisible and put them on top of your view.
In your model:
show_fields = fields.Boolean(default=False)
field_to_show = fields.Char()
def show_fields_action(self):
for record in self: record.show_fields = True
In your view:
<field name="show_fields" invisible="1" />
<field name="field_to_show" attrs="{'domain': [('show_fields','=',True])}" />
<button name="show_fields_action" type="object" string="Show Fields" />
If your question UI/UX related, consider using notebooks instead.
Is there any way to put into website template Selection field (fields.Selecton) of some model or dropdown selection of some model records ?
Or only one way is to call some python methods and get some data and then put it data into web page using JS ?
It turned out that you can add field using editor.
Also all fields are in the black list for website posting by default. To remove it from blacklist you will need to do stuff like this:
<function model="ir.model.fields" name="formbuilder_whitelist">
<value>crm.lead</value>
<value eval="[
'contact_name',
'description',
'email_from',
'name',
'partner_name',
'phone',
]"/>
</function>
I am using v7 and I want to show in a tree view a field with image icons (like a semaphore) depending of other field values in the same row.
Actually, I get the functionality I want with a function field and put the result as string but I really want it as an image. I don't know if is possible to return HTML from the function so I decided to do that with jQuery.
I implemented the jQuery code using the browser console and works but when I put the jQuery code in the view the "data-field" selector does not selected.
Please, can anyone explain me why or tell me another way to get my objective?
Lists
The root element of list views is tree. The list view's root can have the following attributes:
editable, default_order, colors, fonts, create, edit, delete, on_write, string
See more about ListView
You can achieve this by defining child elements button in list view.
I have added icon in product to show whether product is available / hold / sold based on product's status.
button
icon: icon to use to display the button
Xml code to display icon in listview.
<xpath expr="//notebook/page[#string='Order Lines']/field[#name='order_line']/tree[#string='Sales Order Lines']/field[#name='product_id']" position="before">
<field name="product_status" invisible="1" />
<button icon='Hold' readonly="1" attrs="{'invisible':[('product_status', '!=', 'hold')]}"/>
<button icon='Available' readonly="1" attrs="{'invisible':[('product_status', '!=', 'available')]}"/>
<button icon='sold' readonly="1" attrs="{'invisible':[('product_status', '!=', 'sold')]}"/>
</xpath>
NOTE
Remember base field on which you defined button's visibility must be
present on listview, doesn't matter whether it's visible or not but it
must be there, like product_status in above example.
base field must be store=True.
Why store=True ?
Reason: when you set any function field store=True then it will physically created in database, while you give this field name in
domain the odoo framework add this field directly in WHERE clause,
it will not access through browsable object, so if your field is
store=False then it won't be able to find that field and gives you an error.
icons must be present in web/static/src/img/icons.
if you want to keep icons in your custom module then you have to create the same hierarchy for that in side your module folder create /static/src/img/icons and keep all the icons there.
xpath is used to define at which location you want to add/update fields.
See more about xpath
I am trying to create an enhanced rich text field using a schema.xml. Currently I have the following:
<Field ID="8EE65A51-1427-4D5A-8DD0-3712BE5991F0" Name="AudioLinks"
DisplayName="AudioLinks" Type="Note" NumLines="1" RichText="TRUE"
Description="Audio Link URL."/>
The above creates a Rich Text field.
How would I go about creating that into an Enhanced Rich Text field instead?
Stuck with this for over a day now. Any assistance would be greatly appreciated
Many Thanks,
Try setting the RichTextMode attribute to FullHtml:
<Field ID="8EE65A51-1427-4D5A-8DD0-3712BE5991F0"
Name="AudioLinks"
DisplayName="AudioLinks"
Type="Note"
NumLines="1"
RichText="TRUE"
RichTextMode="FullHtml"
Description="Audio Link URL."/>
For more information see:
Field Element (List)
Creating an Enhanced Rich Text Field in your SharePoint Content Types
How do you display data in a 'textarea' using struts application,
This is my code:
<html:textarea property="comments" </html:textarea>
<bean:write name="FormBean" property="comments"/>
where FormBean is my beanclass and comment is a property in beanclass.
But I cannot get it too work.
Thanks in advance for your help.
If you use Struts action forms and you have the html:textarea tag inside your html:form tag (this tag is only valid when nested inside a form tag body) then the following code is all you need:
<html:textarea property="comments" />
Don't know what you are trying to do with bean:write but if you want to display that inside your html:textarea I'm not sure you can. The property attribute is mandatory for the html:textarea tag and will use that as the content.