Community mailing list archives

community@mail.odoo.com

Crone function

by
akalala
- 04/11/2016 04:53:51
Hi all,

i have two classes :

class atelier_material(models.Model):
    _name = 'atelier.material'

    @api.model
    def create_action(self):
        ids = self.env['atelier.materiel'].search([])
        li = self.env['atelier.location.interne']
        for m in ids:
            li.create({'materiel': m.code_mat})

    code_mat = fields.Char(string="Code", size=30, required=True)
    name = fields.Char(string="Name", size=64, required=True)
    ....
atelier_material()

class atelier_location_interne(models.Model):
    _name = 'atelier.location.interne'
    materiel = fields.Many2one('atelier.material', string="Material")
    famille = fields.Char(string="Famille", compute='get_famille', store=True)
    ....
atelier_location_interne()

i create a crone to add atelier_location_interne line for each material, function (create_action ), but i have this error :

openerp\models.py", line 5306, in ensure_one
except_orm: ('ValueError', 'Expected singleton: atelier.location.interne(18, 19)')

Please help.