2
votes

Odoo have automatic schedule setting (ir.cron). i need to configure schedule from my own module. use one2many in my module can create new schedule actions and when i check in settings->automation->schedule actions. that was exist and success to create.

i have issue, just one data display in my module but all data show in schedule actions menu which sucess created.

Please correct my code ,i stuck now :( this my code :

class sync_batch_schedule(osv.osv):
_name = "ir.cron"
_inherit = "ir.cron"

i use _inherit so can save recods in same table and can CRUD In my own module. because when i only read without make new inherit class. the data readonly, so i create one2many, this :

class sync_batch_update(osv.osv):
_name = 'sync.batch.update'


_columns = {
            'name' : fields.char('Name', required=True),
            'sync_batch_update_ids' : fields.one2many('eth.sync.update','batch_update_id', 'Batch to Update'),
            'sync_batch_update_stat_ids' : fields.one2many('sync.update.stat.batch','sync_update_stat_batch_id','Update Statistic'),
            #'batch_id' : fields.function(_get_filtering_schedule,type='one2many',relation='ir.cron',string='Schedule'),
            'batch_id' : fields.one2many('ir.cron','id',string='Schedule')
        }
_defaults = {
    'batch_id': lambda self, cr, uid, context : self._get_filtering_schedule(cr, uid, [0], '', '', context)[0],
}

Can you help me find my wrong code, i just newbie in odoo ;)

1

1 Answers

1
votes
'batch_id' : fields.one2many('ir.cron','id',string='Schedule')

This is the problem

you have to add new many2one into "ir.cron" and use that instead of id

class sync_batch_schedule(osv.osv):
_name = "ir.cron"
_inherit = "ir.cron"
_columns = {
    'sync_id': fields.many2one('sync.batch.update','sync_batch_schedule')
}

and then user it as 'batch_id' : fields.one2many('ir.cron','sync_id',string='Schedule')