Community: Framework mailing list archives

expert-framework@mail.odoo.com

Re: One2many function field New API 8

by
Jean-Paul Robineau
- 07/28/2015 10:57:26
Dear Khalid

This is an example for you

future_action_ids = fields.One2many(compute=_get_records_actions, multi=True, comodel_name='vca.action_plan', string='Future actions')

 @api.multi
     def _get_records_actions(self):
         l_ids = self.env['vca.action_plan'].search([('res_model','=',self._name),
                              ('res_id','in',[x.id for x in self]),
                              ('action_plan_type.type_action','in',['direct','future'])])
         for obj in self:
             obj.future_action_ids = [x.id for x in l_ids if x.action_plan_type.type_action=='direct' and x.res_id==obj.id]

as you can see the function returns a list of ids

best regards


From: Khalid LAKHSAM <k.lakhsam@gmail.com>
To: Community: Framework <expert-framework@mail.odoo.com>
Sent: Tuesday, July 28, 2015 4:42 PM
Subject: One2many function field New API 8

Hi Community,

How to create a One2many with a functionnal field in new api 8 ?

Best regards.
_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe