Odoo Help


Domain in xml odoo 10

on 11/8/18, 8:41 AM 56 views

I want use a domain filter in my xml field like this :


However, i don't understand how does it work !

Here my fields :

    responsible_partner = fields.Many2one(string="Responsible",
    responsible_foyer = fields.Many2one(string="Foyer responsible", comodel_name="horanet.relation.foyer", copy=False)

Here my form view XML :

   <field name="responsible_partner" required="True" domain="[('id','=',responsible_foyer.partner_id)]" />
   <field name="responsible_foyer" />

Here my function :

def _get_active_foyer(self):
    if self.partner_id:
        actually_partner_id = self.partner_id.name
        if actually_partner_id:
            records_foyer_id = self.env['horanet.relation.foyer'].search([('partner_id', '=', actually_partner_id)])

            for rec_foyer in records_foyer_id:
                if rec_foyer.foyer_id:
                    records_partner_id = self.env['horanet.relation.foyer'].search(
                        [('foyer_id', '=', rec_foyer.foyer_id.id)])
                    for rec_partner in records_partner_id:
                        if rec_partner.partner_id:
                            self.responsible_partner = rec_partner.partner_id.id
                            self.responsible_foyer = rec_partner.id

Error :

Error: AttributeError: object has no attribute 'partner_id'

However, I have the field partner_id in my model : "horanet.relation.foyer".

Can you explain to me ?


On 11/9/18, 3:26 AM


Sorry for my english, I am french.

My function and my fields it's in 'ecole.partner.school' model. I have a 'partner_id' field in this model.

In my function, I don't have errors. What I get from the field 'responsible_foyer' is OK. However, I retrieve every partner if I click on my field Many2one in view XML. That is why, I want put a filter in XML. 

I an beginner on ODOO and there are maybe others ways to do :)

Thanks You

Tristán Mozos
On 11/8/18, 3:38 PM


I don't understand exactly what you want to do and I miss the description of the two models and the fields of these to can analyze better the error. However,  I have viewed something on your _get_active_foyer method. I assume that the method is of the model of your fields description. If it is true, I miss the partner_id field declaration on your model and can be a reason of error on self.partner_id statement on the first line.

Best regards

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/8/18, 8:41 AM
Seen: 56 times
Last updated: 11/9/18, 3:26 AM