Odoo Help


How to remove this assertion error ?

Pankaj Moolrajani
on 4/18/14, 8:50 AM 1,503 views

I am trying to calculate comission for salesperson.
If current sales amount is greater than the previous sales amount for the same customer:
then comission=0.50*amount_total
comission = 0.0

But i am missing something, not getting exact results. please guide.

def _calculate_comission(self, cr, uid, ids, field_names, args, context=None):

    for order in self.browse(cr, uid, ids):
        for record in self.browse(cr, uid, self.search(cr, uid, [('user_id','=',order.user_id.id)], limit=1)):
            if order.amount_total > record.amount_total:
                comission = 0.50*order.amount_total

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 4/21/14, 4:21 AM

Hi, Try this...

def _comission_calculate(self, cr, uid, ids, context=None):
        if ids[0]==1:
            return False
            result= cr.execute('select id from dbname where id<%s order by id desc limit 1', (ids[0],))
            result = cr.dictfetchall()
            previous_id = result[0]['id']
            previous = self.browse(cr, uid, previous_id)
            previous_amount = previous.total
            for current in self.browse(cr, uid, ids):
                current_amount = current.total
            if current_amount > previous_amount:
                comission = 0.50 * current_amount
        return comission

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