Skip to Content
Menú
This question has been flagged
3428 Vistes

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:
            return 
        else:
            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)
            else:
                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

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de maig 25
1401
2
de febr. 25
10260
4
de jul. 18
18657
2
de gen. 16
9475
0
d’oct. 24
4290