We really appreciate your efforts for detailed explanation, the analysis you did and also for the patch.
However, in your fix, there is a small mistake,
- if picking_obj.invoice_state == 'invoiced':
+ if 'invoice_state' not in default and picking_obj.invoice_state == 'invoiced':
default['invoice_state'] = '2binvoiced'
With your fix, the code in the `if` block will never execute as the condition you placed will check for the `invoice_state` key in `default` dictionary, but, when the copy() is called from /stock/wizard/stock_return_picking.py line 171, `invoice_state` key set statically, so the condition `if 'invoice_state' not in default` will never be true.
The reason why it works at your end is, the `Return Products` wizard will send the value for it's `invoice_state` field that is, `none` or `2binvoiced` and this value is going to be sent in `default` dictionary in /stock/stock.py line 702, and the returned picking will be created and it's `Invoice Control` field will have the value of `invoice_state` dict.
As per my investigation, this condition is not needed, because, whatever the `invoice_state` selected in `Return Products` wizard, that should be set in the `Invoice Control` in returned picking! or the fix could be modified like,
- if picking_obj.invoice_state == 'invoiced':
+ if default['invoice_state'] != 'none' and picking_obj.invoice_state == 'invoiced':
default['invoice_state'] = '2binvoiced'
But, as per my opinion, the condition is not needed, hence I will prefer to fix by removing this condition and will create a branch.
@Alexis de Lattre: Thanks for your analysis which traced the root cause of the issue.
Hello Alexis de Lattre,
We really appreciate your efforts for detailed explanation, the analysis you did and also for the patch.
However, in your fix, there is a small mistake,
- if picking_ obj.invoice_ state == 'invoiced': obj.invoice_ state == 'invoiced': 'invoice_ state'] = '2binvoiced'
+ if 'invoice_state' not in default and picking_
default[
With your fix, the code in the `if` block will never execute as the condition you placed will check for the `invoice_state` key in `default` dictionary, but, when the copy() is called from /stock/ wizard/ stock_return_ picking. py line 171, `invoice_state` key set statically, so the condition `if 'invoice_state' not in default` will never be true.
The reason why it works at your end is, the `Return Products` wizard will send the value for it's `invoice_state` field that is, `none` or `2binvoiced` and this value is going to be sent in `default` dictionary in /stock/stock.py line 702, and the returned picking will be created and it's `Invoice Control` field will have the value of `invoice_state` dict.
As per my investigation, this condition is not needed, because, whatever the `invoice_state` selected in `Return Products` wizard, that should be set in the `Invoice Control` in returned picking! or the fix could be modified like,
- if picking_ obj.invoice_ state == 'invoiced': 'invoice_ state'] != 'none' and picking_ obj.invoice_ state == 'invoiced': 'invoice_ state'] = '2binvoiced'
+ if default[
default[
But, as per my opinion, the condition is not needed, hence I will prefer to fix by removing this condition and will create a branch.
@Alexis de Lattre: Thanks for your analysis which traced the root cause of the issue.