Skip to content

[16] product_margin_classification changes template list_price instead of variant_extra_price #226

@FreezeS

Description

@FreezeS

Hi guys,

In the current implementation, product_margin_classification is completely unusable for products with variants that have different costs.
Changing the sale price of a variant will change the sale price of all the other variants.

How to reproduce in runboat:

  • create a new attribute "Pins", radio, dynamically. Add 3 values: 5,10,15

  • create a new product "Test1", at Attributes and Variants select Pins, add all 3 values

  • make a new sales order, select product Test1, when popup appears, select Pins - 5. Repeat to create all 3 variants.

  • go to the Test1 template, set list_price 50$.

  • click on 3 Variants, edit each and set cost the same as pins value. After it should look like this:
    Image

  • go to margin classifications, create a 33% margin like this:

Image

  • go to Inventory - Products - Product variants, select Test1 with Pins: 5 and set the margin classification

Image

  • click on Decrease price

What I expected to happen:

  • variant_extra_price to be set at -42.5 resulting in a sales price of 7.5 for the variant and the sale price of the other variants to remain unchanged

What happens:

  • list_price of the template Test1 is set to 7.5 affecting the sales price of all the other variants

Image

  • now if I go to another variant, select the same classification and set the price:

Image
This changed the price for the 5 pin version as well:

Image

Proposed fix

def use_theoretical_price(self):
        for product in self:
            product.lst_price = product.theoretical_price

should be

def use_theoretical_price(self):
        for product in self:
            product.variant_extra_price = product.theoretical_price - product.list_price

From my very limited experience, lst_price should not be edited directly as it affects the template list_price. Every modification of a variant's price should be via variant_extra_price.
Can anyone with more experience chime in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugstalePR/Issue without recent activity, it'll be soon closed automatically.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions