-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
[MIG][8.0] replenishment_cost + product_cost_incl_bom #30
Conversation
18dd17f
to
0398e26
Compare
README.md
Outdated
[product_replenishment_cost](product_replenishment_cost/) | 8.0.2.0.0 | Replenishment cost | ||
[product_standard_margin](product_standard_margin/) | 8.0.2.0.0 | Product Margin and Margin Rate | ||
|
||
Unported addons | ||
--------------- | ||
addon | version | summary | ||
--- | --- | --- | ||
[product_cost_incl_bom](product_cost_incl_bom/) | 1.0 (unported) | Product Cost incl. BOM |
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.
This file is updated automatically by an OCA script.
cost = 0 | ||
if product.id in res.keys(): | ||
cost = res[product.id] | ||
product.replenishment_cost = cost |
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.
Maybe product.replenishment_cost = res.get(product.id, 0)
?
|
||
from . import product_product | ||
from . import product_product, product_template |
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.
Please split one import per line.
|
||
replenishment_cost = fields.Float( | ||
compute=_get_replenishment_cost, store=True, |
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.
Why did you remove the store
attribute ?
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.
I had 2 reasons to remove store=True
- The replenishment cost field defined in product_replenishment_cost module with store=True, creates the field in database with the value of product's standard_price and the value is not recomputed at the time of product_cost_incl_bom module installation.
- Replenishment cost needs to be changed for each change in bom lines of product, when there is a change in their replenishment cost value and it did not work in that case as the method was not triggered for store=True. (when we change the BOM directly, it did not trigger the compute method and it does not allow multi-level BOM)
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.
@sylvain-garancher please check the points I have listed out.
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.
Ok, I see, and I don't find a trigger for that. With the explanation, it's fine.
If the issue is with the other module, maybe you can leave store=True
here, and explicitely change to store=False
in the other module ? (with a comment explaining why)
@api.multi | ||
@api.depends('standard_price') | ||
def _get_replenishment_cost(self): | ||
replenishment_cost = 0.0 |
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.
If a template has no variant, it will pick the value computed for the previous template in the loop.
You should initialize the variable in the for loop.
def _get_replenishment_cost(self): | ||
replenishment_cost = 0.0 | ||
for template in self: | ||
variants = template.mapped('product_variant_ids') |
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.
variants = template.product_variant_ids
is enough here, mapped is useful when you work on multiple records, or through multiple fields.
e29e4e0
to
0bf1e71
Compare
@sylvain-garancher corrections done |
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.
Code review 👍
Restarted Travis and I don't get why the builds are shown as failed whereas the builds exit with 0. |
0bf1e71
to
2a11559
Compare
closing. You can also review the PR for V12 here : #50 |
No description provided.