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.

1

How to remove this assertion error ?

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

I am trying to calculate comission for salesperson.
Calculation:
If current sales amount is greater than the previous sales amount for the same customer:
then comission=0.50*amount_total
else:
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):
    res={}
    comission=0.00

    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
2

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 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
        else:
            comission=0.00
            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

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

0 follower(s)

Stats

Asked: 4/18/14, 8:50 AM
Seen: 1003 times
Last updated: 3/16/15, 8:10 AM