Skip to Content
Menu
This question has been flagged

i have two variants in a single product each variants price need to taken as as a lst_price from product.product,

getFormattedPrice() {
return formatCurrency(this.props.price, this.env.currency.id);
}


as per this code product price is taken from product.template list_price + extra_price 
insted of this i need product.product lst_price(sales price)

Avatar
Discard

Did you change _compute_product_lst_price()? Because ultimately: product.lst_price = list_price + product.price_extra

Best Answer

Hi,

Create a custom module or use your existing one. Add the following controller in controllers/main.py:


from odoo import http

from odoo.http import request

from datetime import datetime


class ProductConfiguratorController(http.Controller):


    @http.route(

        route='/sale/product_configurator/update_combination',

        type='json',

        auth='user',

        methods=['POST'],

    )

    def sale_product_configurator_update_combination(

        self,

        product_template_id,

        ptav_ids,

        currency_id,

        so_date,

        quantity,

        product_uom_id=None,

        company_id=None,

        pricelist_id=None,

        **kwargs,

    ):

        if company_id:

            request.update_context(allowed_company_ids=[company_id])


        product_template = request.env['product.template'].browse(product_template_id)

        combination = request.env['product.template.attribute.value'].browse(ptav_ids)

        product = product_template._get_variant_for_combination(combination)


        pricelist = request.env['product.pricelist'].browse(pricelist_id)

        product_uom = request.env['uom.uom'].browse(product_uom_id)

        currency = request.env['res.currency'].browse(currency_id)


        # Use _get_basic_product_information to fetch all necessary info

        values = self._get_basic_product_information(

            product,

            pricelist,

            combination,

            quantity=quantity or 0.0,

            uom=product_uom,

            currency=currency,

            date=datetime.fromisoformat(so_date),

            **kwargs,

        )


        # ⛔ Remove computed price — set variant's list price (sales price)

        values['price'] = product.lst_price


        return values

def _get_basic_product_information(

    self,

    product,

    pricelist,

    combination,

    quantity,

    uom,

    currency,

    date,

    **kwargs,

):

    name = product.get_product_multiline_description_sale()

    return {

        'product_id': product.id,

        'product_template_id': product.product_tmpl_id.id,

        'combination': combination.ids,

        'name': name,

        'price': pricelist.get_product_price(product, quantity, request.env.user.partner_id),

        'product_uom': uom.id if uom else product.uom_id.id,

        'currency_id': currency.id,

    }


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
1
May 21
6214
1
Mar 18
7877
1
May 25
750
1
Feb 25
1328
3
Mar 24
6308