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

How to display projects bloc in the Customer Form view.

By
Samir
on 10/14/14, 8:15 AM 621 views

Is there any possibility to display a project count in the Customer Form View?

Thanks.

0
Samir
On 10/15/14, 9:17 AM

Hi Mohamed, 

thank's for your answer, 

i think it will works, will try!

Regards

 

0
Mohamed Magdy
On 10/14/14, 9:20 AM

If you mean the number of projects related to a customer

class res_partner(osv.Model):

_name = 'res.partner'

_inherit = 'res.partner'

def _get_number_of_projects(self, cr, uid, ids, name, args, context=None):

res = {}

for partner_id in ids:

proj_ids = self.pool.get('project.project').search(cr, uid, [('partner_id', 'in', ids)], context=context)

res[partner_id] = len(proj_ids)

return res

 

_columns = {

'num_of_projects': fields.function(_get_number_of_projects, type='integer', string='Number Of Projects' , store=True),

}

Then in the view :

<record id="inherit_partner_veiw" model="ir.ui.view">

<field name="name">Inherit Partner View</field>

<field name="model">res.partner</field>

<field name="inherit_id" ref="base.view_partner_form"/>

<field name="arch" type="xml">

<xpath expr="//field[@name='website'] " position="after">

<field name="num_of_projects"/>

</xpath>

</field>

</record>

I Hope this helps you :)

I'm gradually learning Odoo through trial and error and community help. How or where do I implement this, do I have to build a module or can I add this to the existing code (if yes - what and where). Thanks for your support and time Chris Keen

Keen Intelligence, Chris Keen
on 11/6/14, 6:08 AM

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/14/14, 8:15 AM
Seen: 621 times
Last updated: 3/16/15, 8:10 AM