[FIX] sale_order_product_recommendation: wizard didn't properly get on memory created lines#713
Conversation
|
@yajo you were the one that creates this. Can you please check why this is needed? |
| for line in self.order_id.order_line: | ||
| found_line = found_dict[line.product_id.id] | ||
| new_line = RecomendationLine.new({ | ||
| new_line = RecomendationLine.create({ |
There was a problem hiding this comment.
In general terms, creating records in an onchange is not a very good idea... This is a transient model, so records get removed every now and then, so maybe we can make an exception?
🤔 Have you tried converting each .new() to (0, 0, {...})? I think that behind the scenes both get casted to the same operation, but @rco-odoo told me recently that this wasn't 100% the case. At least it's worth trying?
There was a problem hiding this comment.
Of course, you shouldn't create on an onchange! @chienandalu this is not correct, so you have to find another way to solve the problem.
| vals['line_ids'] = [ | ||
| line for line in vals['line_ids'] if line[2]["is_modified"]] | ||
| return super(SaleOrderRecommendation, self).create(vals) | ||
| self.line_ids = wiz_line_ids |
There was a problem hiding this comment.
Or is it possible that all those += mess things up? Have you tried just storing all new records in a separate variable and assigning it just once at the end like here?
BTW you can remove line 56 with this approach.
| "sale.order.recommendation", | ||
| "Wizard", | ||
| ondelete="cascade", | ||
| required=True, |
Using force_save option in views
dd69a81 to
6d95a59
Compare
|
@yajo, this is the correct solution @chienandalu please review it. |
chienandalu
left a comment
There was a problem hiding this comment.
👍 force_save was the key
I couldn't get to the origin point of the issue (lines info gets lost in the wizard action) but this patch fixes it.
cc @Tecnativa