This question has been flagged
2 Replies
3613 Views

I'm trying to edit the RML report of the Delivery Order ( /addons/delivery/report/shipping.rml) so that it displays not only the finished products, but also the detailed list of the products that were consumed in the Manufacturing Order and their associated serial numbers.

I understand that in order to do so, I need to access the consumed products list (mrp_production.move_lines2) of the Manufacturing Order associated to the Delivery Order. And I thought I could do that by doing the following : 

- One loop to iterate on the move lines of the Delivery Order : [[repeatIn(o.move_lines, 'do_line')]]

- Another loop to iterate on the consumed products list : [[repeatIn(do_line.production_id.move_lines2, 'mo_lines')]]

However, it seems like the production_id field associated to my stock_move (do_line) is empty. When I try to print on the report [[do_line.sale_line_id]], it prints "browse_record(sale.order.line, 1)", which makes sense. When I try to print on the report [[do_line.production_id]] it doesn't print anything.

When I check the online documentation (http://useopenerp.com/v8/model/stock-move#columns-product_id), it tells me that the production_id field is a "column extended with add-on mrp > stock.py > class StockMove". I however do believe that I have the mrp module installed, since I can manage my Manufacturing Orders and since I can find the file /addons/mrp/stock.py.

 

Can someone please help me with this matter? I'd be forever grateful :-)

Avatar
Discard
Best Answer

You need to iterate again the object..

<para style="P10">[[ repeatIn(objects,'o') ]]</para>

parent table

<tr>
        <td>
          <para style="P5">[[ o.name ]]</para>
        </td>

</tr>

child table

<tr>
          <para style="P10">[[ repeatIn(o.do_line,'line') ]]</para>
        <td>
          <para style="P5">[[ line.production_id ]]</para>
        </td>

</tr>

Avatar
Discard
Author Best Answer

Thanks for your reply Abegail.

I thought this is what I had done. Let me paste my code here:

 

    <para style="terp_default_9">[[repeatIn(objects,'o')]]</para>

    [......]

    <section>
      <para style="terp_default_1">[[repeatIn(o.move_lines,'do_line')]]</para>
      <blockTable colWidths="83.0,370.0,85.0" style="Table4">
        <tr>
          <td>
            <para style="terp_default_9">[[formatLang(do_line.product_qty)]]</para>
          </td>
          <td>
            <para style="terp_default_9">[[do_line.product_id and do_line.product_id.name or '']]</para>
          </td>
          <td>
            <para style="terp_default_Right_9">[[(do_line.prodlot_id and (do_line.prodlot_id.name + (do_line.prodlot_id.ref and ('/' + do_line.prodlot_id.ref) or ''))) or '']]</para>
          </td>
        </tr>
        <tr>
          <td></td>
          <td>including:</td>
          <td></td>
        </tr>
      </blockTable>
      <section>
        <para style="terp_default_1">[[repeatIn(do_line.production_id.move_lines2, 'mo_line')]]</para>
        <blockTable colWidths="83.0,370.0,85.0" style="Table4">
          <tr>
            <td>
              <para style="terp_default_9">[[formatLang(mo_line.product_qty)]]</para>
            </td>
              <td>
              <para style="terp_default_9">[[mo_line.product_id and do_line.product_id.name or '']]</para>
            </td>
            <td>
              <para style="terp_default_9">[[(mo_line.prodlot_id and (mo_line.prodlot_id.name + (mo_line.prodlot_id.ref and ('/' + mo_line.prodlot_id.ref) or ''))) or '']]</para>
            </td>
          </tr>
        </blockTable>
      </section>
      <para style="terp_default_1">
        <font color="white"> </font>
      </para>
    </section>

But the problem is that [[repeatIn(do_line.production_id.move_lines2, 'mo_line')]] yields the error "Cannot iterate on NoneType object" and that when I try to do [[do_line.production_id]], the result is empty.

Thanks again for your help!

Avatar
Discard