-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
10.0 product supplierinfo discount #407
10.0 product supplierinfo discount #407
Conversation
@StefanRijnhart can you rebase it? The depends is now merged so I think travis should be happy with that! 😄 |
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. (only : 9c219cf)
no test.
9c219cf
to
4b6bfad
Compare
@JonathanNEMRY thanks for noting! Now rebased. |
Hi. I'm just thought about a potential improvment. For the time being :
The Idea :
Pro :
Cons :
regards. |
@legalsylvain I don't think I agree with your conclusion that this module changes the semantics of the field. Is it not the case that without this module, the price field represents both the gross price as well as the net price? You may as well add a new field for the net price instead of adding a new field for the gross price. But IMHO it is out of scope for this migration. |
Hi @StefanRijnhart.
Well, for the supplierinfo, it is a matter of PoV. I can understand your. About purchase.order.line, well it is written in the current readme file, that module breaks the meaning of the price_unit field. Maybe it's wrong, but in that case, it should be removed. Don't you think ?
Of course, as said, not a blocking point, just a question ! |
@legalsylvain The question had to be asked. I think these concepts have to be clear for user, at least. |
The problem is that the same field, Any way, |
I'm going to work on an 11.0 port of this shortly (fundamentally just removing procurement.order). I just wanted to check, are there any changes planned on this PR before it's merged into 10.0 that I should take into consideration? |
@lukebranch no, I think this is working fine as it is now. Maybe if you review we can have it merged! |
Brilliant, thanks for the reply. I'll take a look at this over the weekend and get back to you. |
@lukebranch did you take the time to review this PR ? |
I don't now why close the other PR if this PR is down! |
Hi @apesquero what is down about this PR? |
Nothing, I think this PR is perfect, but it does not finish being published. |
Then make your review here and follow the process, or use it. |
@pedrobaeza as the original author, can I have your additional approval on the added change in 61a32a0726? |
@apesquero still looking forward to your review! Reviews are the only thing that can get any PR merged. |
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.
Minor comments.
One can have performance impacts. Keep eye on it
product_supplierinfo = self.product_id._select_seller( | ||
partner_id=self.partner_id, quantity=self.product_qty, | ||
date=self.order_id.date_order and | ||
self.order_id.date_order[:10], |
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 cannot do that. Use
fields.Date.to_string(fields.Date.from_string(self.order_id.date_order))
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.
Fixed!
discount_map = dict( | ||
[(line.product_id.product_tmpl_id.id, line.discount) | ||
for line in self.order_line.filtered('discount')]) | ||
return super(PurchaseOrder, self.with_context( |
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.
As with_context() recreate new environment, it is strongly encouraged to avoid this to pass parameters. Performance reasons
But this works. Improvement in another version.
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.
@rousseldenis sure, this will lead to a new read() on the purchase order and its lines but I'm a bit surprised you mention it as a bad practice. Have you got a link to guidelines from Odoo or the OCA that mention with_context as such?
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.
Nope, that is based on experienced cases.
For this, I don't have an immediate solution, I didn't study it deeply.
I'm sorry, I'm new, it's possible that I did not express myself well, I think your code is correct. I have no review! |
@apesquero in that case, please go to the Review Changes on the Files Changed tab on this PR and select 'Approve'. Thanks! |
61a32a0
to
9f07868
Compare
""" | ||
res = super(PurchaseOrderLine, self)._onchange_quantity() | ||
if self.product_id: | ||
date = False |
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.
@StefanRijnhart Nearly, you have to define it to None. Either function _select_seller will crash (Look at it - same case here OCA/stock-logistics-warehouse#351).
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.
Thanks for spotting this! Changed to None and I fixed another instance of date_order[10] in this code.
when supplierinfo is created automatically
9f07868
to
a95f1bb
Compare
Thanks for your reviews everyone! |
I'm late to the party, but yes, very good addition in 61a32a0, @StefanRijnhart |
Apart from migrating this module to 10.0, this PR suggests to handle an issue that already existed in 9.0 in 61a32a0726: because Odoo automatically creates supplierinfo entries when a purchase order is confirmed, the purchase order lines' discounts should be added to these entries.