Odoo Help


How to show sales order data in the projects module

on 10/7/16, 12:47 PM 253 views

I'm trying to visualize in the projects module the amount of the sales order/contract associated to that project. My code uses related fields and somehow I the fields show up with all their attributes from the sale order (ie help info) but they show up as empty.

Why do the fields show up correctly but not the actual values?

This is the field in the sale.order model:

from openerp import fields, models, api
class Sale(models.Model):      
_inherit = 'sale.order'
      sale_order_project = fields.One2many('project.project', 'sale_order', string = 'Sale Order Project')

This is the related field in the project model:

from openerp import fields, models, api
class Project(models.Model):         _inherit = 'project.project'
        sale_order = fields.Many2one('sale.order', string = 'Sale Order')
        amount_total_untaxed = fields.Float('Amount Untaxed', related = 'sale_order.amount_untaxed', store=True)
        amount_total = fields.Float('Amount Total', related='sale_order.amount_total',store = True)


On 10/7/16, 7:20 PM

 I foud the problem, it was an issue with the record id

Since sale.order project_id is the same as project.project analytic_account_id, when requesting sales order data the id must be associated with the analityc account.

The code looks like:

from openerp import fields, models, api

class Analytic(models.Model):
_inherit = 'account.analytic.account'  
  sale_order_ids = fields.One2many('sale.order', 'project_id', string='Sale orders', store=True)

from openerp import fields, models, api
class Project(models.Model):
    _inherit = 'project.project'
amount_total = fields.Float(related='analytic_account_id.sale_order_ids.amount_total', store=True)

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


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)


Asked: 10/7/16, 12:47 PM
Seen: 253 times
Last updated: 10/7/16, 7:20 PM