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

In my product view I can see the sale price of a product, this is the base price. 

Below it I also want to see the price of a specific pricelist (GoldPartnerPrice) for the product. Is this possible with a calculated field in studio? 

If yes, what is the code to get the pricelist value of that specific product?

Keep in mind that the general rule of the pricelist is 10% discount but on some products there's a specific price or discount.


아바타
취소
베스트 답변

Hi,


Try the following steps,


1-Add a New Field

- Drag and drop a Float field into the form where you want to display the Gold Partner Price.

- Name the field something like: Gold Partner Price.


2-Make it a Computed Field

- In the field’s properties (right-hand panel), enable “Computed field”.

- In the Python Code box, paste the following snippet:


Code:-


# Search for the GoldPartnerPrice pricelist

pricelist = env['product.pricelist'].search([('name', '=', 'GoldPartnerPrice')], limit=1)


# Get the product variant (since pricelists work at product.product level)

product_variant = record.product_variant_id


# If pricelist exists and product variant is set, compute price

result = pricelist._get_product_price(product_variant, 1.0, False) if pricelist and product_variant else 0.0


* env['product.pricelist'] looks for your pricelist named GoldPartnerPrice.

* record.product_variant_id ensures you’re computing on the correct variant (Studio’s record is the current product template).

* _get_product_price(product, qty, partner) computes the price according to the pricelist rules.


4-Save the Field



- This will dynamically calculate the price each time you open or refresh the product.

- If you later rename your pricelist, update the ('name', '=', 'GoldPartnerPrice') filter.

- If you want it to use a specific pricelist ID (instead of name), replace with:

            pricelist = env['product.pricelist'].browse(YOUR_PRICELIST_ID)


Hope it helps

아바타
취소
작성자

With _get_product_price I had to remove the False param, then it worked perfectly, thanks!

관련 게시물 답글 화면 활동
1
10월 25
304
1
10월 24
2178
2
10월 24
3497
1
7월 24
2827
0
6월 24
1542