Skip to content

Commit

Permalink
[FIX] stock_ux: now origin_description field to show in Delivery Slip
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc committed Jun 22, 2023
1 parent 5589849 commit 62efc2f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion stock_ux/__manifest__.py
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Stock UX',
'version': "15.0.1.3.0",
'version': "15.0.1.4.0",
'category': 'Warehouse Management',
'sequence': 14,
'summary': '',
Expand Down
11 changes: 10 additions & 1 deletion stock_ux/models/stock_move.py
Expand Up @@ -32,6 +32,8 @@ class StockMove(models.Model):
related='picking_id.partner_id',
)

origin_description = fields.Char(compute="_compute_origin_description")

@api.depends(
'move_line_ids.qty_done',
'move_line_ids.lot_id',
Expand All @@ -42,6 +44,13 @@ def _compute_used_lots(self):
rec.move_line_ids.filtered('lot_id').mapped(
lambda x: "%s (%s)" % (x.lot_id.name, x.qty_done)))

def _compute_origin_description(self):
for rec in self:
if rec.sale_line_id:
rec.origin_description = rec.sale_line_id.name
else:
rec.origin_description = False

def set_all_done(self):
self.mapped('move_line_ids').set_all_done()
for rec in self.filtered(lambda x: not x.move_line_ids):
Expand Down Expand Up @@ -174,4 +183,4 @@ def check_cancel(self):
return
if self.filtered(
lambda x: x.picking_id and x.state == 'cancel' and not self.user_has_groups('stock_ux.allow_picking_cancellation')):
raise ValidationError("Only User with 'Picking cancelation allow' rights can cancel pickings")
raise ValidationError("Only User with 'Picking cancelation allow' rights can cancel pickings")
4 changes: 3 additions & 1 deletion stock_ux/models/stock_move_line.py
Expand Up @@ -105,5 +105,7 @@ def _get_aggregated_product_quantities(self, **kwargs):
if bool(self.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin', 'False')) == True:
for line in aggregated_move_lines:
moves = self.filtered(lambda sml: sml.product_id == aggregated_move_lines[line]['product']).mapped('move_id')
aggregated_move_lines[line]['name'] =', '.join(moves.mapped('name'))
if moves.mapped('origin_description'):
aggregated_move_lines[line]['description'] = False
aggregated_move_lines[line]['name'] =', '.join(moves.mapped('origin_description'))
return aggregated_move_lines
20 changes: 7 additions & 13 deletions stock_ux/views/report_deliveryslip.xml
Expand Up @@ -8,17 +8,14 @@
</p>
</table>
<xpath expr="//table[@name='stock_move_table']/tbody/tr/td[1]" position="attributes">
<attribute name="t-if">o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin', 'False') == 'False'</attribute>
<attribute name="t-if">o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin', 'False') == 'False' or not move.origin_description</attribute>
</xpath>
<xpath expr="//table[@name='stock_move_table']/tbody/tr/td[1]" position="after">
<td t-if="o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin') == 'True'">
<span t-field="move.name"/>
<p t-if="move.description_picking != move.product_id.name">
<span t-field="move.description_picking"/>
</p>
<td t-if="o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin') == 'True' and move.origin_description">
<span t-field="move.origin_description"/>
</td>
</xpath>

<!-- Filtramos los stock_move en estado cancelado porque nosotros habilitamos la cancelacion de los mismos,
esto desde el lado de Odoo no se puede lograr -->
<xpath expr="//t[@t-set='lines']" position="after">
Expand All @@ -28,14 +25,11 @@

<template id="stock_report_delivery_has_serial_move_line" inherit_id="stock.stock_report_delivery_has_serial_move_line">
<xpath expr="//td[1]" position="attributes">
<attribute name="t-if">o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin', 'False') == 'False'</attribute>
<attribute name="t-if">o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin', 'False') == 'False' or not move_line.move_id.origin_description</attribute>
</xpath>
<xpath expr="//td[1]" position="after">
<td t-if="o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin') == 'True'">
<span t-field="move_line.move_id.name"/>
<p t-if="move_line.move_id.description_picking != move_line.product_id.name">
<span t-field="move_line.move_id.description_picking"/>
</p>
<td t-if="o.env['ir.config_parameter'].sudo().get_param('stock_ux.delivery_slip_use_origin') == 'True' and move_line.move_id.origin_description">
<span t-field="move_line.move_id.origin_description"/>
</td>
</xpath>
</template>
Expand Down

0 comments on commit 62efc2f

Please sign in to comment.