콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3480 화면

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

아바타
취소
관련 게시물 답글 화면 활동
1
5월 25
1458
2
2월 25
10333
4
7월 18
18696
2
1월 16
9523
0
10월 24
4321