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

how to implement polymorphysm present in openerp

By
Romuald Franck
on 7/14/14, 4:35 AM 709 views

I have these classes:

class site_task(osv.osv):
    _name='site.task'
    _columns = {
                'numero':fields.integer('Numéro',size=3),
                'description':fields.text('Tâches',required=True),
                'unit':fields.many2one('product.uom','Unité'),
                'pourcentage':fields.float("Pourcentage"),
                'planning_id':fields.many2one('site.planning','Planning No'),
                }
site_task()

class site_planning(osv.osv):
    _name='site.planning'
    _columns={
              'name':fields.date('Date du jour',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]},required=True),
              'chantier_id':fields.many2one('res.company','Chantier'),
              'state':fields.selection([('draft','Brouillon'),('validated','Validé')],'State',readonly=True,select=True),
              }
    _defaults={
               'name': lambda *a: fields.date.today(),  
               'chantier_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'site.planning.daily', context=c),
               'state': 'draft',
               }
    def validated (self,cr,uid,ids,context=None):
        self.write(cr, uid, ids, {'state':'validated'})
        return True
site_planning()

class site_planning_daily(osv.osv):
    _name='site.planning.daily'
    _inherit='site.planning'
    _columns={
              'task_ids':fields.one2many('site.task','planning_id','tâches',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              }          
 
site_planning_daily()

class site_planning_monthly(osv.osv):
    _name='site.planning.monthly'
    _inherit='site.planning'
    _columns={              
              'date_fin':fields.date('Date fin',required=True,states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids1':fields.one2many('site.task','planning_id','Jour 1',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids2':fields.one2many('site.task','planning_id','Jour 2',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids3':fields.one2many('site.task','planning_id','Jour 3',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids4':fields.one2many('site.task','planning_id','Jour 4',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids5':fields.one2many('site.task','planning_id','Jour 5',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids6':fields.one2many('site.task','planning_id','Jour 6',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids7':fields.one2many('site.task','planning_id','Jour 7',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids8':fields.one2many('site.task','planning_id','Jour 8',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids9':fields.one2many('site.task','planning_id','Jour 9',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids10':fields.one2many('site.task','planning_id','Jour 10',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids11':fields.one2many('site.task','planning_id','Jour 11',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids12':fields.one2many('site.task','planning_id','Jour 12',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids13':fields.one2many('site.task','planning_id','Jour 13',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids14':fields.one2many('site.task','planning_id','Jour 14',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              'task_ids15':fields.one2many('site.task','planning_id','Jour 15',states={'draft': [('readonly', False)], 'validate': [('readonly',False)]}),
              }

site_planning_monthly()

 

So the problem is that when i try to insert a record in the planning_monthly view, i got an error telling the 'planning_id' of my tasks aren't present in site.planning table. I'm surprise because i made site.planning.monthly inheriting site.planning.

If someone unedrstand my problem, please give me an idea.

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 7/14/14, 4:49 AM

in the structure you use, _name and _inherit should be the same. See https://doc.openerp.com/trunk/server/03_module_dev_02/#object-inheritance-inherit

I think OpenERP is unable to see that you actually try to point to a subclass.

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

1 follower(s)

Stats

Asked: 7/14/14, 4:35 AM
Seen: 709 times
Last updated: 3/16/15, 8:10 AM