Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions sale_stock_ux/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def _compute_delivery_status(self):
if line.order_id.force_delivery_status:
line.delivery_status = line.order_id.force_delivery_status
continue

if float_compare(line.all_qty_delivered, line.product_uom_qty, precision_digits=precision) == -1:
delivery_status = "to deliver"
elif float_compare(line.all_qty_delivered, line.product_uom_qty, precision_digits=precision) >= 0:
Expand Down Expand Up @@ -140,7 +139,10 @@ def _compute_quantity_returned(self):
if order_line.qty_delivered_method == "stock_move":
return_moves = order_line.mapped("move_ids").filtered(
lambda r: (
r.state == "done" and not r.scrapped and r.location_dest_id.usage != "customer" and r.to_refund
r.state == "done"
and not r.scrapped
and r.location_dest_id.usage != "customer"
and not r.to_redeliver
)
)
for move in return_moves:
Expand Down Expand Up @@ -181,8 +183,8 @@ def _compute_quantity_returned(self):
continue
filters = {
"outgoing_moves": lambda m: m.location_dest_id.usage == "customer"
and (not m.origin_returned_move_id or (m.origin_returned_move_id and m.to_refund)),
"incoming_moves": lambda m: m.location_dest_id.usage != "customer" and m.to_refund,
and (not m.origin_returned_move_id or (m.origin_returned_move_id and not m.to_redeliver)),
"incoming_moves": lambda m: m.location_dest_id.usage != "customer" and not m.to_redeliver,
}
order_qty = order_line.product_uom._compute_quantity(
order_line.product_uom_qty, relevant_bom.product_uom_id
Expand Down
4 changes: 4 additions & 0 deletions sale_stock_ux/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class StockMove(models.Model):
related="group_id.sale_id",
)

to_redeliver = fields.Boolean(
default=False, help="If true, then the returned quantities on the SO line will not be imputed"
)

def _get_new_picking_values(self):
"""return create values for new picking that will be linked with group
of moves in self.
Expand Down
5 changes: 5 additions & 0 deletions sale_stock_ux/wizards/stock_return_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ def default_get(self, fields):
except KeyError:
pass
return result

def action_create_exchanges(self):
action = super().action_create_exchanges()
self.picking_id.return_ids.move_ids.write({"to_redeliver": True})
return action
9 changes: 4 additions & 5 deletions sale_stock_ux/wizards/stock_return_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
<field name="arch" type="xml">
<field name="product_return_moves" position="before">
<div class="alert alert-info" role="alert" style="margin-bottom:0px;">
<b>Importante</b>: si está haciendo un movimiento inverso relacionado a un Pedido de Venta o de Compra, entonces debe prestar atención al campo <b>"Para Abonar (actualizar OC/OV)"</b>, donde, si:
<b>Importante</b>: si está haciendo un movimiento inverso relacionado a un Pedido de Venta o de Compra, entonces debe tener en cuenta qué acción ejecutar al devolver:
<ul>
<li>
<b>Está marcado</b>: entonces <b>se va</b> a actualizar la OC/OV considerando que los productos devueltos no se van a volver a entregar, y por ende, permitiendo hacer una nota de crédito si los items ya fueron facturados, o tener en cuenta esta devolución al hacer la factura.
<b>Devolver y Devolver Todo</b>: Se modificará la OV/OC, disminuyendo las cantidades a facturar. Este caso implica que los productos devueltos no se van a volver a entregar.
</li>
<li>
<b>No está marcado</b>: entonces <b>no se va</b> a actualizar la OC/OV. Esto es común, por ejemplo, si se devuelve mercadería defectuosa y se pretende hacer una nueva entrega de la misma.
<b>Devolución para Cambio</b>: No se modificará la OV/OC ya que se entiende que se volverán a entregar/recibir los productos devueltos. Esta acción generará automáticamente 2 movimientos: Uno para hacer la devolución y el otro para volver a entregar o recibir el producto (según corresponda)".
</li>
</ul>
Si la devolución no está ligada a una OC/OV entonces este campo no repercute en nada.
</div>
</field>
<field name="to_refund" position="attributes">
Expand All @@ -25,7 +24,7 @@
<!-- always show the button -->
<attribute name="groups"></attribute>
<!-- porque la traducción no se actualiza -->
<attribute name="string">Para Abonar (actualizar OC/OV)</attribute>
<attribute name="column_invisible">1</attribute>
</field>
</field>
</record>
Expand Down