Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
2612 Vistas

I am looking to manage prices by updating the attribute default additional price value.

I can understand that it may be unwise to have the default changing value change any additional set prices on individual products. Knowing the risks involved, Is there any way to force Odoo Online to use the default additional price only? Currently the default additional price will only apply after the price has been added and then the attribute is added to the product which is less than ideal. I have upwards of 10,000 variants I need to manage with the same attribute that will affect the price equally so changing the prices per product will be a hinderance to my users.


***updated with solution ***


After playing with chat gpt for a couple hours i have finally found my solution. If you want to update your pricing from the attribute menu rather than individually on each product and each attribute, which will take about 9 clicks per price extra value, you will need to create a server action that will do this update for you.


I activated the dev mode and under the technical section found the server action menu. Under this menu I created a server action called update attribute pricing that would execute code in the model 'product.template' . Then I used the following code to acheive this 


# Fetch all attribute lines associated with the product

attribute_lines = env['product.template.attribute.value'].search([('product_tmpl_id', '=', record.id)])


for attribute_line in attribute_lines:

    # Fetch the related product attribute value

    attribute_value = attribute_line.product_attribute_value_id

    

    if attribute_value:

        # Fetch the default extra price from the product attribute value model

        default_extra_price = attribute_value.default_extra_price

        

        # Compare and update if necessary

        if attribute_line.price_extra != default_extra_price:

            attribute_line.write({'price_extra': default_extra_price})

 

now with this action created and activating a contextual action I can select products I wish to update pricing on and when using the action it will fetch the default_price_extra and apply those values to the price_extra fields on each product.

Avatar
Descartar
Autor Mejor respuesta

Hi Ricardo, 

Thank you for the suggestion, however it would be highly unrealistic to manage my volume of products in this manner. In addition to the rest of my inventory I have 7 products that contain a minimum of 600 variants each along with a large variety of additional options that need to be priced out. I really would prefer to be able to manage prices from one menu such as the "default additional cost" in the configuration > attributes tab. 


update:

upon further exploration i believe I have found a solution that i think could work but chatgpt can only get me so far in making it function as intended.


I would like to create a server action that is either manually triggered or scheduled/automatically triggered to update the value price extra field (price_extra) under the Product Template Attribute Value model (product.template.attribute.value) to the default extra price value under the product.attribute.value model.


currently my server action expression looks like this [ update price_extra to product.attribute.value.default_extra_price ] however this does not work. I have tried a couple versions of this but no success. I would appreciate any insight or advice on this solution.



Avatar
Descartar
Mejor respuesta

It is also possible to create "Extra prices" for product variants, for specific pricelists (using the "Extra prices" button on products with variants):

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
feb 24
1966
3
jul 25
2095
1
feb 25
2317
3
sept 24
2581
1
oct 23
2000