-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Revert changes to computation of _immediately_usable_qty + distinguish product/variants #80
Revert changes to computation of _immediately_usable_qty + distinguish product/variants #80
Conversation
@@ -29,35 +29,23 @@ class ProductTemplate(models.Model): | |||
""" | |||
_inherit = 'product.template' | |||
|
|||
# immediately usable quantity caluculated with the quant method | |||
@api.multi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put @api.one and avoid the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
@gfcapalbo @gurneyalex @StefanRijnhart @laetitia-gangloff do you agree? |
Why keep immediately_usable_qty if it is to set the same value than virtual_available ? Other question, why stock_available_immediately is empty ? |
|
I also, I wonder why the module I also agree with your explanation, that a quant can be reserved but still available but if you do that, the module |
OK I hadn't understood your statement that You may mark "WIP". |
Thank you @clonedagain for detecting problems post-merge. The initial concept of defining "available immediately" via quants was due to the fact that I had a client with internal moves to production that shouldn't be counted. In my case it works very well, but there are more use cases to consider. What I don't understand is the alternative: self.immediately_usable_qty = self.virtual_available we are just duplicating information, doesn't seem to make sense.If the two values are the same just get rid of one. virtual_available is defined as: virtual_available = float_round(quants.get(id, 0.0) + moves_in.get(id, 0.0) - moves_out.get(id, 0.0), precision_rounding=product.uom_id.rounding) Does it semantically may sense to define immediately_available as: quants - moves out ? In other words virtual_available + moves_in ? I propose docstrings to explain the semantics of each variable. |
This reverts commit c74aab4.
…he quant calculations done in product template are fine." This reverts commit d6dee6f.
The previous fix restored stock_available but then there was no way to exclude the incomming moves from the count. This belongs in stock_available_immediately, restoring it cleanly. This commit also takes care to respect the distinction between templates and variants, so it should fix OCA#73 too.
I've restored the computation in stock_available_immediatly so should make sense now. @gfcapalbo yes "immediately_available as: quants - moves out" is basically what stock_available_immediatly does now. |
With your additions it makes sense. |
I think the travis failure is unrelated isn't it? |
👍 Ran the following test scenario on runbot
Similar test with warehouse configured in Pick + Ship Also, this new implementation handles the context properly so it is possible by passing a modified to context to limit the stock to a given warehouse. |
👍 |
@clonedagain build should be fixed by #82 |
…into 8.0-stock_available-based-on-virtual
193ea55
to
d1fea83
Compare
@gurneyalex I think travis now chokes on the unicode author "Numérigraphe". |
@clonedagain yes and you can assign @moylop260 to the issue 😉 |
@clonedagain Start lint check just in modules changed
************* Module stock_available_immediately
stock_available_immediately/__init__.py:1: [C8201(no-utf8-coding-comment), ] No UTF-8 coding comment found: Use `# coding: utf-8` or `# -*- coding: utf-8 -*-`
stock_available_immediately/__init__.py:1: [W8201(incoherent-interpreter-exec-perm), ] Incoherent interpreter comment and executable permission. Interpreter: [] Exec perm: True
************* Module stock_available_immediately.models.__init__
stock_available_immediately/models/__init__.py:1: [C8201(no-utf8-coding-comment), ] No UTF-8 coding comment found: Use `# coding: utf-8` or `# -*- coding: utf-8 -*-`
stock_available_immediately/models/__init__.py:1: [W8201(incoherent-interpreter-exec-perm), ] Incoherent interpreter comment and executable permission. Interpreter: [] Exec perm: True
************* Module stock_available_immediately.tests.__init__
stock_available_immediately/tests/__init__.py:1: [C8201(no-utf8-coding-comment), ] No UTF-8 coding comment found: Use `# coding: utf-8` or `# -*- coding: utf-8 -*-`
************* Module stock_available_immediately.tests.test_stock_available_immediately
stock_available_immediately/tests/test_stock_available_immediately.py:23: [C8104(class-camelcase), testStockLogisticsWarehouse] Use `CamelCase` "TestStockLogisticsWarehouse" in class name "testStockLogisticsWarehouse". You can use oca-autopep8 of https://github.com/OCA/maintainer-tools to auto fix it.
Found 6 errors in modules changed.
These checks are still in beta: they won't affect your build status for now.
|
I don't think that |
I'll check it now thanks. |
👍 |
@guewen |
👍 |
…-virtual Revert changes to computation of _immediately_usable_qty + distinguish product/variants
Commit 6c16913 changed the way we compute the immediately_usable_qty: instead of using the virtual stock, we used the sum of quants without reservations. But a quant may actually be reserved and still be available (for example it may be reserved for an internal move).
Fixes #79
Also fixes #73 by correctly computing template value as sum of variant values, and placing the fields on views of both the templates and variants.