Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[V8] Show 'Invoiced' magic button for specific group in partner form view

By
Aurélien Rivet
on 6/24/16, 10:26 AM 125 views

Hi all,

I want to change the behaviour of the 'Invoiced' "magic button" in partner form view.

I noticed that the crresponding field is defined as follow:

_columns = {

     'total_invoiced': fields.function(_invoice_total, string="Total Invoiced", type='float', groups='account.group_account_invoice'),

}

What does this 'kwarg' argument "groups" mean ? 

I couldn't find any documentation about it, so I supposed it makes the field accessible only for users who belong to the 'account.group_account_invoice'.

Now I've created a custom group. How can I add it to the list of authorized groups ?

I tried to redefine the field using V8 API and following syntax

total_invoiced = field.Float(groups='account.group_account_invoice,custom.my_custom_group')

But it doesn't seem to work.

Same using the old API syntax.


0
Aurélien Rivet
On 6/24/16, 3:20 PM

Ok I dit it.

What I didn't know is that I had to do two things. First I had to override the field. I did it with the legacy syntax because it didn't seem to work with the new one:

_columns = {

     'total_invoiced': fields.function(_invoice_total, string="Total Invoiced", type='float', groups='account.group_account_invoice'),

}

But I didn't know that I also had to allow the group to see the corresponding view.

To do that, two ways: GUI or code.

First, find the xml_id of the view you want to show.

You can do it in the Config > Groups > Your group and Views tabs.

In my case, it was account.partner_view_buttons.

Then, add a view line in the views tab of your target group.

To do it with xml file:

		<record id="sale.group_sale_invoice" model="res.groups">
			<field name="name">Watch Invoices</field>
			<field name="category_id" ref="base.module_category_sales_management"/>
                            <!-- The following line does the trick -->			                            <field name="view_access" eval="[(4, ref('account.partner_view_buttons'),0)]" />
		</record>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/24/16, 10:26 AM
Seen: 125 times
Last updated: 6/24/16, 3:21 PM