Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6153 Lượt xem

Hi,


I want to restrict users to create quotations only to customers who work on certain industries.


Example:

I want the salespeople who sells to Supermarkets to only be able to create quotations to customers that have Supermakert as their industry_id.


What I've done:

-----------------------------------------------------------------------------------------------

1- I've created a Many2many field on res.users:

from odoo import models, fields


class res_users(models.Model):
_inherit = 'res.users'

z_allowed_industries = fields.Many2many('res.partner.industry')

-----------------------------------------------------------------------------------------------

2- Added z_allowed_ind to form view:

<record id="view_users_form_inherit" model="ir.ui.view">
<field name="name">res.users.form.inherit</field>
<field name="model">res.users</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">

<xpath expr="//notebook" position="inside">
<page string="Exta Details">
<field name="z_allowed_ind" widget="many2many_tags"/>
</page>
</xpath>
</field>
</record>

-----------------------------------------------------------------------------------------------

3- Changed the domain on Quotation -> partner_id field:

<field name="partner_id" position="replace">
<field name="partner_id"
widget="res_partner_many2one"
domain="[('parent_id', '!=', False),
('parent_id.industry_id', 'in', 'user_id.z_allowed_ind')]"
/>
</field>

-----------------------------------------------------------------------------------------------


I know that ('parent_id.industry_id', 'in', 'user_id.z_allowed_ind') is not the correct way to do this... but I have no idea how to do it XD


Can anyone help me?


Thanks in advance!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

There is an OCA module called web_domain_field which will allow you to set the domain dynamically.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 20
3270
0
thg 6 17
4211
1
thg 9 23
2404
1
thg 9 22
2808
0
thg 3 25
736