[IMP] stock: link to source origin in reception report
Make it so the (sales order) of a picking is also a clickable link in the reception report. This was done in a flexible way so it should work in theory for any stock.move._get_source_document() record, but it is only applicable to sales orders for now. Part of Task: 2632884 X-original-commit: d8cd091c3b61ac212fe9e92d532af7cefcf315a6 Part-of: odoo/odoo#79408
This commit is contained in:
@@ -86,10 +86,12 @@ class ReceptionReport(models.AbstractModel):
|
||||
# show potential moves that can be assigned
|
||||
for product_id, outs in products_to_outs.items():
|
||||
for out in outs:
|
||||
# only show pickings or MOs, no SOs
|
||||
source = out.picking_id if out.picking_id else out._get_source_document()
|
||||
# we expect len(source) = 2 when picking + origin [e.g. SO] and len() = 1 otherwise [e.g. MO]
|
||||
source = (out._get_source_document(),)
|
||||
if not source:
|
||||
continue
|
||||
if out.picking_id and source[0] != out.picking_id:
|
||||
source = (out.picking_id, source[0])
|
||||
|
||||
qty_to_reserve = out.product_qty
|
||||
product_uom = out.product_id.uom_id
|
||||
@@ -114,14 +116,14 @@ class ReceptionReport(models.AbstractModel):
|
||||
break
|
||||
|
||||
if not float_is_zero(qty_done, precision_rounding=product_uom.rounding):
|
||||
sources_to_lines[source].append(self._prepare_report_line(qty_done, product_id, out, source, move_ins=self.env['stock.move'].browse(moves_in_ids)))
|
||||
sources_to_lines[source].append(self._prepare_report_line(qty_done, product_id, out, source[0], move_ins=self.env['stock.move'].browse(moves_in_ids)))
|
||||
|
||||
# draft qtys can be shown but not assigned
|
||||
qty_expected = product_to_qty_draft.get(product_id, 0)
|
||||
if float_compare(qty_to_reserve, qty_done, precision_rounding=product_uom.rounding) > 0 and\
|
||||
not float_is_zero(qty_expected, precision_rounding=product_uom.rounding):
|
||||
to_expect = min(qty_expected, qty_to_reserve - qty_done)
|
||||
sources_to_lines[source].append(self._prepare_report_line(to_expect, product_id, out, source, is_qty_assignable=False))
|
||||
sources_to_lines[source].append(self._prepare_report_line(to_expect, product_id, out, source[0], is_qty_assignable=False))
|
||||
product_to_qty_draft[product_id] -= to_expect
|
||||
|
||||
# show already assigned moves
|
||||
@@ -135,17 +137,19 @@ class ReceptionReport(models.AbstractModel):
|
||||
# it is possible there are different in moves linked to the same out moves due to batch
|
||||
# => we guess as to which outs correspond to this report...
|
||||
continue
|
||||
source = out_move.picking_id if out_move.picking_id else out_move._get_source_document()
|
||||
source = (out_move._get_source_document(),)
|
||||
if not source:
|
||||
continue
|
||||
if out_move.picking_id and source[0] != out_move.picking_id:
|
||||
source = (out_move.picking_id, source[0])
|
||||
qty_assigned = min(total_assigned, out_move.product_qty)
|
||||
sources_to_lines[source].append(
|
||||
self._prepare_report_line(qty_assigned, product_id, out_move, source, is_assigned=True, move_ins=moves_in))
|
||||
self._prepare_report_line(qty_assigned, product_id, out_move, source[0], is_assigned=True, move_ins=moves_in))
|
||||
|
||||
# dates aren't auto-formatted when printed in report :(
|
||||
sources_to_formatted_scheduled_date = defaultdict(list)
|
||||
for source, dummy in sources_to_lines.items():
|
||||
sources_to_formatted_scheduled_date[source] = self._get_formatted_scheduled_date(source)
|
||||
sources_to_formatted_scheduled_date[source] = self._get_formatted_scheduled_date(source[0])
|
||||
|
||||
return {
|
||||
'data': data,
|
||||
|
||||
@@ -62,17 +62,17 @@
|
||||
<thead t-if="report_type == 'html' or any(line['is_assigned'] for line in sources_to_lines[source])">
|
||||
<tr class="bg-light">
|
||||
<th>
|
||||
<i t-if="source.priority == '1'" class="o_priority o_priority_star fa fa-star"/>
|
||||
<a name="source_link" href="#" t-att-res-model="source._name" view-type="form" t-att-res-id="source.id" t-esc="source.display_name"/>
|
||||
<span t-if="source._name == 'stock.picking' and source.origin">
|
||||
(<t t-esc="source.origin"/>)
|
||||
<i t-if="source[0].priority == '1'" class="o_priority o_priority_star fa fa-star"/>
|
||||
<a name="source_link" href="#" t-att-res-model="source[0]._name" view-type="form" t-att-res-id="source[0].id" t-out="source[0].display_name"/>
|
||||
<span t-if="len(source) > 1">
|
||||
(<a name="origin_link" href="#" t-att-res-model="source[1]._name" view-type="form" t-att-res-id="source[1].id" t-out="source[1].display_name"/>)
|
||||
</span>
|
||||
<span t-if="source._name == 'stock.picking' and source.partner_id">:
|
||||
<span t-if="source[0]._name == 'stock.picking' and source[0].partner_id">:
|
||||
<a name="source_link" href="#"
|
||||
t-att-res-model="source.partner_id._name"
|
||||
t-att-res-id="source.partner_id.id"
|
||||
t-att-res-model="source[0].partner_id._name"
|
||||
t-att-res-id="source[0].partner_id.id"
|
||||
view-type="form"
|
||||
t-esc="source.partner_id.name"/>
|
||||
t-out="source[0].partner_id.name"/>
|
||||
</span>
|
||||
</th>
|
||||
<th>Expected Delivery: <t t-esc="sources_to_formatted_scheduled_date[source]"/></th>
|
||||
|
||||
Reference in New Issue
Block a user