Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6124 Lượt xem

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>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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)

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