-
Notifications
You must be signed in to change notification settings - Fork 42
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
[16.0][IMP] rma: create incoming shipment from rma group #508
base: 16.0
Are you sure you want to change the base?
[16.0][IMP] rma: create incoming shipment from rma group #508
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 16.0 #508 +/- ##
==========================================
- Coverage 80.58% 80.56% -0.03%
==========================================
Files 128 128
Lines 4889 4898 +9
Branches 794 796 +2
==========================================
+ Hits 3940 3946 +6
- Misses 728 730 +2
- Partials 221 222 +1
Continue to review full report in Codecov by Sentry.
|
4e82915
to
0e68988
Compare
@@ -108,7 +108,7 @@ | |||
name="%(action_rma_picking_in)d" | |||
string="Create Incoming Shipment" | |||
class="oe_highlight" | |||
attrs="{'invisible':['|', '|', '|', ('qty_to_receive', '=', 0), ('qty_to_receive', '<', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}" | |||
attrs="{'invisible':['|', '|', ('qty_to_receive', '<', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}" | |||
type="action" |
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 this change ? Reading the code, it seems that the create incoming shipment button will be displayed twice if qty_to_receive = 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.
@florian-dacosta ,
Reading the calculation method for the 'qty_to_receive' field, it seems to me that qty_to_receive=0.0 if receipt_policy not in ["ordered", "delivered"](so for receipt_policy='no').
This is why I told myself that putting in the domain ('qty_to_receive', '=', 0) and ('receipt_policy', '=', 'no') was a duplicate.
@api.depends(
"move_ids",
"move_ids.state",
"qty_received",
"receipt_policy",
"product_qty",
"type",
)
def _compute_qty_to_receive(self):
for rec in self:
rec.qty_to_receive = 0.0
if rec.receipt_policy == "ordered":
rec.qty_to_receive = rec.product_qty - rec.qty_received
elif rec.receipt_policy == "delivered":
rec.qty_to_receive = rec.qty_delivered - rec.qty_received
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.
@chafique-delli But qty_to_receive may be 0 too for receipt_policy in ["ordered", "delivered"]. And in this case, we want to hide this button, as the other not highlighted will be displayed then.
For now with this change, if receipt_policy = "ordered" and qty_to_receive = 0, we have twice the same button (highlighted and not highlighted)
<button | ||
name="%(action_rma_picking_in)d" | ||
string="Create Incoming Shipment" | ||
attrs="{'invisible':['|', '|', ('qty_to_receive', '=', 0), ('qty_to_receive', '>', 0), ('state', '!=', 'approved')]}" |
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 button would be hided if qty_to_receive = 0 but displayed if qty_to_receive < 0, it does not seem logic to me.
If it is visible when qty_to_receive < 0, it should also be visible when qty_to_receive = 0.
Also, I believe you need to hide this button if no lines have a receipt policy set, like it is on rma line side.
I believe we have 2 options :
-
We behave in a different manner than on line side : we display only the receive button when we expected a reception (qty_to_receive > 0) and we don't display the button in the other case. Then, if the user want to force a reception, he should go on rma line where the button is displayed even if we don't expect him to generate a reception.
It may be a bit confusing for the user to have a different behavior but if seems better/safer to me since on group, we manage multiple lines... -
Act like on rma line side exactly, then you have to add a field on group with the receipt policy, to hide the button if no policy is set.
@sebastienbeau, it would be nice to have your opinion on this
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 think the best solution is the 1. User need a simple UI for processing the 99% of case. So only making visible the right button when there is something to do is the best option.
Then for the advanced case the user can go to the line and make some specific action.
Thanks for your work
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 agree with @sebastienbeau in this case. Better to stick to the most common use case.
if active_model == "rma.order": | ||
rma = rma_obj.browse(active_ids) | ||
lines = rma.rma_line_ids.filtered(lambda x: x.state == "approved") | ||
else: |
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 don't think all approved lines should always be added when coming from a group.
I'd say, if the highlighted button is pressed, then we should only get lines having a qty_to_receive > 0
(maybe passing a context on the button for instance ?)
And if the not highlighted button is pressed, then all lines with a receipt policy != 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.
@florian-dacosta , it's done.
35e7ac5
to
6fd5d2f
Compare
@AaronHForgeFlow , @JordiBForgeFlow , Please, I would like to have your opinion on processing RMA lines from the RMA group. |
@chafique-delli I have not looked much into the code. But the idea of being able to generate a single receipts/deliveries/refunds for a RMA group seems like a good feature to me. |
Ok, if that suits you, I will continue in this direction. THANKS |
a4456df
to
d657fa1
Compare
d657fa1
to
8c6cbcb
Compare
@sebastienbeau , @florian-dacosta , @AaronHForgeFlow , a review please. |
8c6cbcb
to
8d59e55
Compare
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.
Tested so far:
- create a single receipt order to process several RMA Group lines
- create a single delivery order to process several RMA Group lines
It works good. Thanks. Do you plan to continue?
7eba3ea
to
e84ed45
Compare
I have completed the changes planned for the RMA Group. |
Thank you @chafique-delli I will review it soon |
471941b
to
4167a0a
Compare
@chafique-delli Thank you for the work, only a couple of things: The refunds for the groups are created good, but for some reason the button in the rma group that takes the user to the created refund it is not working, it does nothing: The sale order creation is correct, and linked correctly to the rma lines of the group. I think a small but nice addition here is to be able to access the generated sales order directly from the group, same as we do for the incoming shipments, deliveries or refunds. Do you think you can do it? Aside from this. I think the only think pending is the discussion about the conditions on the displaying of the buttons. |
@AaronHForgeFlow , thanks for the review. |
23df512
to
58d68a5
Compare
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.
@chafique-delli
I think we have a problem of consistency. There is a different behavior for each button and I find it very confusing.
Incoming shipment and outgoing shipment : Only visible if there is at least one line with a qty to receive/to_deliver
Take by default only rma lines with a qty_to_receive/deliver > 0
Create refund : always visible. Not highlighted if no quantity to refund on any line / highlighted if at least one line with a qty.
Then by default in the wizard, we have all lines, even those which would not have the refund in its operation (in case of different operation by line).
Create SO => Behave like create refund.
In my opinion, we should have the same behavior as for incoming/outgoing shipments. (1 button + take only lines which have a qty to refund / 1 button + only lines with a qty_to_sell > 0)
rma_account/wizards/rma_refund.py
Outdated
lines = rma_line_obj.browse(rma_line_ids) | ||
if active_model == "rma.order": | ||
rma = rma_obj.browse(active_ids) | ||
lines = rma.rma_line_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.
shouldn't we have the same logic as for incoming/outgoing shipment creation, take only the line with qty_to_refund > 0?
lines = rma.rma_line_ids | ||
else: | ||
lines = rma_line_obj.browse(active_ids) | ||
for line in lines: |
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 think this part does not make sense. We check all lines from rma group (or selected rma lines from ui via active_ids) are approved... But then, the refund is created on the base of the wizard item_ids, which may not be related to the checked lines...
Example : select 2 rma lines first one is not approved, second one is ok.
Click on action => create refund. Delete the first line because you changed your mind => click on invoice_refund. It will block because the first line is not approved... But this line won't even be in the refund since it has been deleted from the wizard.
I'd just check the rma lines doing something like lines = self.item_ids.line_id
instead. It workfs for both case (rma lines/rma group). Does it make sense to you?
rma = rma_obj.browse(active_ids) | ||
lines = rma.rma_line_ids | ||
else: | ||
lines = rma_line_obj.browse(active_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.
I don't understand this whole method. Is this really used ? I think it could be removed fully...
It is a compute method from line_id field to link the item line with the rma_line, but on the loop, it will always take the same rma_line right ? (the first one in active_ids/rma order). So this method assign all item line to the same rma_line.
Then in default_get it is well set...I guess since it is set on default_get, this _compute_line_id is kind of useless, that is why it is working... I'd remove it totally...
lines = rma_line_obj.browse(rma_line_ids) | ||
if active_model == "rma.order": | ||
rma = rma_obj.browse(active_ids) | ||
lines = rma.rma_line_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.
only those we qty_to_sell > 0 ?
@@ -134,4 +134,28 @@ | |||
</field> | |||
</record> | |||
|
|||
<record id="view_rma_button_form" model="ir.ui.view"> |
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 find it quite confusing to have an override of rma.order
view in rma_make_picking_view.xml file.
I know there is other similar cases in the rma modules but do we really want to continue this way ? Should it not go to rma_order_view.xml ? @AaronHForgeFlow
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.
@florian-dacosta, better to have file for model, whenever possible, in the next versions some cleanup will be done, hopefully.
ab99e40
to
38d71bb
Compare
4195a38
to
5834842
Compare
@AaronHForgeFlow , for the refund button, it's fixed and I added the smart button for the sales order. |
3b54408
to
3c88cee
Compare
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.
All seems fine to me now, thanks
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.
LGTM (code review)
@AaronHForgeFlow I believe this PR is ready, when you have time to finish the review! (I'll port it to 17 when merged) |
ac0b63b
to
699923e
Compare
Nice improvement. Functional tests look good so far. I will ask more people affected by this change to review this. |
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.
Create a RMA group with 3 lines, all of them with opreation "Replace after receive". The RMA lines are created find and the Incoming shipment is created fine. However, the button "create Incoming shipment" is still highlighted when if the shipment is already ready to be received:
If I click on the button again it is proposing me to craete a new incoming shipment for the same quantity, that is not correct:
Is it that because of the changes in the "quantity to receive" calculation?
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.
LGTM (code review)
Better to add some tests
…om wizard views to rma_order_view.xml files
… made during the review
699923e
to
d184449
Compare
Everything that is created via the wizards at the level of an RMA line, we wish to do at the level of the RMA group, namely:
I would like to have your opinion on this process.
If this does not pose a problem for you then I will continue my work to extend this to other wizards ('CREATE DELIVERY', 'CREATE SUPPLIER RMA', ....).
@CarlosVForgeFlow , @florian-dacosta , @AaronHForgeFlow