تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3737 أدوات العرض
class PartnerSales(models.Model):
_inherit = "res.partner"
    cuid = fields.Integer(string="Get Current User ID", compute="_dp_cuid")
    cspid = fields.Integer(string="Get Current Sale Person ID", related="user_id.id")

    @api.depends("cuid")
    @api.one
    def _dp_cuid(self):
    self.cuid = self.env.user.id
<?xml version="1.0" encoding="UTF-8"?> 
<odoo>
<record id="view_dham_customers_form" model="ir.ui.view">
<field name="name">KSK DN</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='email']" position="attributes">
<attribute name="attrs">
{'invisible': [('cspid','=', 'cuid')]}
</attribute>
</xpath>
</field>
</record>

Email field is not hidden. How to fix it?

Thanks in advance.








الصورة الرمزية
إهمال
أفضل إجابة

Hi DHA, 

cspid = fields.Integer(string="Get Current Sale Person ID", related="user_id.id", store=True)


Second Question :

For that i would suggest the following logic : 
1- create a boolean like this : 

        is_salesperson = fields.Boolean(compute='compute_is_salesperson', store=True)
@api.multi
@api.depends('user_id')
def compute_is_salesperson(self):
user = self.env.user
  for record in self:
     if record.user_id and record.user_id.id == user.id : 
            return True

and in your xml field Email declaration you add attribute attrs like this : 

 attrs="{'invisible': [('is_salesperson','=', True)]}"

And of course the declaration of your boolean if form view : 

<field name="is_salesperson" invisible="1"/>

Upvote if this helps! 
Thank you.








الصورة الرمزية
إهمال
الكاتب أفضل إجابة

i.imgur.com/qfhE2fr.png

If SalePerson == CurrentUserId:

    Email = Hidden

    Phone = Hidden

Everyone has methods.

Thanks.

الصورة الرمزية
إهمال

Please upvote if any of the answers work(s) for you. That encourages the community to keep answering questions or at least making efforts :)

Please read Second Question section in my previous answer ;)

الكاتب

I have tested it but not working

what value does is_salesperson get in your form view ? (you can make it temporarely visible to see its value)

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يناير 24
14355
2
أبريل 17
3314
1
مايو 16
3499
4
فبراير 25
2329
1
أغسطس 24
1972