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

Hello, i create a field on each product category to add extra cost on the products but i want to be able to change this extra cost on the quotation tree

(i dont want the change to be saved on the category, i want the change to save only on the quotation for this time only)

i add the field to the quotation tree i change the extra cost and its working but when i save the quotation the extra cost resets backs to the default (the cost that i add on the product categories)

Here is the code the field is the extra_cost

@api.depends('order_line.extra_cost_amount','order_line.product_uom_qty','order_line.real_cost_amount','order_line.purchase_price')

    def _extra_cost(self):

        for order in self:

            extra_cost = real_cost_amount = total_real_cost_amount = total_cost = 0

            for line in order.order_line:

                #if line.state != 'cancel':

                extra_cost += line.extra_cost_amount * line.product_uom_qty

                real_cost_amount += line.real_cost_amount

                total_real_cost_amount += line.real_cost_amount * line.product_uom_qty

                total_cost += line.purchase_price * line.product_uom_qty

                line.extra_cost_amount = (line.purchase_price * line.extra_cost) / 100

                line.real_cost_amount = line.extra_cost_amount + line.purchase_price

            order.extra_cost = line.extra_cost

            order.real_cost_amount = line.real_cost_amount

            order.total_real_cost_amount = total_real_cost_amount 

            order.extra_cost_per = ((order.extra_cost / total_cost)*100) if total_cost else 0

            # total_amount = order.amount_after_discount if order.apply_discount else order.amount_untaxed

            total_amount = order.amount_untaxed

            real_margin = total_amount - order.total_real_cost_amount

            order.real_margin = real_margin

            order.real_margin_per = (real_margin * 100)/total_amount if total_amount else 100


아바타
취소
베스트 답변

Hi,

You can update the extra_cost in the XML file

Use the force save attribute in the XML code force_save="1"

<field name="extra_cost" force_save="1"/>


Regards

아바타
취소
관련 게시물 답글 화면 활동
3
5월 25
1858
1
4월 25
1385
3
9월 24
14356
2
2월 24
2578
1
7월 23
2808