Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0] [MIG] product_pricelist_supplierinfo #1745

Closed

Conversation

marielejeune
Copy link
Contributor

No description provided.

cubells and others added 30 commits October 10, 2024 09:49
* Don't depend on sales
* Extended README
* Tests focused on module specific features
* Code optimization
* Don't mix pricelist info with supplier info on criteria
Date order is passed by context, so we have to take this into account for
computing properly available supplierinfo records.
If not, you can twist the order in the form and rules won't be applied according criteria
If you set the value "Based on" for using supplier info, but then you change the
computation type to another one (like fixed price or discount), this code is still
acting, so we should check both fields.
Currently translated at 93.3% (14 of 15 strings)

Translation: product-attribute-12.0/product-attribute-12.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-product_pricelist_supplierinfo/es/
When having price per qty at the supplier level and if you want to
base your pricelist on the supplier price, now you can
define a margin on the product.supplierinfo
Use standard way to select the seller.

As a result a bug in previous solution is fixed also: before this,
all supplierinfo records having product_tmpl_id set, were considered
as possible price for all product variants, even if product_id was
set also. That resulted in same price for all variants even if
supplierinfo records had different price for all variants.
If we have suppliers in two or more currencies, and we have a pricelist
with an item that is selected the "Prices based on supplier info" option
but the pricelist is in a currency different from the supplierinfo the
compute of the price get the price on the same amount but with a different
currency.
With these changes, we are converting the price to the currency on the
pricelist that is being used.
Also, a test was added to prove the previous behaviour.
Currently translated at 100.0% (20 of 20 strings)

Translation: product-attribute-12.0/product-attribute-12.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-product_pricelist_supplierinfo/fr/
It is possible that this method is called on an inactive template,
in which case product_variant_id returns empty recordset and
_select_seller will raise expected singleton error.
If we have a product with a supplier with a UOM "A" but the product is
sold with a UOM "B" the price we are getting is the same no matter the
UOM. For example:
Product with the price 1200 per Dozen and we sell a 1 unit we are
getting the price of 1200 for that unit when we should be obtaining 100.

With these changes, we are converting the price to the UOM that is being
used on the sale or the default on the product.
Also, a test was added to prove the previous behaviour.
[UPD] Update product_pricelist_supplierinfo.pot

[UPD] README.rst
… when date is datetime.

date may come from context
When we check the price of any product, the date that we pass on the context has to be a Datetime value or None. With this change we avoid to pass a False.

Here you have the reference to the code that check that https://github.com/OCA/OCB/blob/13.0/addons/product/models/product.py#L599-L600

TT29935

product_pricelist_supplierinfo 13.0.1.0.2
TT31816

[UPD] Update product_pricelist_supplierinfo.pot

[UPD] README.rst

[IMP] update dotfiles [ci skip]
In the e-commerce, if we have a pricelist with a rule based on
supplierinfo for a determined supplier partner, such partner could be
not accesible for public users and the affected products could not be
reached.

TT31476
If we don't have a supplierinfo that below 1 unit we won't get any
seller. We want to ensure that the condition is fully ignored to get
whatever price given the other criterias.

TT33659
…sers

0581b66 is not enough on v13 for
avoiding the access error, so we sudoed the whole price fetch operation.

TT36898
weblate and others added 16 commits October 10, 2024 09:49
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: product-attribute-16.0/product-attribute-16.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_supplierinfo/
…od in product_pricelist model

In version 15.0 the _compute_price_rule method was used to obtain the
product price because the price was a computed field, however, in
version 16.0 we need to inherit _compute_price from product_pricelist_item
because this method is used directly when creating a new sale order line.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: product-attribute-16.0/product-attribute-16.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_supplierinfo/
Currently translated at 100.0% (14 of 14 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_supplierinfo/es/
Currently translated at 100.0% (14 of 14 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_supplierinfo/pt_BR/
Currently translated at 100.0% (14 of 14 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_supplierinfo/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: product-attribute-17.0/product-attribute-17.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-product_pricelist_supplierinfo/
Currently translated at 100.0% (14 of 14 strings)

Translation: product-attribute-17.0/product-attribute-17.0-product_pricelist_supplierinfo
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-product_pricelist_supplierinfo/it/
@marielejeune marielejeune marked this pull request as ready for review October 10, 2024 07:59
@pedrobaeza
Copy link
Member

/ocabot migration product_pricelist_supplierinfo

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Oct 10, 2024
@OCA-git-bot OCA-git-bot mentioned this pull request Oct 10, 2024
32 tasks
@JordiBForgeFlow
Copy link
Member

Hi @pedrobaeza @marielejeune We have proposed to rename 'margin' to 'markup'.
acsone#9

Markup = (sales price - cost) / cost
Margin = (sales price - cost) / sales price

See https://www.investopedia.com/ask/answers/102714/whats-difference-between-profit-margin-and-markup.asp

@pedrobaeza
Copy link
Member

Well, as here we are doing sales pricelists, we are not talking about costs, but the sales margin you want. It's a very common nomenclature to call it "margin over cost".

@JordiBForgeFlow
Copy link
Member

JordiBForgeFlow commented Dec 9, 2024 via email

@JordiBForgeFlow
Copy link
Member

JordiBForgeFlow commented Dec 9, 2024 via email

self.ensure_one()
sale_price = self.price
if self.sale_margin:
sale_price = (self.price + (self.price * (self.sale_margin / 100))) or 0.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since v17, there is a discount field on supplierinfo and a price_discounted
If you want to sale a product depending on the price you buy it, this is the price_discounted that should be used, right ?
Or at least, if not by default, it should be an option in the module ?
What do you think ? @pedrobaeza @JordiBForgeFlow @marielejeune

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it should be included in this module.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and sorry to jump in, but maybe a field named like no_supplierinfo_discount could work, similar to the existing field no_supplierinfo_min_quantity: https://github.com/OCA/product-attribute/blob/5c4e5f6c/product_pricelist_supplierinfo/models/product_pricelist_item.py#L15.

The idea would be to use this field to bypass the discount in the supplier info, passing its value here as a parameter: https://github.com/OCA/product-attribute/blob/5c4e5f6c/product_pricelist_supplierinfo/models/product_template.py#L44

so that you can select between self.price and self.price_discounted using no_supplierinfo_discount as a validation here: https://github.com/OCA/product-attribute/blob/5c4e5f6c/product_pricelist_supplierinfo/models/product_supplierinfo.py#L16

This could be implemented in version 17.0.

Regards.

<field name="price" position="after">
<field
name="sale_margin"
string="Sale margin"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Sale Margin (%)" to make it clearer, similar to the discount field: https://github.com/odoo/odoo/blob/75571a66/addons/product/models/product_supplierinfo.py#L65

@marielejeune
Copy link
Contributor Author

marielejeune commented Jan 22, 2025

Superseeded by #1837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.