Odoo Help

Welcome!

This community 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.

0

Why my domain doesn't work?

By
Abegail Sanchez
on 9/28/14, 8:45 PM 937 views

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

This work:

parent.patient_case_id

But this doesn't work:

parent.patient_case_id.name.id

 

Creditor Model:

_name="creditor.mgmt"

_columns={

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

}

Admission Model:

_name="his.admission"

_columns={

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

}

 

My Model:

_name="hospital.billing"

 _columns={
             
              '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>
                                        </tree>
                                    </field>

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

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

deep
On 9/30/14, 9:24 AM

Actually It should be

domain="[('id','=',parent.patient_case_id)]"

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

deep
on 10/1/14, 1:23 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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