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

OpenERP one2many and one2many [Closed]

By
priyankahdp
on 4/30/13, 8:05 AM 2,754 views

The Question has been closed

by
priyankahdp
on 04/30/2013 10:26:31

I need to load workers's allowances & deductions.
allowances 2 types fixed & variable.
deductions also 3 types fixed , variable & special.

then my classes have relationship like this
allowance one2many fixed
allowance one2many variable

deduction one2many fixed
deduction one2many variable
deduction one2many special

my last requirment is to load those deductions and allowances in two '<page>' tags then i wrote a method for onchange_worker.but its not worked & hope you will help me to sortout this issue
thanks
(initially i wrote code for fixed allowances)

function in my class

def on_change_worker(self, cr, uid, ids, worker_id): fixed_v = {} fixed_list_v = {} fixed_list = [] fixed_list_data = [] if worker_id:
ind_allowance_id = self.pool.get('bpl.allowance.individual.data').search(cr, uid, [('worker_id', '=', worker_id)]) ind_allowance_obj = self.pool.get('bpl.allowance.individual.data').browse(cr, uid, ind_allowance_id)[0]

        for allowance_record in ind_allowance_obj.fixed_allowance_ids:
            fixed_list.append({'allowance_id':allowance_record.allowance_id.id, 'allowance_name': allowance_record.allowance_name.id })
        fixed_v['allowance_ids'] = fixed_list
        fixed_list_data.append(fixed_v)
        fixed_list_v['fixed_allowance_ids'] = fixed_list_data
        return {'value':fixed_list_v}

view.xml

<form string='bpl_worker_summary' version='7.0'>
<sheet>
<group>
<group>
<field name='bpl_company_id' readonly="1" />
<field name='bpl_estate_id' />
<field name='worker_id' on_change="on_change_worker(worker_id)" />
</group>
</group>
<div name="Allowances"></div>
<separator string="Allowances" />
<notebook>
<page string="Allowances">
<field name='allowance_ids' nolabel='1'>
<tree string='List' editable='bottom'>
<field name='fixed_allowance_ids' nolabel='1'>
<tree string="fixed_allowance">
<field name='allowance_id' />
<field name='allowance_name' />
<field name='amount' />
</tree>
</field>
</tree>
</field>
</page>
<page string="Deductions">
<field name='deduction_ids' nolabel='1'>
</field>
</page>
</notebook>
</sheet>
</form>

still not shows any records.please help me to sort this

EDITED

need to return mu result like this.?

dict: {'fixed_allowance_ids': [{'allowance_ids': [{'allowance_id': 1, 'allowance_name': 1}]}]}

do you get any error on server side?

Abhishek MEhta
on 4/30/13, 8:58 AM

not any error.but data not loaded to my grid. see above xml its mention like <field><tree ><field><tree ><field /></tree></field></tree></field> any issue with that xml architechure.?

priyankahdp
on 4/30/13, 9:02 AM
0

priyankahdp

--priyankahdp--
1089
| 5 5 6
Colombo, Sri Lanka
--priyankahdp--
Java Developer ORACLE Python J2EE Spring Hibernate Struts & Jquery............. :-)
priyankahdp
On 4/30/13, 9:56 AM

done with below codes

model class

def on_change_worker(self, cr, uid, ids, worker_id):
    fixed_v = {}
    fixed_list_v = {}
    fixed_list = []
    fixed_list_data = []

    if worker_id:            

        ind_allowance_id = self.pool.get('bpl.allowance.individual.data').search(cr, uid, [('worker_id', '=', worker_id)])
        ind_allowance_obj = self.pool.get('bpl.allowance.individual.data').browse(cr, uid, ind_allowance_id)[0]

        for allowance_record in ind_allowance_obj.fixed_allowance_ids:
            fixed_list.append({'allowance_id':allowance_record.allowance_id.id, 'allowance_name': allowance_record.allowance_name.id })
        fixed_v['fixed_allowance_ids'] = fixed_list
        fixed_list_data.append(fixed_v)
        fixed_list_v['allowance_ids'] = fixed_list_data
        return {'value':fixed_list_v}

view.xml

<page string="Allowances">
<field name='allowance_ids' nolabel='1'>
<field name='fixed_allowance_ids' nolabel='1'>
<tree string="fixed_allowance">
<field name='allowance_id' />
<field name='allowance_name' />
<field name='amount' />
</tree>
</field>
</field>
</page>

now result comes like this but still need to get values on tree view

image description

could you display these one2many values in tree view, if so,? How did you solve it?

MEXYTUL, Diego Calzadilla
on 4/3/15, 12:05 AM

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 4/30/13, 8:05 AM
Seen: 2754 times
Last updated: 3/16/15, 8:10 AM