OCA / margin-analysis

Odoo Financial Controlling (margin, costs, ...)
https://odoo-community.org/project/9
GNU Affero General Public License v3.0
74 stars 161 forks source link

[FIX] [16.0] sale_margin_delivered: Fix calculation when more quantities are sent than ordered #207

Closed Shide closed 5 months ago

Shide commented 5 months ago

When sending more quantities than ordered, purchase_price_delivery field is not calculated correctly in this Odoo version.

Now, instead of use unit_cost of valuation layer, value / quantity is used instead. Refunds are already taken in consideration in valuation layers. Before, only the first valuation layer is taken in consideration, now all valuation layers are considered. (FIFO product valuation and one move needs to be splitted in 2 stock.move.lines and each move line has different lots with different values)

Also added tests, more concise translations and "help" to fields to know exactly what does.

https://www.loom.com/share/9cc8c826b8054b62a508d561632b837c?sid=ce29f0dd-9fd4-40bd-b615-4f775f42b339

MT-6136 @moduon @yajo @EmilioPascual @rafaelbn @sergio-teruel please review if you want :)

OCA-git-bot commented 5 months ago

Hi @sergio-teruel, some modules you are maintaining are being modified, check this out!

yajo commented 5 months ago

Could you merge please @sergio-teruel? I don't have permission here

sergio-teruel commented 5 months ago

Ohhh!! I'm not a PSC... :sob:

rafaelbn commented 5 months ago

Hello all! @sergio-teruel @Gelojr @yajo @Gelojr !

I've reviewed and I have doubts in cost price delivered and a better order in columns 😇

This is my video review (1.5x is 5 minutes)

https://www.loom.com/share/3ffc172466d24629bee5247cdb89f9f6?sid=f0146094-5bf3-4798-936f-5ea6bc32810e

🙏🏼 Thank you! Reviewing with ❤️ 😄

imagen

Gelojr commented 5 months ago

Hello all! @sergio-teruel @Gelojr @yajo @Gelojr !

I've reviewed and I have doubts in cost price delivered and a better order in columns 😇

This is my video review (1.5x is 5 minutes)

https://www.loom.com/share/3ffc172466d24629bee5247cdb89f9f6?sid=f0146094-5bf3-4798-936f-5ea6bc32810e

🙏🏼 Thank you! Reviewing with ❤️ 😄

imagen

I believe that the Cost price dlvd. column should appear, since it is the total cost of what is delivered. It seems that it is not calculated correctly, since it is calculating the cost of the quantity ordered.

Shide commented 5 months ago

Hello all! @sergio-teruel @Gelojr @yajo @Gelojr !

I've reviewed and I have doubts in cost price delivered and a better order in columns 😇

This is my video review (1.5x is 5 minutes)

https://www.loom.com/share/3ffc172466d24629bee5247cdb89f9f6?sid=f0146094-5bf3-4798-936f-5ea6bc32810e

🙏🏼 Thank you! Reviewing with ❤️ 😄

imagen

Those columns are not duplicated, but in your case, you are using Standard or AVCO product valuation. Those columns are not meaningfull in your context, but in a FIFO valuation should change a bit.

In any case, for the commercial user, Cost and Margin are welcome because they cannot see dlvd. margins when doing the quotation. If commercial user receives a % extra payment for each sale based on the margin (assume margin dlvd. because cost can be modified freely on the line) and valuations are Standard or AVCO, they can assume that dlvd. cost and margins are going to be the same as sale cost and margins.

Then,

Since all columns can be used for different type of users and Odoo allows to custom tree columns per user, the code as it is will work for a variety of roles. I won't add anything more. Just inform users that what do each column and what are suggested columns to see on each role.

rafaelbn commented 5 months ago

After discussing with @Shide , this ho ahead as resolves BUG and later we could improve it.

Thank you!! 😃

OCA-git-bot commented 5 months ago

This PR looks fantastic, let's merge it! Prepared branch 16.0-ocabot-merge-pr-207-by-rafaelbn-bump-patch, awaiting test results.

OCA-git-bot commented 5 months ago

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