Skip to Content
Menu
This question has been flagged
4935 Views

I want to create a new field inside a existing model(product.product) to store there a path for a GIF image. However, field is not being added, and method is not being called. I have checked the fields inside a technical settings and in product.product model itself. Field 'gifpath' is nowhere to be found.

When I try to access that field by xml, new  html tag is created with my record, and field inside it.

New html code:

<record id="image_1024" model="product.product" data-oe-id="1330" data-oe-xpath="/data/xpath/record" data-oe-model="ir.ui.view" data-oe-field="arch">
		<field name="image_1024">gifpath()</field>
	      </record>

Python code(models.py)

# -*- coding: utf-8 -*-

from odoo import models, fields, api


class imgtogif_r(models.Model):
    _inherit = 'product.product'
    field_gifpath = fields.Char('gifpath')

    @api.one
    def gifpath(self,productid):
        selected_prod = self.env['product.product'].search[(`id`, `=`, productid)]
        if selected_prod != None:
            return selected_prod.gifpath

templates.xml code:

<odoo>

    <data>

       <template id="website_sales_inh" name="webiste_sales_inherit" inherit_id="website_sale.products_item">

          <xpath expr="//span[@class='d-flex h-100 justify-content-center align-items-center']" position="replace">
              <record id="image_1024" model="product.product">
        <field name="image_1024">gifpath()</field>
          </record>
              <span t-field="product.image_1920"
                        t-options="{'widget': 'image', 'preview_image': 'image_1024' if product_image_big else 'image_256'}"
                        class="d-flex h-100 justify-content-center align-items-center"/>
          </xpath>

       </template>

    </data>

</odoo>


Avatar
Discard
Related Posts Replies Views Activity
1
Jun 16
10027
1
Dec 16
2100
1
Sep 15
3671
0
Mar 15
2507
3
Sep 24
9997