Odoo Help

Welcome!

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

0

[Solved]Functional Field in New Odoo v8 API?

By
Jo
on 10/5/15, 1:57 PM 440 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

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

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.


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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