Odoo's qweb groups_id - odoo-11

With Odoo's Qweb, i wanna apply a restriction into actions.
I wanna remove some contacts into list with 'is_b2c' is True.
<record id="action_contacts" model="ir.actions.act_window">
<field name="name">Contacts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="search_view_id" ref="base.view_res_partner_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a contact in your contacts directory.
</p><p>
Odoo helps you easily track all activities related to
a customer: discussions, history of business opportunities,
documents, etc.
</p>
</field>
</record>
The restriction must be:
<record id="contacts.action_contacts" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">
[
('is_b2c','=', False) <!-- Get contacts with 'is_b2c' is False for -->
]
</field>
<!-- for this group name only -->
<field name="groups_id" eval="[(6,0,[ref('sales_team.group_sale_salesman')])]"/>
</record>
Thanks

Instead of adding a group on the action, create two separate menu items and also create two separate actions and then add groups on these menu items. On one of the actions add the domain to show only limit contacts.

Related

What is a rule and how to inherit it and edit it in odoo 10?

So I created this user named Eric and I want him to manage all the features in gamification module. When I go to gamification security I found these rules:
<record id="goal_user_visibility" model="ir.rule">
<field name="name">User can only see his/her goals or goal from the same challenge in board visibility</field>
<field name="model_id" ref="model_gamification_goal"/>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
<field name="domain_force">[
'|',
('user_id','=',user.id),
'&',
('challenge_id.user_ids','in',user.id),
('challenge_id.visibility_mode','=','ranking')]</field>
</record>
<record id="goal_gamification_manager_visibility" model="ir.rule">
<field name="name">Manager can see any goal</field>
<field name="model_id" ref="model_gamification_goal"/>
<field name="groups" eval="[(4, ref('base.group_erp_manager'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
<field name="domain_force">[(1, '=', 1)]</field>
</record>
But I can't find them in the user interface so I can put Eric in one of them. Isn't a rule the same as a group? If not how can I deal with this? Thanks.

How to manage security of model, such as only sales manager should be able to create, delete, write and read those records in odoo 10

I am new in odoo and want know how to manage security in module,
O have created one model and now gives group that can only see my
record view, see below code that I have tried,
<record id="view_account_supplier_payment_tree" model="ir.ui.view">
<field name="name">account.supplier.payment.tree</field>
<field name="model">account.payment</field>
<field name="arch" type="xml">
<tree decoration-info="state=='draft'" decoration-muted="state=='reconciled'" edit="false">
<field name="payment_date"/>
<field name="name"/>
<field name="journal_id"/>
<field name="payment_method_id"/>
<field name="partner_id" string="Vendor"/>
<field name="amount" sum="Amount"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="state"/>
<field name="currency_id" invisible="1"/>
<field name="partner_type" invisible="1"/>
</tree>
</field>
</record>
Make an ir.model.access.csv file to manage security,
this file also mention in manifest file.

Odoo use both inherited Tree View and Parent Tree View

I created a special tree view for res.partner that help me modify records on the fly.
I put this view in a special Menu: test Configuration / Modification Rapide / Modification Contacts.
Everything is working fine expect that whenever there's a res.partner tree it's my tree view that is used.
Is there a way to use my custom tree view only from my Custom menu.
and every place else is the default tree view that is used ?
<record model="ir.ui.view" id="view_test_contact_tree">
<field name="name">res.partner.tree.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<field name="email" position="replace" />
<field name="phone" position="replace" />
<xpath expr="//tree[#string='Contacts']" position="attributes">
<attribute name="editable">bottom</attribute>
</xpath>
<xpath expr="/tree/field[#name='display_name']" position="before">
<field name="isBuyer" string="A"/>
<field name="isSeller" string="V"/>
<field name="isSupplier" string="F"/>
<field name="isMiddle" string="I"/>
<field name="isBackOffice" string="B"/>
</xpath>
<xpath expr="/tree/field[#name='display_name']" position="after">
<field name="mobile"/>
<field name="phone"/>
<field name="email"/>
</xpath>
</field>
</record>
<record model="ir.actions.act_window" id="action_res_partner_rel10">
<field name="name">Menu</field>
<field name="res_model">res.partner</field>
<field name="view_mode">tree</field>
</record>
<menuitem name="test Configuration" id="test_config_id" sequence="450"/>
<menuitem name="Modification Rapide" id="modif_id" parent="test_contact.test_config_id" sequence="20" />
<menuitem name="Modification Contacts" id="sub_gestion_modif_id" parent="modif_id" sequence="11" action="action_res_partner_rel10"/>
As I understand you want to show your own created tree view in this menu.
So for this you have to pass your create tree view in ref of action to open your tree view
Like:
<record id="action_quotations" model="ir.actions.act_window">
<field name="name">Quotations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_quotation_tree"/> <======= your tree view id
<field name="view_mode">tree,form,calendar,graph</field>
<field name="context">{'search_default_my_sale_orders_filter': 1}</field>
<field name="domain">[('state','in',('draft','sent','cancel'))]</field>
</record>
you have not have to inherit exits view and change in this, instead of create new tree view and pass in actions
Hope this help

Odoo v9 edit record with view_type=tree

I have to show the records of a custom module in a tree view (not list)
<field name="view_type">tree</field>
Instead of
<field name="view_type">form</field>
However, I would also like to be able to go to the records' corresponding forms when I click on them. Based on what I read, it's not possible, at least not by default. Is there any workaround to 'fix' it?
Here is my code:
<!-- Estrutura de Redes -->
<record id="edit_estrutura" model="ir.ui.view">
<field name="name">gestao.rede.estrutura.form</field>
<field name="model">gestao.rede.estrutura</field>
<field name="arch" type="xml">
<form string="Estrutura da Rede">
<header>
<!--<button name="" string="Desabilitar" type="object" states="habilitado"/>-->
<!--<button name="" string="Habilitar" type="object" states="desabilitado"/>-->
</header>
<sheet string="Estrutura da Rede">
<div class="oe_nome">
<label for="razao_social" class="oe_edit_only" string="Nome"/>
<h1>
<field name="name" string="Nome:"/>
</h1>
<label string="Pasta Acima:"/>
<field name="parent_id" options="{'no_create': True}"/>
<label string="Variável:"/>
<field name="variavel"/>
<label string="Pastas Abaixo:" class="oe_read_only"/>
<field name="pastas_filho" options="{'no_create': True}" class="oe_read_only"/>
</div>
</sheet>
</form>
</field>
</record>
<record id="view_estrutura_tree" model="ir.ui.view">
<field name="name">gestao.rede.estrutura.tree</field>
<field name="model">gestao.rede.estrutura</field>
<field name="field_parent">pastas_filho</field>
<field name="arch" type="xml">
<tree string="Estrutura da Rede" delete="true" editable="bottom/top" toolbar="1">
<field name="name"/>
<field name="pastas_filho"/>
<field name="parent_id"/>
<field name="variavel"/>
</tree>
</field>
</record>
<record id="open_view_gestao_estrutura_all" model="ir.actions.act_window">
<field name="name">Estrutura da Rede</field>
<field name="res_model">gestao.rede.estrutura</field>
<field name="view_type">tree</field>
<field name="domain">[]</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_estrutura_tree"/>
</record>
<menuitem action="open_view_gestao_estrutura_all" id="menu_action_estrutura" parent="menu_gestao_redes" sequence="20"/>
Thanks!
Editable Tree View
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
Example:
<tree editable="bottom/top">
<field name="xyz"/>
</tree>
Try this
<tree editable="bottom">
Add your fields
</tree>

Odoo - search_default does not work?

I created button in partner form to show another models relation with it. It is same button like Opportunities, Meetings, Sales button at partners form showing all its Opportunities, Meetings, Sales etc.
Code looks like this:
Model:
from openerp import models, fields
from openerp import api
class res_partner(models.Model):
_inherit = 'res.partner'
service_ids = fields.One2many('calendar.service', 'partner_id', 'Calendar Services')
service_count = fields.Integer('Services', compute='_count_services')
#api.one
#api.depends('service_ids')
def _count_services(self):
self.service_count = len(self.service_ids)
Action:
<record id="action_calendar_service" model="ir.actions.act_window">
<field name="name">Services</field>
<field name="res_model">calendar.service</field>
<field name="view_mode">tree,calendar,form</field>
<field name="view_id" ref="view_calendar_service_tree"/>
<field name="search_view_id" ref="view_calendar_service_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create new service.
</p>
</field>
</record>
View:
<record id="view_partners_form_service1" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited1</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="crm.view_partners_form_crm1"/>
<field eval="18" name="priority"/>
<field name="arch" type="xml">
<button name="schedule_meeting" position="after">
<button
class="oe_inline oe_stat_button"
attrs="{'invisible': [('customer', '=', False)]}"
name="%(calendar_service.action_calendar_service)d"
icon="fa-star"
type="action"
context="{'search_default_partner_id': active_id}">
<field name="service_count" string="Services" widget="statinfo"/>
</button>
</button>
</field>
</record>
Everything works with that button except for one thing. It does not filter result with partner_id (the one that button was pressed) and it opens all 'calendar.service' records. But it should show only the ones from that specific partner. Does context="{'search_default_partner_id': active_id}"> need something more? What am I missing here?
Finally found what was missing. I needed to add this line:
<field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>
In my model search view. Without that it does not use search_default filter.

Resources