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

I created a custom computation field called "x_asf" (under the amount_untaxed field in quotation). The formula of the ASF field is amount_untaxed * 0.10

 

I added the code below but it's not working. anyone can help?

 

def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None):
        """ Wrapper because of direct method passing as parameter for function fields """
        return self._amount_all(cr, uid, ids, field_name, arg, context=context)

    def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
        cur_obj = self.pool.get('res.currency')
        res = {}
        for order in self.browse(cr, uid, ids, context=context):
            res[order.id] = {
                'amount_untaxed': 0.0,
                'x_asf': 0.0,
                'amount_tax': 0.0,
                'amount_total': 0.0,
            }
            val = val1 = 0.0
            cur = order.pricelist_id.currency_id
            for line in order.order_line:
                val1 += line.price_subtotal
                val += self._amount_line_tax(cr, uid, line, context=context)
            res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
            res[order.id]['x_asf'] = res[order.id]['amount_untaxed'] * 0.10
            res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
            res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
        return res

아바타
취소
베스트 답변

Probably your method is not called, add (repeat) in your module a line that calling the method

_columns = {
        'amount_untaxed': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Untaxed Amount',
}

Similar call is needed to the method _amount_all_wrapper

아바타
취소
관련 게시물 답글 화면 활동
1
10월 22
4067
1
3월 25
1632
1
5월 24
1981
Sales quotation 해결 완료
2
3월 24
2044
1
6월 23
2491