report_deliveryslip.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <odoo>
  3. <template id="stock_report_delivery_document_inherit_mrp" inherit_id="stock.report_delivery_document">
  4. <!-- needs to be set before so elif directly follows if later on -->
  5. <xpath expr="//t[@name='has_packages']" position="before">
  6. <!-- get only the top level kits' (i.e. no subkit) move lines for easier mapping later on + we ignore subkit groupings-->
  7. <!-- note that move.name uses top level kit's product.template.display_name value instead of product.template.name -->
  8. <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.type == 'phantom')"/>
  9. </xpath>
  10. <xpath expr="//t[@name='no_package_section']" position="before">
  11. <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.type == 'phantom')"/>
  12. <t t-if="has_kits">
  13. <!-- print the products not in a package or kit first -->
  14. <t t-set="move_lines" t-value="move_lines.filtered(lambda m: not m.move_id.bom_line_id)"/>
  15. </t>
  16. </xpath>
  17. <xpath expr="//t[@name='no_package_move_lines']" position="inside">
  18. <t t-call="mrp.stock_report_delivery_kit_sections"/>
  19. </xpath>
  20. <xpath expr="//t[@name='has_packages']" position="after">
  21. <!-- Additional use case: group by kits when no packages exist and then apply use case 1. (serial/lot numbers used/printed) -->
  22. <t t-elif="has_kits and not has_packages">
  23. <t t-call="mrp.stock_report_delivery_kit_sections"/>
  24. <t t-call="mrp.stock_report_delivery_no_kit_section"/>
  25. </t>
  26. </xpath>
  27. </template>
  28. <template id="stock_report_delivery_kit_sections">
  29. <!-- get all kits-related SML, including subkits and excluding the packaged SML -->
  30. <t t-set="all_kits_move_lines" t-value="o.move_line_ids.filtered(lambda l: l.move_id.bom_line_id.bom_id.type == 'phantom' and not l.result_package_id)"/>
  31. <!-- do another map to get unique top level kits -->
  32. <t t-set="boms" t-value="has_kits.mapped('move_id.bom_line_id.bom_id')"/>
  33. <t t-foreach="boms" t-as="bom">
  34. <!-- Separate product.product from template for variants-->
  35. <t t-if="bom.product_id">
  36. <t t-set="kit_product" t-value="bom.product_id"/>
  37. </t>
  38. <t t-else="">
  39. <t t-set="kit_product" t-value="bom.product_tmpl_id"/>
  40. </t>
  41. <tr t-att-class="'bg-200 fw-bold o_line_section'">
  42. <td colspan="99">
  43. <span t-esc="kit_product.display_name"/>
  44. </td>
  45. </tr>
  46. <t t-set="kit_move_lines" t-value="all_kits_move_lines.filtered(lambda l: l.move_id.bom_line_id.bom_id == bom)"/>
  47. <t t-if="has_serial_number">
  48. <tr t-foreach="kit_move_lines" t-as="move_line">
  49. <t t-set="description" t-value="move_line.move_id.description_picking"/>
  50. <t t-if="description == kit_product.display_name">
  51. <t t-set="description" t-value=""/>
  52. </t>
  53. <t t-call="stock.stock_report_delivery_has_serial_move_line"/>
  54. </tr>
  55. </t>
  56. <t t-else="">
  57. <t t-set="aggregated_lines" t-value="kit_move_lines._get_aggregated_product_quantities(kit_name=kit_product.display_name)"/>
  58. <t t-if="aggregated_lines">
  59. <t t-call="stock.stock_report_delivery_aggregated_move_lines"/>
  60. </t>
  61. </t>
  62. </t>
  63. </template>
  64. <!-- No kit section is expected to only be called in no packages case -->
  65. <template id="stock_report_delivery_no_kit_section">
  66. <!-- Do another section for kit-less products if they exist -->
  67. <t t-set="no_kit_move_lines" t-value="o.move_line_ids.filtered(lambda l: not l.move_id.bom_line_id)"/>
  68. <t t-if="no_kit_move_lines">
  69. <tr t-att-class="'bg-200 fw-bold o_line_section'">
  70. <td colspan="99">
  71. <span>Products not associated with a kit</span>
  72. </td>
  73. </tr>
  74. <t t-if="has_serial_number">
  75. <tr t-foreach="no_kit_move_lines" t-as="move_line">
  76. <t t-call="stock.stock_report_delivery_has_serial_move_line"/>
  77. </tr>
  78. </t>
  79. <t t-else="">
  80. <t t-set="aggregated_lines" t-value="no_kit_move_lines._get_aggregated_product_quantities()"/>
  81. <t t-if="aggregated_lines">
  82. <t t-call="stock.stock_report_delivery_aggregated_move_lines"/>
  83. </t>
  84. </t>
  85. </t>
  86. </template>
  87. </odoo>