I am new to Odoo customizing an currently stuck on a Many2one field.
Following the Code Snippet I am working on:
This is my Python Code:
My One2many field:
field_contacts_customer_info = fields.One2many(
'contacts.customer.information', 'another_id', string='Contacts for customer information')
My class:
class ContactsCustomerInformation(models.Model):
_name = 'contacts.customer.information'
_rec_name = 'name_contacts'
name_contacts = fields.Many2one(
'res.partner', string="Person", domain="[('is_company' , '=' , False)]")
mail_contacts = fields.Char(
related = 'name_contacts.email' ,string="Email")
another_id = fields.Many2one('res.partner', string="AnotherID")
@api.onchange('name_contacts')
def onchange_name_contacts(self):
if self.name_contacts:
if self.name_contacts.email:
self.mail_contacts = self.name_contacts.email
And my XML:
<page name="contacts_customer_information" string="Contacts for customer information" attrs="{'invisible': [('is_company','=', False)]}">
<field name="field_contacts_customer_info">
<tree editable="bottom">
<field name="name_contacts"/>
<field name="mail_contacts" domain="[('is_company' , '=' , False)]"/>
<field name="another_id" invisible="1"/>
<field name="versuch" invisible="1"/>
</tree>
<form>
<group>
<group>
<field name="name_contacts" domain="[('is_company' , '=' , False)]"/>
</group>
<group>
<field name="mail_contacts" domain="[('is_company' , '=' , False)]"/>
</group>
</group>
</form>
</field>
</page>
At the moment I have only one condition and that is that in the Many2one field no Companys but only Individuals are displayed. I also want to display only the Individuals that belong to the Company on whose view you are currently located. I know that I have to link this with an AND condition.
What is the condition that only the Individuals of the currently displayed Company are displayed ?
Thanks.