Odoo Help

0

[Solved]Functional Field in New Odoo v8 API?

By
Jo
on 10/5/15, 1:57 PM 788 views

Hi all,

I try to add a functional field in stock.pack.operation,

Here it is my code, which is i tried,


from openerp import fields, models, api

class stock_inherited(models.Model):

    _inherit = 'stock.pack.operation',


    @api.depends('picking_id.partner_id')

    def _compute_child_contact_ids(self):

         partner_id = int(record.picking_id.partner_id)

         is_company = record.picking_id.partner_id.is_company

         parent_id = record.picking_id.partner_id.parent_id

         record.filters = is_company +','+parent_id+','+partner_id

         return self.filters

    

     partner_id = fields.Many2one(string="Partner ID", related='picking_id.partner_id', store=True)

     filters = fields.Char(compute="_compute_child_contact_ids", string="Filters", store=True)


here partner_id gets exact partner ids, but the filters field is empty.

thanks in advance...!

2
Akhil P Sivan
On 10/5/15, 11:56 PM

Hi,

Because you need either give @api.one or use a for loop to iterate in the recordset. Try like this:

from openerp import models, fields, api

class stock_inherited(models.Model):

_inherit = 'stock.pack.operation'

@api.depends('picking_id.partner_id')
def _compute_child_contact_ids(self):
for record in self:
partner_id = record.picking_id.partner_id.id
is_company = record.picking_id.partner_id.is_company
parent_id = record.picking_id.partner_id.parent_id
record.filters = is_company +','+parent_id+','+partner_id




partner_id = fields.Many2one(string="Partner ID", related='picking_id.partner_id')
filters = fields.Char(compute="_compute_child_contact_ids", string="Filters")

I don't understand the way you need partner_id and parent_id, you need exactly the name or record id? Please tell what you exactly need in filters.


About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 10/5/15, 1:57 PM
Seen: 788 times
Last updated: 10/6/15, 2:36 AM