Odoo Help


Didn't insert some values into table?

Praveen S
on 7/31/13, 1:08 PM 1,162 views

hi, i am new to openerp. Me created a new dealer module. Their exists the commission payment to dealer. So to calculate commission me write the following function. The commission percentage/fixed amount was stored in dealer category table and each dealer is associated with dealer category.The sale order table have information about corresponding dealer in each sale. My aim is to calculate commission for dealer and its calculating value will take from dealer category. The function is added to the existing sale.py file and which was linked with sale_workflow.

the added function is here.

def action_dealer_sale(self, cr, uid, ids, context=None):
    comm = 0.0
    for o in self.browse(cr, uid, ids):
        if not o.dealer_id:
            dealer_idn = self.get.pool('dealer').browse(cr, uid, o.dealer_id)
            dealer_cat = self.get.pool('dealer.category').browse(cr, uid, dealer_idn.dealer_category_id)
            if dealer_cat.type == 'percent':
                comm = (dealer_cat.amount * o.amount_untaxed)
                comm = dealer_cat.amount
            dealer_sale = self.get.pool('dealer.sale.line').create(cr, uid,
                                                                {   'sale_id' : o.id,
                                                                    'state' : 'draft',
                                                                    'dealer_id' : dealer_idn.id,
                                                                    'amount' : comm,
                                                                    'commission' : False,
    return True

The above described my python code which was added in sales.py file. It didn't calculate the commission and doesn't inserts value for the fields dealer_id and amount in dealer.sale.line table. Other fields are stored with corresponding values.What was the error in my code... Pls help me its very urgent

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: 7/31/13, 1:08 PM
Seen: 1162 times
Last updated: 3/16/15, 8:10 AM