Odoo Help


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.


Didn't insert some values into table?

Praveen S
on 7/31/13, 1:08 PM 684 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

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)


Asked: 7/31/13, 1:08 PM
Seen: 684 times
Last updated: 3/16/15, 8:10 AM