Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3455 Widoki

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
maj 25
1420
2
lut 25
10281
4
lip 18
18668
2
sty 16
9489
0
paź 24
4299