Skip to Content
Menu
This question has been flagged
1 Reply
2097 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.


Avatar
Discard
Author Best Answer

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>
Avatar
Discard