This question has been flagged

hello

i inherit product.template model and add new field (foreign_currency).

next i inherit Bom & Structure report and add 2 column as cost(USD) and Bom(USD).

cost(USD) is USD cost of product. it can be 0.00

Bom(USD) is multiplication of quantity and cost(USD).

now i want to fill cost(USD) and Bom(USD) columns per each product and calculate sum of BoM(USD) in footer of report.


my model.py

from odoo import models, fields
classForeignCurrency(models.Model):_inherit = 'product.template'
foreign_currency = fields.Float(string="foreign currency(USD)")


my inhert xml file is :

<odoo>

<data>

    <template id="bom_report_inherit" inherit_id="mrp.report_mrp_bom">

        <xpath expr="//tr/th[6]"position="after">

            <th class="o_mrp_prod_cost text-right">Cost (USD)th>

            <th class="o_mrp_prod_cost text-right">Bom Cost (USD)th>

        xpath>

    template>

data>

<data>

    <template id="bom_report_total_price_inherit"inherit_id="mrp.report_mrp_bom">

        <xpath expr="//tfoot/tr/td[6]"position="after">

            <td class=" text-right"><span>total cost(USD) of Bomspan>td>

            <td class=" text-right"><span>total cost(USD) of Bomspan>td>

        xpath>

    template>

data>


<data>

    <template id="bom_report_main_product_inherit" inherit_id="mrp.report_mrp_bom">

        <xpath expr="//tbody/tr/td[6]" position="after">

            <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_bom_cost text-right">

                <span t-field="o.foreign_currency"/>

            td>

            <td t-if="data['report_structure'] != 'bom_structure'" class="o_mrp_bom_cost text-right">

                <span t-field="o.foreign_currency"/>

            td>

        xpath>

    template>

data>


<data>

    <template id="bom_report_price_inherit" inherit_id="mrp.report_mrp_bom_line">

        <xpath expr="//tr/td[6]" position="after">

            <td class="o_mrp_prod_cost text-right">

                <span>cost(USD) of each productspan>

            td>

            <td class="o_mrp_prod_cost text-right">

                <span>multiplication of quantity and cost(USD).span>

            td>

        xpath>

    template>

data>

odoo>


with this xml file i get this error:

Traceback (most recent call last):
  File "/opt/odoo15/odoo/odoo/http.py", line 644, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo15/odoo/odoo/http.py", line 302, in _handle_exception
    raise exception.with_traceback(None) from new_cause
odoo.addons.base.models.qweb.QWebException: 'o'
Traceback (most recent call last):
  File "/opt/odoo15/odoo/odoo/addons/base/models/qweb.py", line 219, in render_template
    yield from compiled_fn(self, values, log)
  File "", line 167, in template_1135
KeyError: 'o'

Error when render the template
KeyError: 'o'
Template: 1135
Path: /t/div/t[1]/div[2]/div/div/table/tbody/tr/td[7]/span
Node: 
Avatar
Discard