1

I am using Odoo 12. I don't have access to Odoo's Python part, only the Odoo developer mode. I installed the web_one2many_kanban module but apart from the images and the id of the lines of my one2many, I can not display the rest of the data.

My code:

<t t-name="kanban-box">
  <div t-attf-class="oe_kanban_card  {{ record.x_bom_line_ids.raw_value }}">
    <t t-if="record.x_bom_line_ids.raw_value">
      <div class="row">
        <div class="col-8">
          <strong>
            <span>
              <t t-esc="record.product_id.value"/>
            </span>
          </strong>
        </div>
        <div class="col-4">
          <strong>
            <span class="float-right text-right">
              <t t-esc="record.x_virtual_available.value"/>
            </span>
          </strong>
        </div>
      </div>
    </t>
  </div>
</t>

<t t-foreach="record.x_bom_line_ids.raw_value" t-as="room">
  <img t-att-src="kanban_image('mrp.bom.line', 'x_image', room)" t-att-data-member_id="room" />

My error:

"Uncaught TypeError: Cannot read property 'value' of undefined"
Nino Filiu
  • 16,660
  • 11
  • 54
  • 84

2 Answers2

2

You forgot to mention the model of the record you are writing this template for. From your code it is apparent that you are trying to display value field for two relational field, one is product_id, another one is x_virtual_available. The given error message is appearing because, either one of the related field of your record is unset, hence the value being False/empty for python, and undefined for javascript. And as you are trying to access value field of that related field, you are getting this error. To solve this error, have a close look to your record and check for those fields value.

<t t-name="kanban-box">
  <div t-attf-class="oe_kanban_card  {{ record.x_bom_line_ids.raw_value }}">
    <t t-if="record.x_bom_line_ids.raw_value">
      <div class="row">
        <div class="col-8">
          <strong>
            <span>
              <t t-esc="record.product_id.name"/>
            </span>
          </strong>
        </div>
        <div class="col-4">
          <strong>
            <span class="float-right text-right">
              <t t-esc="record.x_virtual_available"/>
            </span>
          </strong>
        </div>
      </div>
    </t>
  </div>
</t>

<t t-foreach="record.x_bom_line_ids.raw_value" t-as="room">
  <img t-att-src="kanban_image('mrp.bom.line', 'x_image', room)" t-att-data-member_id="room" />
arryph
  • 2,725
  • 10
  • 15
  • sorry, but I do not understand your answer. I added an x_virtual_available field in the model: mrp.bom.line and the product_id field is there. – isabelle collin milliet Mar 13 '19 at 15:56
  • the x_virtual_available field is of floating type and is linked product_id.virtual_available and product_id is a many2one related to product.product – isabelle collin milliet Mar 13 '19 at 15:59
  • You are trying to get `value` attribute of a `float` field?? – arryph Mar 13 '19 at 16:01
  • 1
    The problem is, suppose you are trying to load the template for `mrp.bom.line` record with id `10`, that record with id 10 has one of this field `x_virtual_available` or `product_id ` not set, so the value is undefined. Moreover, no float field or `product.product` record has this attribute `value`. That's why you are getting this error. – arryph Mar 13 '19 at 16:09
  • @arryph maybe better formatted code would help to read it ;-) – CZoellner Mar 13 '19 at 16:52
  • 1
    @isabellecollinmilliet i think arryph has it correct and `product_id` is missing ('cause floats are filled with 0.0 as default). In a original Odoo kanban view (lead) you can see that Odoo is checking if `value` is set before using it: ` ` – CZoellner Mar 13 '19 at 16:56
  • @CZoellner hehe yeah my bad, I copied the code from question but somehow indentation got removed. fixed now. – arryph Mar 13 '19 at 18:13
0

sorry I understood the mistake I was focusing on a field many2many instead of one2many! the problem solved but now I try to do the same thing with another field one2many and it does not work the first part works but not the second why?

 <p>
               <t t-foreach="record.x_bomlineids.raw_value"  t-as="r">
                <span style="color:blue !important;">
                <strong> <t t-esc="r.x_name" t-att-data-list_id="r"/></strong></span>
                 <span style="color:grey !important;"> Démixé libre: </span><strong> 
 <t t-esc="r.x_virtual_available" /> </strong><t t-esc="r.x_unite"/>   <br/>


                 </t>
                    </p>
                 <p>
                        <t t-foreach="record.bom_line_ids.raw_value"  t-as="l">
                <span style="color:blue !important;">
                <strong> <t t-esc="l.product_tmpl_id" t-att-data-list_id="l"/> 
 </strong></span>
                <span style="color:grey !important;"> stock coli mixte: </span> 
 <strong><t t-esc="l.x_virtual_available" /> </strong><t t-esc="l.x_unite"/>   <br/>
                       </t>
            </p>