This commit extends the delivery slip so that products added as a kit component to a stock.picking are grouped together by kit (or non-kit) when at least 1 kit exists. Kit grouping occurs for products from a kit without a package assigned. Non-kit section appears only when no packages are assigned. Implementation notes: - Sub-kits (i.e. kits within kits) of kits are purposely not included - Duplicate product names with different BOMs will be merged into one since there is no straightforward way to distinguish them within current db structure - There are some cases where this doesn't work as expected and may lead to components being grouped together under the same kit even if they are from different kits (e.g. kit1 has bolts and so does kit2 => on slip bolts will only show under kit1 section). Two cases where this happens is when kits are added before 'Operation Type' is specified and 'Operation Type = Manufacturing' This completes subsection 1 of overall Improve delivery slip task. Task: 2039720
82 lines
4.4 KiB
XML
82 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<template id="stock_report_delivery_document_inherit_mrp" inherit_id="stock.report_delivery_document">
|
|
<!-- needs to be set before so elif directly follows if later on -->
|
|
<xpath expr="//t[@name='has_packages']" position="before">
|
|
<!-- get only the top level kits' (i.e. no subkit) move lines for easier mapping later on + we ignore subkit groupings-->
|
|
<!-- note that move.name uses top level kit's product.template.display_name value instead of product.template.name -->
|
|
<t t-set="has_kits" t-value="o.move_line_ids.filtered(lambda l: l.move_id.bom_line_id and l.move_id.bom_line_id.bom_id.product_tmpl_id.display_name == l.move_id.name)"/>
|
|
</xpath>
|
|
<xpath expr="//t[@name='no_package_section']" position="before">
|
|
<t t-set="has_kits" t-value="move_lines.filtered(lambda l: l.move_id.bom_line_id and l.move_id.bom_line_id.bom_id.product_tmpl_id.display_name == l.move_id.name)"/>
|
|
<t t-if="has_kits">
|
|
<!-- print the products not in a package or kit first -->
|
|
<t t-set="move_lines" t-value="move_lines.filtered(lambda m: not m.move_id.bom_line_id)"/>
|
|
</t>
|
|
</xpath>
|
|
<xpath expr="//t[@name='no_package_move_lines']" position="inside">
|
|
<t t-call="mrp.stock_report_delivery_kit_sections"/>
|
|
</xpath>
|
|
<xpath expr="//t[@name='has_packages']" position="after">
|
|
<!-- Additional use case: group by kits when no packages exist and then apply use case 1. (serial/lot numbers used/printed) -->
|
|
<t t-elif="has_kits and not has_packages">
|
|
<t t-call="mrp.stock_report_delivery_kit_sections"/>
|
|
<t t-call="mrp.stock_report_delivery_no_kit_section"/>
|
|
</t>
|
|
</xpath>
|
|
</template>
|
|
|
|
<template id="stock_report_delivery_kit_sections">
|
|
<!-- do another map to get unique top level kits -->
|
|
<t t-set="kits" t-value="has_kits.mapped('move_id.bom_line_id.bom_id.product_tmpl_id')"/>
|
|
<t t-foreach="kits" t-as="kit">
|
|
<tr t-att-class="'bg-200 font-weight-bold o_line_section'">
|
|
<td colspan="99">
|
|
<span t-esc="kit.display_name"/>
|
|
</td>
|
|
</tr>
|
|
<t t-set="kit_move_lines" t-value="has_kits.filtered(lambda l: l.move_id.name == kit.display_name)"/>
|
|
<t t-if="has_serial_number">
|
|
<tr t-foreach="kit_move_lines" t-as="move_line">
|
|
<t t-set="description" t-as="move_line.move_id.description_picking"/>
|
|
<t t-if="description == kit.name">
|
|
<t t-set="description" t-value=""/>
|
|
</t>
|
|
<t t-call="stock.stock_report_delivery_has_serial_move_line"/>
|
|
</tr>
|
|
</t>
|
|
<t t-else="">
|
|
<!-- move line description by default is the product_template.name (kit name), instead of display_name-->
|
|
<t t-set="aggregated_lines" t-value="kit_move_lines._get_aggregated_product_quantities(kit_name=kit.name)"/>
|
|
<t t-if="aggregated_lines">
|
|
<t t-call="stock.stock_report_delivery_aggregated_move_lines"/>
|
|
</t>
|
|
</t>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- No kit section is expected to only be called in no packages case -->
|
|
<template id="stock_report_delivery_no_kit_section">
|
|
<!-- Do another section for kit-less products if they exist -->
|
|
<t t-set="no_kit_move_lines" t-value="o.move_line_ids.filtered(lambda l: not l.move_id.bom_line_id)"/>
|
|
<t t-if="no_kit_move_lines">
|
|
<tr t-att-class="'bg-200 font-weight-bold o_line_section'">
|
|
<td colspan="99">
|
|
<span>Products not associated with a kit</span>
|
|
</td>
|
|
</tr>
|
|
<t t-if="has_serial_number">
|
|
<tr t-foreach="no_kit_move_lines" t-as="move_line">
|
|
<t t-call="stock.stock_report_delivery_has_serial_move_line"/>
|
|
</tr>
|
|
</t>
|
|
<t t-else="">
|
|
<t t-set="aggregated_lines" t-value="no_kit_move_lines._get_aggregated_product_quantities()"/>
|
|
<t t-if="aggregated_lines">
|
|
<t t-call="stock.stock_report_delivery_aggregated_move_lines"/>
|
|
</t>
|
|
</t>
|
|
</t>
|
|
</template>
|
|
</odoo>
|