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

One2Many mapping in openerp 7 [Closed]

By
priyankahdp
on 3/25/13, 1:00 AM 2,951 views

The Question has been closed

by
priyankahdp
on 04/30/2013 10:20:16

Please advice me what is the error with this mapping.?unable to save users via below xml form

class bpl_work_offer(osv.osv):
    _name = "bpl.work.offer"
    _description = "BPL Work Offer"
    _columns = {
        'user_id': fields.many2one('res.users', 'User Name'),
        'date_of_offer': fields.date('Date'),
        'bpl_estate_id':fields.many2one('bpl.estate.n.registration', 'Estate', help='Estate'),
        'bpl_division_id':fields.many2one('bpl.division.n.registration', 'Division', help='Division'),
        'payment_type': fields.selection([('normal_work', 'Normal Work'), ('cash_work', 'Cash Work')], 'Payment Type'),
        'select_by': fields.selection([('by_name', 'By Names'), ('by_count', 'By Count')], 'Select  By'),
        'no_of_workers': fields.integer('No of Workers'),
        'work_type': fields.selection([('tea', 'Tea'), ('rubber', 'Rubber'), ('sundry', 'Sundry')], 'Work Type'),
        'total_workers': fields.integer('Total Workers'),
        'selected_tea_workers_line_ids': fields.one2many('bpl.selected.tea.workers.line', 'worker_id', 'Tea Workers', ondelete="cascade"),
        'selected_rubber_workers_line_ids': fields.one2many('bpl.selected.rubber.workers.line', 'worker_id', 'Rubber Workers', ondelete="cascade"),
        'selected_sundry_workers_line_ids': fields.one2many('bpl.selected.sundry.workers.line', 'worker_id', 'Sundry Workers', ondelete="cascade"),
    }

bpl_work_offer()

class selected_tea_workers_line_ids(osv.osv):
    _name = 'bpl.selected.tea.workers.line'
    _description = 'BPL Selected Tea Workers line'
    _columns = {
        'worker_id':fields.many2one('bpl.worker', 'Worker', ondelete='cascade', help='Worker'),
        'is_selected': fields.boolean('Select', help="Selected or not"),
        }

selected_tea_workers_line_ids()

class selected_rubber_workers_line_ids(osv.osv):
    _name = 'bpl.selected.rubber.workers.line'
    _description = 'BPL Selected Rubber Workers line'
    _columns = {
        'worker_id':fields.many2one('bpl.worker', 'Rubber Worker', ondelete='cascade', help='Worker'),
        'is_selected': fields.boolean('Select', help="Selected or not"),
        }

selected_rubber_workers_line_ids()

class selected_sundry_workers_line_ids(osv.osv):
    _name = 'bpl.selected.sundry.workers.line'
    _description = 'BPL Selected Sundry Workers line'
    _columns = {
        'worker_id':fields.many2one('bpl.worker', 'Sundry Worker', ondelete='cascade', help='Worker'),
        'is_selected': fields.boolean('Select', help="Selected or not"),
        }

selected_sundry_workers_line_ids()

view.xml mentioned below

<record model="ir.ui.view" id="bpl_work_offer_form"> <field name="name">bpl.work.offer.form</field> <field name="model">bpl.work.offer</field> <field name="arch" type="xml"> <form string="bpl_work_offer" version="7.0"> <sheet>

                    <group>
                        <group>
                            <field name='bpl_estate_id' />
                            <field name='bpl_division_id' />
                            <field name='user_id' />
                        </group>
                        <group>
                            <field name='date_of_offer' />
                            <field name='payment_type' />
                            <field name='select_by' />
                            <field name='no_of_workers' attrs="{'invisible':[('select_by','=','by_name')]}" />
                            <field name='work_type' />

                        </group>
                    </group>
                    <div name="Worker Selection"></div>
                    <separator string='Select workers' />
                    <notebook attrs="{'invisible':[('select_by','=','by_count')]}">
                        <page string="Tea Workers" attrs="{'invisible':[('work_type','!=','tea')]}">
                            <field name='selected_tea_workers_line_ids' nolabel='1'>
                                <tree string='List' editable='bottom'>
                                    <field name='worker_id' />
                                    <field name='is_selected' />
                                </tree>
                            </field>
                            <group class='oe_subtotal_footer oe_right'>
                                <field name='total_workers' />
                            </group>
                            <br />
                            <br />
                        </page>
                        <page string="Rubber Workers" attrs="{'invisible':[('work_type','!=','rubber')]}">
                            <field name='selected_rubber_workers_line_ids' nolabel='1'>
                                <tree string='List' editable='bottom'>
                                    <field name='worker_id' />
                                    <field name='is_selected' />
                                </tree>
                            </field>
                            <group class='oe_subtotal_footer oe_right'>
                                <field name='total_workers' />
                            </group>
                            <br />
                            <br />
                        </page>
                        <page string="Sundry Workers" attrs="{'invisible':[('work_type','!=','sundry')]}">
                            <field name='selected_sundry_workers_line_ids' nolabel='1'>
                                <tree string='List' editable='bottom'>
                                    <field name='worker_id' />
                                    <field name='is_selected' />
                                </tree>
                            </field>
                            <group class='oe_subtotal_footer oe_right'>
                                <field name='total_workers' />
                            </group>
                            <br />
                            <br />
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>
1

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 3/25/13, 5:28 AM

The definition of

'worker_id':fields.many2one('bpl.worker', 'Rubber Worker', ondelete='cascade', help='Worker'),

refers to model bpl.worker, but you have only defined model bpl.work.offer. You have to correct the model names.

Column

'selected_tea_workers_line_ids': fields.one2many('bpl.selected.tea.workers.line', 'worker_id', 'Tea Workers', ondelete="cascade"),

in model bpl.work.offer defines a one2many relation to bpl.selected.tea.workers.line. But then model bpl.selected.tea.workers.line requires a many2one relation to bpl.work.offer!

thanks its worked..here see my whole code https://github.com/priyankahdp/openerp/tree/openerp

in worker registration class i added domain to my estate & division fields to filter.they worked when i select company or division.but still division and estate fields shows other unrelevant records to(seems because they are many2one fileds.how to restict that )

priyankahdp
on 3/25/13, 7:35 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: 3/25/13, 1:00 AM
Seen: 2951 times
Last updated: 4/12/16, 1:18 AM