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

[ADD][12.0] new module product_net_weight #894

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

legalsylvain
Copy link
Contributor

@legalsylvain legalsylvain commented Aug 3, 2021

This module extends the functionality of stock module to support gross weight.
Updated : See conversation below

This module extends the functionality of stock module to support net weight. (container excluded)

It also compute the Weight Price (Sale Price / Net Weight) that is a mandatory information
in certain businesses.

  • Go to 'Inventory > Master Data > Product' and edit items.

  • Go to 'Inventory' tab, and fill the "Net Weight" value.

product_form

  • If the net weight defined, the weight price is computed and displayed on the main tab

product_form_price

Note: The original weight field is renamed to "Gross Weight", to be more explicit.

@dreispt
Copy link
Sponsor Member

dreispt commented Aug 3, 2021

You probably mean "Gross Weight".
I could be wrong, but AFAIU the out-of-the-box "Weight" is the gross weight.
Because when computing shipping weight, the "Weight" field is used.

So what we might need to add is the "Net Weight" instead.

@legalsylvain
Copy link
Contributor Author

Thanks for your insight, @dreispt.

You probably mean "Gross Weight".

Yes ! sorry. I'll fix that.

I could be wrong, but AFAIU the out-of-the-box "Weight" is the gross weight.

No the weight field is the net weight, AFAIRTD. (As Far As I read the doc).

https://github.com/odoo/odoo/blob/12.0/addons/product/models/product.py#L148 See : packaging not included

Because when computing shipping weight, the "Weight" field is used.

in odoo or in oca modules ? (i don't use shipping weight)

In V8, there was two fields weight and weight_net, but :

In Openupgrade, we consider that the new weight field is the old weight_net field :

https://github.com/OCA/OpenUpgrade/blob/9.0/addons/product/migrations/9.0.1.2/pre-migration.py#L129

help welcome on that point !

@legalsylvain legalsylvain changed the title [ADD][12.0] new module product_brut_weight [ADD][12.0] new module product_gross_weight Aug 4, 2021
@legalsylvain
Copy link
Contributor Author

legalsylvain commented Aug 4, 2021

Hi @dreispt : I replaced "Brut Weight" per "Gross Weight".

@legalsylvain
Copy link
Contributor Author

Hi @amoyaux. Could you give your point of view, regarding the weight field.

  • Is it a net or a gross weight ?
  • Why odoo removed the weight_net field between 8.0 and 9.0 version ?

(I ping you because you're set as responsible of Logistics topic here (https://github.com/odoo/odoo/wiki/BugManagement) feel free to ping another guy if I'm wrong)

Thanks.

@amoyaux
Copy link

amoyaux commented Aug 4, 2021

Gross weight (at least from delivery point of view)
It's probably because it's not really used by the majority of use and a lot of module (like this one) exist for people with the need.

@legalsylvain
Copy link
Contributor Author

Gross weight (at least from delivery point of view)
It's probably because it's not really used by the majority of use and a lot of module (like this one) exist for people with the need.

Well, if you say that the odoo weight field is the gross weight :
-> I'll rename this module to product_net_weight. @dreispt : are you ok with that proposal ?
-> I think odoo SA should add an help on this field, mentionning it is a gross weight. (https://github.com/odoo/odoo/blob/master/addons/product/models/product.py#L123). On master description is too generic. Don't you think ?

Thanks @amoyaux for this quick response !

@dreispt
Copy link
Sponsor Member

dreispt commented Aug 5, 2021

@legalsylvain Yes, that would match my experience.
Let me elaborate with an example:

  • A bottle of wine weights 1250g (gross) = 750g wine (net weight) + 500g bottle
  • When I ship the bottle, for my transport company the product weight I need to use is 1250.
  • When I ship 6 bottles in a wood crate, the crate package weights 500g. That's what the "excluding package" means. For my transport operation, total weight will then be 6*1250 + 500 (including package).

For Odoo shipping to work correctly, I need the "weight" field to be set to 1250g, not 750g.

Does this make sense?

@legalsylvain
Copy link
Contributor Author

@dreispt : perfect ! thanks.

@rousseldenis
Copy link
Sponsor Contributor

@legalsylvain Just one question, if you want to manage packaging weight, why not putting it there as for one product, you can have different weights - but maybe is too keep it simple ?

@legalsylvain
Copy link
Contributor Author

Hi @rousseldenis.
Well, I made an error regarding "packaging" world. Let's take @dreispt exemple, with bottle :

  • The content (wine) weighs 750g. This is the net weight. until now, I was using the weight field, that was wrong, according to what @amoyaux says . So, i'll rename the current module to product_net_weight, and i will switch to use this new field. I need this field to compute price per unit value. That is mandatory in food business to display on label in your shop the price per liter or price per kilo of food product. (see below)

  • The container (bottle) weighs 400g, so the gross weight (weight in odoo, if i understand correctly) is 750 + 400 = 1150g.

  • The packaging (box) weighs 300g, so a box of 6 bottles weighs (6 * 1150) + 500 = 7400g, that means 1233 gr per Unit (weight_packaging_included) I need this field for logistic purpose because we have developed an in-house delivery service at grap, and we need to know if the truck is overloaded.
    But it's to hard to know the weigh of each package. (We have a database of 10.000 products, and each product has it packaging). (I understand your solution of creating a packaging product.)
    To have this value, we decide to make an approximation that is weight + 10%. (In my example it is 7%).

Hope I answered your question.

Label edited by Odoo.
image

@pedrobaeza
Copy link
Member

Sometime ago, there was net weight field in Odoo core: https://github.com/odoo/odoo/blob/9e8f70e4849b0eeaca8b5cf51372ecfa23dc561b/addons/product/product.py#L546 (this is 8.0)

@legalsylvain legalsylvain force-pushed the 12.0-ADD-product_brut_weight branch 2 times, most recently from 4fb2d43 to 1a297dc Compare August 6, 2021 09:20
@legalsylvain legalsylvain changed the title [ADD][12.0] new module product_gross_weight [ADD][12.0] new module product_net_weight Aug 6, 2021
@legalsylvain
Copy link
Contributor Author

Hi all.

  • I updated the module to introduce the "Net Weight" field.
  • Also added the computed field "Weight Price".
  • added tests & updated documentation and PR description.

It's ready for review.

Thanks.

@rousseldenis rousseldenis added this to the 12.0 milestone Aug 6, 2021
@hparfr
Copy link
Contributor

hparfr commented Aug 10, 2021

Thanks for this module.

I prefer (not blocking) if this module only adds a net_weight field and do not any calculation about price.
Be dependent of product_logistics_uom is also a great feature.

  • product_logistics_uom (product_attribute, v12, v14) takes care of expressing volume and weights in different units, it allows to express bottle of 75cl instead of 0,00075m³ (rounded at 0 by odoo) or 30gr of pepper without changing decimal precision. product_net_weight is not dependent of product_logistics_uom
  • price calculation is more complex than that and, IMO, it should not be included in this module. Because, it should be done against a different unit of measure (like volume for the liquids, or per unit for like eggs).
  • price display, is another story, on e-commerce and labels, you may want to display €/gr or €/100gr instead of €/kg.

Because I know, you don't want to change now, I hope, you agree to let these changes happen in v14.

@legalsylvain
Copy link
Contributor Author

Hi @hparfr.

I removed Weight Price, as indeed in next version, it should be maybe in other module. (refactor with product_logistics_uom, or other).

Could you review and approve this PR, and we can plan to work in the next oca days on that topic ?

kind regards.

@rvalyi
Copy link
Member

rvalyi commented Aug 17, 2021

Hello @sylvainc I was about to ask you the same as @hparfr . We have a customer selling air-conditionners who need this and price per Kg won't interrest them. I'm glad you removed the calculation. Now you have a trivial flake8 issue to fix (remove uselss api import) and then I promise to approve it.

@mbcosta
Copy link

mbcosta commented Aug 19, 2021

Hi @legalsylvain
Good work, I also had doubt about what weight field refered after v8 Gross or Net and by openupgrade thought it was Net, thanks to make it clear. One suggestion is includ the wine example at README.

Should this https://github.com/OCA/OpenUpgrade/blob/9.0/addons/product/migrations/9.0.1.2/pre-migration.py#L133 be fixed?

I already approved because is simple module and the travis error is just an import not used after fixed the PR should be green.

- Add new net_weight field on product models;
- Rename weight field with 'Gross Weight' string;
@legalsylvain
Copy link
Contributor Author

hi @mbcosta. thanks for your review.

thanks.

Copy link
Member

@rvalyi rvalyi left a comment

Choose a reason for hiding this comment

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

thank you @legalsylvain for having clarified this weight mess!!

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@dreispt
Copy link
Sponsor Member

dreispt commented Aug 19, 2021

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 12.0-ocabot-merge-pr-894-by-dreispt-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit cfa7214 into OCA:12.0 Aug 19, 2021
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 401b90c. Thanks a lot for contributing to OCA. ❤️

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

Successfully merging this pull request may close these issues.

None yet

9 participants