summaryrefslogtreecommitdiff
path: root/addons/mrp/report/mrp_report_bom_structure.xml
blob: 2896392430f0b21353c75da2b2c2fcf2bfa69dd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <template id="report_mrp_bom">
        <div class="container o_mrp_bom_report_page">
            <t t-if="data.get('components') or data.get('lines')">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 style="display:inline;">BoM Structure </h1>
                        <h1 style="display:inline;" t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_prod_cost">&amp; Cost</h1>
                        <h3>
                            <a href="#" t-if="data['report_type'] == 'html'" t-att-data-res-id="data['product'].id" t-att-data-model="data['product']._name" class="o_mrp_bom_action">
                                <t t-esc="data['bom_prod_name']"/>
                            </a>
                            <t t-else="" t-esc="data['bom_prod_name']"/>
                        </h3>
                        <h6 t-if="data['bom'].code">Reference: <t t-esc="data['bom'].code"/></h6>
                    </div>
                </div>
                <t t-set="currency" t-value="data['currency']"/>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="mt16">
                            <table width="100%" class="o_mrp_bom_expandable">
                                <thead>
                                    <tr>
                                        <th>Product</th>
                                        <th name="th_mrp_bom_h">BoM</th>
                                        <th class="text-right">Quantity</th>
                                        <th class="text-left" groups="uom.group_uom">Unit of Measure</th>
                                        <th t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_prod_cost text-right" title="This is the cost defined on the product.">Product Cost</th>
                                        <th t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_bom_cost text-right" title="This is the cost based on the BoM of the product. It is computed by summing the costs of the components and operations needed to build the product.">BoM Cost</th>
                                        <th t-if="data['report_type'] == 'html' and data['has_attachments']" class="o_mrp_has_attachments" title="Files attached to the product">Attachments</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>
                                            <span><a href="#" t-if="data['report_type'] == 'html'" t-att-data-res-id="data['product'].id" t-att-data-model="'product.product'" class="o_mrp_bom_action"><t t-esc="data['bom_prod_name']"/></a><t t-else="" t-esc="data['bom_prod_name']"/></span>
                                        </td>
                                        <td name="td_mrp_bom">
                                            <div><a href="#" t-if="data['report_type'] == 'html'" t-att-data-res-id="data['bom'].id" t-att-data-model="'mrp.bom'" class="o_mrp_bom_action"><t t-esc="data['code']"/></a><t t-else="" t-esc="data['code']"/></div>
                                        </td>
                                        <td class="text-right"><span><t t-esc="data['bom_qty']" t-options='{"widget": "float", "decimal_precision": "Product Unit of Measure"}'/></span></td>
                                        <td groups="uom.group_uom"><span><t t-esc="data['bom'].product_uom_id.name"/></span></td>
                                        <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_prod_cost text-right">
                                            <span><t t-esc="data['price']" t-options='{"widget": "monetary", "display_currency": currency}'/></span>
                                        </td>
                                        <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_bom_cost text-right">
                                            <span><t t-esc="data['total']" t-options='{"widget": "monetary", "display_currency": currency}'/></span>
                                        </td>
                                        <td t-if="data['report_type'] == 'html'">
                                            <span>
                                                <t t-if="data['attachments']">
                                                    <a href="#" role="button" t-att-data-res-id="data['attachments'].ids" t-att-data-model="'mrp.document'" class="o_mrp_show_attachment_action fa fa-fw o_button_icon fa-files-o"/>
                                                </t>
                                            </span>
                                        </td>
                                    </tr>
                                    <t t-if="data['report_type'] == 'html'" t-call="mrp.report_mrp_bom_line"/>
                                    <t t-if="data['report_type'] == 'pdf'" t-call="mrp.report_mrp_bom_pdf_line"/>
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <td></td>
                                        <td name="td_mrp_bom_f"></td>
                                        <td t-if="data['report_structure'] != 'bom_structure'" class="text-right o_mrp_prod_cost"><span><strong>Unit Cost</strong></span></td>
                                        <td groups="uom.group_uom"></td>
                                        <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_prod_cost text-right">
                                            <span><t t-esc="data['price']/data['bom_qty']" t-options='{"widget": "monetary", "display_currency": currency}'/></span>
                                        </td>
                                        <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_bom_cost text-right">
                                            <span><t t-esc="data['total']/data['bom_qty']" t-options='{"widget": "monetary", "display_currency": currency}'/></span>
                                        </td>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </t>
            <t t-else="">
                <h1 class="text-center">No data available.</h1>
            </t>
        </div>
    </template>

    <template id="report_mrp_bom_line">
        <t t-set="currency" t-value="data['currency']"/>
        <t t-foreach="data['components']" t-as="l">
            <t t-set="space_td" t-value="'margin-left: '+ str(l['level'] * 20) + 'px;'"/>
            <tr class="o_mrp_bom_report_line" t-att-data-id="l['child_bom']" t-att-parent_id="l['parent_id']" t-att-data-line="l['line_id']" t-att-data-product_id="l['prod_id']" t-att-data-qty="l['prod_qty']" t-att-data-level="l['level']">
                <td>
                    <div t-att-style="space_td">
                        <t t-if="l['child_bom']">
                            <div t-att-data-function="'get_bom'" class="o_mrp_bom_unfoldable fa fa-fw fa-caret-right" style="display:inline-block;" role="img" aria-label="Unfold" title="Unfold"/>
                        </t>
                        <div t-att-class="None if l['child_bom'] else 'o_mrp_bom_no_fold'" style="display:inline-block;">
                            <a href="#" t-att-data-res-id="l['prod_id']" t-att-data-model="'product.product'" class="o_mrp_bom_action"><t t-esc="l['prod_name']"/></a>
                        </div>
                        <t t-if="l['phantom_bom']">
                            <div class="fa fa-dropbox" title="This is a BoM of type Kit!" role="img" aria-label="This is a BoM of type Kit!"/>
                        </t>
                    </div>
                </td>
                <td name="td_mrp_bom">
                    <div>
                        <a href="#" t-att-data-res-id="l['child_bom']" t-att-data-model="'mrp.bom'" class="o_mrp_bom_action"><t t-esc="l['code']"/></a>
                  </div>
                </td>
                <td class="text-right"><span><t t-esc="l['prod_qty']" t-options='{"widget": "float", "decimal_precision": "Product Unit of Measure"}'/></span></td>
                <td groups="uom.group_uom"><span><t t-esc="l['prod_uom']"/></span></td>
                <td class="o_mrp_prod_cost text-right">
                    <span t-esc="l['prod_cost']" t-options='{"widget": "monetary", "display_currency": currency}'/>
                </td>
                <td class="o_mrp_bom_cost text-right">
                    <span t-esc="l['total']" t-options='{"widget": "monetary", "display_currency": currency}'/>
                </td>
                <td>
                    <span>
                        <t t-if="l['attachments']">
                            <a href="#" role="button" t-att-data-res-id="l['attachments'].ids" t-att-data-model="'mrp.document'" class="o_mrp_show_attachment_action fa fa-fw o_button_icon fa-files-o"/>
                        </t>
                    </span>
                </td>
            </tr>
        </t>
        <t t-if="data['operations']">
            <t t-set="space_td" t-value="'margin-left: '+ str(data['level'] * 20) + 'px;'"/>
            <tr class="o_mrp_bom_report_line o_mrp_bom_cost" t-att-data-id="'operation-' + str(data['bom'].id)" t-att-data-bom-id="data['bom'].id" t-att-parent_id="data['bom'].id" t-att-data-qty="data['bom_qty']" t-att-data-level="data['level']">
                <td name="td_opr">
                    <span t-att-style="space_td"/>
                    <span class="o_mrp_bom_unfoldable fa fa-fw fa-caret-right" t-att-data-function="'get_operations'" role="img" aria-label="Unfold" title="Unfold"/>
                    Operations
                </td>
                <td/>
                <td class="text-right">
                    <span t-esc="data['operations_time']" t-options='{"widget": "float_time"}'/>
                </td>
                <td groups="uom.group_uom"><span>Minutes</span></td>
                <td class="o_mrp_prod_cost">
                </td>
                <td class="o_mrp_bom_cost text-right">
                    <span t-esc="data['operations_cost']" t-options='{"widget": "monetary", "display_currency": currency}'/>
                </td>
                <td/>
            </tr>
        </t>
    </template>

    <template id="report_mrp_operation_line">
      <t t-set="currency" t-value="data['currency']"/>
      <t t-foreach="data['operations']" t-as="op">
          <t t-set="space_td" t-value="'margin-left: '+ str(op['level'] * 20) + 'px;'"/>
          <tr class="o_mrp_bom_report_line o_mrp_bom_cost" t-att-parent_id="'operation-' + str(data['bom_id'])">
              <td name="td_opr_line">
                  <span t-att-style="space_td"/>
                  <a href="#" t-att-data-res-id="op['operation'].id" t-att-data-model="'mrp.routing.workcenter'" class="o_mrp_bom_action"><t t-esc="op['name']"/></a>
              </td>
              <td/>
              <td class="text-right">
                  <span t-esc="op['duration_expected']" t-options='{"widget": "float_time"}'/>
              </td>
              <td groups="uom.group_uom"><span>Minutes</span></td>
              <td class="o_mrp_prod_cost"></td>
              <td class="o_mrp_bom_cost text-right">
                  <span t-esc="op['total']" t-options='{"widget": "monetary", "display_currency": currency}'/>
              </td>
              <td/>
          </tr>
      </t>
    </template>

    <template id="report_mrp_bom_pdf">
        <t t-call="web.html_container">
            <t t-call="mrp.report_mrp_bom"/>
        </t>
    </template>

    <template id="report_mrp_bom_pdf_line">
      <t t-set="currency" t-value="data['currency']"/>
      <t t-foreach="data['lines']" t-as="l">
          <t t-set="space_td" t-value="'margin-left: '+ str(l['level'] * 20) + 'px;'"/>
          <tr t-if="data['report_structure'] != 'bom_structure' or l['type'] != 'operation'">
              <td>
                  <div t-att-style="space_td">
                    <div><t t-esc="l['name']"/></div>
                  </div>
              </td>
              <td name="td_mrp_code">
                  <div t-if="l.get('code')" t-esc="l['code']" />
              </td>
              <td class="text-right">
                  <span>
                      <t t-if="l['type'] == 'operation'" t-esc="l['quantity']" t-options='{"widget": "float_time"}'/>
                      <t t-if="l['type'] == 'bom'" t-esc="l['quantity']" t-options='{"widget": "float", "decimal_precision": "Product Unit of Measure"}'/>
                  </span>
              </td>
              <td groups="uom.group_uom"><span><t t-esc="l['uom']"/></span></td>
              <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_prod_cost text-right">
                  <span t-if="'prod_cost' in l" t-esc="l['prod_cost']" t-options='{"widget": "monetary", "display_currency": currency}'/>
              </td>
              <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_bom_cost text-right">
                  <span t-esc="l['bom_cost']" t-options='{"widget": "monetary", "display_currency": currency}'/>
              </td>
          </tr>
      </t>
    </template>

    <template id="report_bom_structure">
        <t t-set="data_report_landscape" t-value="True"/>
        <t t-call="web.basic_layout">
            <t t-call-assets="mrp.assets_common" t-js="False"/>
            <t t-foreach="docs" t-as="data">
                <div class="page">
                    <t t-call="mrp.report_mrp_bom"/>
                </div>
                <p style="page-break-before:always;"> </p>
            </t>
        </t>
    </template>
</odoo>