Odoo Help


How to get total workers by button ? [Closed]

on 4/18/13, 5:42 AM 2,139 views

The Question has been closed

Sudhir Arya (SA)
on 04/18/2013 06:51:23

my requirement like this when i adding workers in select workers tree view, then need to add total of them right side bottom total workers field.its ok its show when i'm going to save or when i clicked the (update) button. i refer the purchase module but i can't find what function exaclty called when that button clicked.

my whole code uploaded to here@GitHub refer line 397 in bpl_view.xml and line 335 in bpl.py

as per purchase module i wrote function.but its have only return statement.thats also confused to me.

def button_total(self, cr, uid, ids, context=None):
    return True

please advice me on this issue & please tell me why when clicked the button records save automatically.?its have only return True statement. ? ?



Sudhir Arya (SA)

--Sudhir Arya (SA)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow




Sudhir Arya (SA)
On 4/18/13, 6:40 AM

Write this code:

def button_total(self, cr, uid, ids, context=None):
    tea_worker_line_ids = self.browse(cr, uid, ids[0], context=context).selected_tea_workers_line_ids or []
    total_tea_worker = len(tea_worker_line_ids)
    self.write(cr, uid, ids, {'total_workers': total_tea_worker}, context=context)
    return True

wow..its worked Arya thanks

on 4/18/13, 6:48 AM

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

0 follower(s)


Asked: 4/18/13, 5:42 AM
Seen: 2139 times
Last updated: 3/16/15, 8:10 AM