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!