I am making a custom module in OpenERP. I have a list(tree) view and a form view. I can view and edit records.
When I take the mobile view of the same module, I can see the main menu and browse to the sub menu, but no list view or form view is visible. All I can see is a blank page. Is my list definition worng?
<?xml version="1.0"?>
<tree string = "Camera">
<field name = "a"/>
<field name = "b"/>
</tree>
I believe that after a menu option is selected, the following menu is a simple list with the name of each record.
It may be that you don't have any record yet.
Or it may be that you don't have a name field on the object model and views. Add that field (make it required) or, alternatively, set the object's _rec_name attribute (example: _rec_name = 'a').
OE Mobile View is read-only mode
It does not have any type of view(like, tree or for, or kanban), It just show the view of record and show you have value. It hos wht name filed valeu on list then if you click on it it open detail view which show thw other detail. and yes try and add the record on your model.
Thank You
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.
I defined a Many2many field for ir.attachemnt. The problem is i can' see the Add an item link to add the records.
*.py
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
*.xml
<notebook>
<page string='Attachments'>
<field name="attachment_ids"/>
</page>
</notebook>
I also tried this:
<field name="attachment_ids" widget="many2many" />
Any idea?
There is only two thing that make Odoo behave like this.
Your view is in edit mode but I think I'm seeing a place holder comments this means it's not the case
Your user is not allowed to create an ir.attachment which is more likely not the case
Your field is readonly.
If not one of this cases these is wired but if you didn't understand what happen you can force that link to appear by using embedded tree with create attribute set to true
<field..... >
<tree create='1'>
....
It'a a bug. If you have more many2many fields in the some class and for one of this you haven't right access rules, all the many2many fields are showed in readonly mode.
This is with Odoo 10 and the default bootstrap-datetimepicker.
I have a field in my view that has a "Start of event" datetime. I'd like the date picker that shows up to work in 5 minute intervals (minuteStepping: 5) and to show the time picker along with the date picker (sideBySide: true).
I've confirmed that this works as I want it to by editing addons/web/static/src/js/widgets/date_picker.js manually.
However, I'd prefer to just give the two options I want to change as a parameter to my <field ..> definition under my <form> tag in the view XML. The source Widget accepts an options parameter in its init method that it extends to end up with the final options object, but I've been unable to insert my configuration options into this object.
I tried giving it as <field ... options="{...}" and as .. t-field-options='..', but I'm guessing the latter won't work since I'm not in a qweb context in my view, and the first one isn't read by widgets.
Is there any way I can do this without creating a new widget? (and hopefully without subclassing or extending the existing widget, but keep it as a pure view configuration option instead)?
You can see a great example in this module. https://github.com/OCA/web/tree/10.0/web_m2x_options
In the file. static/src/js/form.js.
The module has overridden the fields Many2one to add different options can be set in the XML declaration of field.
Example : <field name="partner_id" options="{'search_more':true}" />
In this example. The search more button is visible in all cases.
You can use the logic of this module as a base of your widget extension.
Installation:
In a First time, you must download the Github repository.
https://github.com/jo541/web
Select the branch 10.0.
In the repository, there are a named module "web_widget_datepicker_options". This module gives you the possibility to specify any options as you want for a specific field.
After download and install the module on Odoo. You needing to reload the cache of your browser to be sure.
Modification:
Now you can modify your form view. For an example, I will use the view form sale.order.
In the form view sale.order, you have a field "date_order". If you would like to have the time step 5 by 5.
<field name="date_order" options="{'datepicker':{'minuteStepping': 5}}" attrs="{'invisible': [('state', 'in', ['sale', 'done', 'cancel'])]}"/>
All the options in the dict of the key datepicker will be adding to the option of the bootstrap datepicker.
Hello I have created a button on my Odoo 10 form "SET geprint" now i want to attach an action to the button. If i press the button the value of the boolean geprint must change to 1. How can I make this possible?
If possible i would also like to create that button in the list view to update multiple records.
Thx for your help
I tried your code but i am getting the following error now
(name field to update is x_geprint)
button code :
You can do it via following methods.
Create object type of button in form view. you can give button type="object", after that when you click on button then system will call python method In which you can write your code.
ex:
<button name="validate" string="Validate" type="object" states="draft" class="oe_highlight"/>
#api.multi
def validate(self):
self.write({})
return True
For the list view you need to create new wizard, In which you can select number of records from list view and in list view Action select your wizard name item.
Ex:
from openerp import models, fields, api, _
class test(models.TransientModel):
_name = 'test.test'
<act_window name="Name String" res_model="wizard.model"
src_model="source.model" view_mode="form" view_type="form"
target="new" multi="False"
id="your_id"
view_id="view_id"
context="{}"/>
In source model Action menu you can select wizard link and In the wizard you will get active_ids in context.
active_ids means all list-view selected records, based on that you can do it any operations with selective records.
This may help you.
Make a server action (settings - > technical - > Server actions)
After that search for the action number in your link please see image (my number is 638)
Then go to the form where you want to add the button. In my example its stock.move
Go into edit formview and add the following code
<button name="638" string=" Set geprint" type="action" />
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