コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
6183 ビュー

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!

アバター
破棄
最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
1
12月 20
3286
0
6月 17
4219
1
9月 23
2419
1
9月 22
2830
0
3月 25
758