Colors in Tree View Odoo 9 ERROR - odoo

Good Day!,
I've trying to Migrate my Odoo8 to 9 But I have an error in One2Many Grid Colors
here's my code
<group>
<data>
<field name="employee_documents" string ="">
<tree colors = "red:expired=='EXP'">
<field name="document"/>
<field name="document_number"/>
<field name="date_issued"/>
<field name="date_expiry"/>
<field name="issuing_authority"/>
<field name="place_ofissue"/>
<field name="expired" />
</tree>
</field>
</data>
</group>
and I having an Error
Uncaught Error: QWeb2 - template['ListView.rows']: Runtime Error: Error: QWeb2 - template['ListView.row']: Runtime Error: Error: NameError: name 'expired' is not defined
I found out the colors attribute is causing the error because when I remove it my grid is not causing an Error,
Is there new way in Odoo 9 to do this thanks

This is the correct way to add color attribute in treeview. You should check your .py file where you have defined the field expired.
From the error it is clear that this error is related to the definition of the field, not due to the color attribute. At runtime your filed expired is not located. That is why you are getting this error.

For v9, colors are gone - replaced by the following decorators:
decoration-bf - shows the line in BOLD
decoration-it - shows the line in ITALICS
decoration-danger - shows the line in LIGHT RED
decoration-info - shows the line in LIGHT BLUE
decoration-muted - shows the line in LIGHT GRAY
decoration-primary - shows the line in LIGHT PURPLE
decoration-success - shows the line in LIGHT GREEN
decoration-warning - shows the line in LIGHT BROWN
The formatting is dependent on the bootstrap style, and these can be combined (the colors look better when shown bold)
https://www.odoo.com/fr_FR/forum/aide-1/question/set-color-in-tree-view-based-on-task-stage-94556

From Odoo9 onward colour attribute as like odoo8 version is being depricated.
In odoo8 we can keep color for tree view rows like this
<tree string="tree_view_BT" colors="red:state == 'inact'">
This is being depricated in odoo9. In odoo9 you can only use a set of defined colors only.
In odoo9, tree views can take supplementary attributes to further customize their behavior as follows:
decoration-{$name} : This attribute allows changing the style of a row's text based on the corresponding record's attributes.
{$name} can be replaced with bf for having font weight as bold.
For example decoration-bf="condition("state=='open'")"
For italics keep as decoration-it="condition"
Odoo9 support only bootstrap contextual colors such as
bootstrap contextual colors (danger, info, muted, primary, success or
warning).
Bootstrap contextual colors
decoration-danger='condition' for Red
decoration-info='condition' for Blue
decoration-muted='condition' for Grey
decoration-primary='condition' for Purple
decoration-success='condition' for Green
decoration-warning='condition' for Orange

Actually colors are deprecated from V9. we can use like this
Decoration-danger as red and decoration-info as blue.

Related

Custom color palette in Calendar view Odoo 8

I am trying to display a model on the calendar view,
<calendar date_start="check_in" date_stop="check_out" quick_add="false" color="state"
display="[guest]">
<field name="guest"/>
<field name="state"/>
</calendar>
where the state can be 4 possible values, but i don't know how to specify the color palette, the default one isn't like i want it, any idea how to? for example for each state i wanna specify a color

Can't add items to Many2many in Odoo 12 EE

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.

report print dropdown odoo

I have to add an item in print menu from purchase order tree view in odoo 8.
i am unable to find where is current Purchase Order reports added in print menu. i researched and found there is a tag from below:
https://www.odoo.com/forum/help-1/question/how-to-add-an-item-to-the-more-drop-down-list-in-sales-module-61833
also tried below, but i am getting qweb error :
<act_window name="Print Receiving Wkst"
res_model = "purchase.order"
src_model = "purchase.order"
key = "action"
key2="client_print_multi"
value="ir.actions.act_window,action_report_print_receivePO"
id="act_print_recevg_wkst"
/>
my custom report is in "test" module with id "action_report_print_receivePO"
I am getting error for value tag i think.
Basically i have to add new entry in print menu from purchase order tree view. so that when ever it is clicked custom report is printed. moreover if more than one PO selected, it will create PDF of all the POs
Thanks,
You don't need to go through the stress of creating an action and then adding a new item to the "More dropdown". Odoo already provides a way for you do this. just set menu = True when you're registering your report and a Print option would appear in the "More dropdown" that prints your report.
<report
id="purchase_order_report"
string="Purchase order"
model="purchase.order"
report_type="qweb-pdf"
file="purchase.order.file"
name="purchase.order.report"
menu="True"
/>
For more information on what the other parameters mean please refer to the
docs
just in case you might want to generate reports of a different types not fully supported by Odoo, such as py3o you'll definitely need to create a report action as defined in the official doc. For example:
<record id="account.account_invoices" model="ir.actions.report">
<field name="report_type">py3o</field>
<field name="py3o_filetype">odt</field>
<field name="module">my_custom_module_base</field>
<field name="py3o_template_fallback">report/account_invoice.odt</field>
</record>
However for your action to appear in the Print dropdown list, you must add two more fields to the record
<field name="binding_model_id" ref="model_my_custom_module_base"/>
<field name="binding_type">report</field>
Hope this helps anyone in the future!!
NB: Here I'm using the py3o reporting engine. Check it out as an alternative to the native qweb engine.

Disable one2many popup odoo 8

Good Day! is it possible to disable pop of tree view in the form. I tried no_open="True" readonly="1" edit="False" both on field and tree view but didn't worked.
<field name="payment_line">
<tree editable="top" create="false">
<field name="product"/>
<field name="description"/>
<field name="account"/>
<field name="unit"/>
<field name="qty"/>
<field name="amount"/>
<field name="total"/>
</tree>
</field>
I've coped with the same issue in odoo 10, my one2many treeview always make a popup on click. No matter editable='bottom' option was set.
Suddenly I've found web_tree_no_open module from codingforfun, that adds a new option:
< tree open="false" >
It's for version 8 but it can be used in 10 just renaming openerp.py to manifest.py
It can be downloaded from here:
https://github.com/initOS/web/tree/8.0-tree-view-no-select/web_tree_no_open
Worked for me, I hope it helps
Use this style to disable click in read as well as edit mode:
<field name="your_o2m" style="pointer-events:none;" />
Use editable='bottom' in this case, like:
<field name='line_ids'>
<tree create='false' editable='bottom'>
<field name='so_line_id' readonly='1'/>
<tree>
</field>
Odoo Version 10.0
web_tree_no_open module adds a new option: <tree open="false">
Lists
The root element of list views is <tree> 3. The list view's root can have the following attributes:
editable
by default, selecting a list view's row opens the corresponding form view. The editable attributes makes the list view itself editable in-place.
Valid values are top and bottom, making new records appear respectively at the top or bottom of the list.
The architecture for the inline form view is derived from the list view. Most attributes valid on a form view's fields and buttons are thus accepted by list views although they may not have any meaning if the list view is non-editable
default_order
overrides the ordering of the view, replacing the model's default order. The value is a comma-separated list of fields, postfixed by desc to sort in reverse order:
<tree default_order="sequence,name desc">
create, edit, delete
allows disabling the corresponding action in the view by setting the corresponding attribute to false
on_write
only makes sense on an editable list. Should be the name of a method on the list's model. The method will be called with the id of a record after having created or edited that record (in database).
The method should return a list of ids of other records to load or update.
string
alternative translatable label for the view
Deprecated since version 8.0: not displayed anymore
Note
if the list view is editable, any field attribute from the form view is also valid and will be used when setting up the inline form
view
in the form and tree view you can add create='false' to disable the create button and edit='false' to disable the edit button.Also use editable="top" or editable="bottom" if you dont want the form view to popup. for example
<tree string="Sale Order" create="false" edit="false" editable="bottom">
...
...
...
</tree>

OpenERP. Add image into field dynamically in a tree view

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