콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
6241 화면

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
3310
0
6월 17
4242
1
9월 23
2468
1
9월 22
2868
0
3월 25
811