Odoo Help


Why my domain doesn't work?

Abegail Sanchez
on 9/28/14, 8:45 PM 1,339 views

I need to get the id of the res_partner on the parent table.

This work:


But this doesn't work:



Creditor Model:



'name':fields.many2one('res.partner','Creditor\'s Name',domain=['|',('customer','=',True),('is_company','=',True)]),


Admission Model:



'name' : fields.many2one ('res.partner', 'Patient Name', required="1", domain=[('customer', '=', 1)]),



My Model:


              'patient_case_id' : fields.many2one ('his.admission', 'Patient Admission', required=True, states={'process':[('readonly',True)], 'cancel':[('readonly',True)]}),

'creditor_id' : fields.one2many ('creditor.mgmt', 'creditor', 'Creditors' ,states={'process':[('readonly',True)], 'cancel':[('readonly',True)]},),


The view of my model:

<field name="patient_case_id" string="Patient Name" class="oe_patient_name"/>

<field name="creditor_id" nolabel="1">
                                        <tree string="Creditor Lines List" version="7.0" colors="red:credit_balance == 0;red:state == False;green:state == True;" editable="top">
                                            <field name="customer" on_change="on_change_customer(customer)" string="Customerss?" />
                                            <field name="partner_view" invisible="1" ></field>
                                            <field name="name" domain="[('id','=',parent.patient_case_id.name.id)]" string="Creditor's Name" required="1" options="{'always_reload':True,'m2o_dialog':false,'create':false,'create_edit':false}" ></field>


Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

On 9/30/14, 9:24 AM

Actually It should be


In XML, you cant travese and fetch further data... so in onchange event (written in py class), you have to manually browse and fetch further data

I already tried that before but still no luck it give me this (Error: AttributeError: object has no attribute 'name') and I alslo wondering why this work on on_change event but in a different model. This is how it looks like. Hospital Billing Model: _name="hospital.billing" _description="Hospital Billing System" _columns={ 'patient_case_id' : fields.many2one ('his.admission', 'Patient Admission', required=True, states={'process':[('readonly',True)], 'cancel':[('readonly',True)]}), } My Model: _name="hospital.account_request.lines" _description="Hospital Account Request Lines" _columns={ 'name':fields.char('Request Name',char=32), 'hospital_account_line':fields.one2many('hospital.account.lines','request_id','Hospital Account Lines'), 'billing_soa':fields.many2one('hospital.billing','Hospital Billing',ondelete='restrict',domain=[('state','=','draft')]), } My model can hop into 2 models On the view: on_change="on_change_account_receivable(creditor_mgmt_partner,parent.billing_soa.patient_case_id)

Abegail Sanchez
on 9/30/14, 9:08 PM

Well.. try to pass only parent.billing_soa..... then in onchange event browse further and fetch the required data

on 10/1/14, 1:23 AM

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

2 follower(s)


Asked: 9/28/14, 8:45 PM
Seen: 1339 times
Last updated: 3/16/15, 8:10 AM