Community mailing list archives

community@mail.odoo.com

Re: Create function in crone

by
akalala
- 04/11/2016 04:33:57
Hi Dominique,
I deleted ensure_one, but i have this error :

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


New function :

@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})

2016-04-10 23:37 GMT+00:00 Dominique KON SUN TACK <dominique.k@elico-corp.com.sg>:

The error is a message generated by ensure_one

You don't need to ensure that the self is singleton by the way. You are not using this information on the code

On 11 Apr, 2016 5:48 am, "Yassine ISSAOUI" <yassine.trav@gmail.com> wrote:
Hello,

recently i try to run a cron in odoo 8, but a have a this error :              

File "/opt/odoo/openerp/models.py", line 5303, in ensure_one raise except_orm("ValueError", "Expected singleton: %s" % self) except_orm: ('ValueError', 'Expected singleton: atelier.material()')

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

Thanks.

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Yassine ISSAOUI
+212 6 77 64 50 58