Help

Odoo module not working on the new system

Closed
Avatar
Raitis

The question has been closed for reason: not enough information given to provide help

by
Ermin Trevisan
on 05/24/2020 10:37:45

I have copied my module to a new odoo system(Because I got a system crash on previous) and now it won't work. It is showing that, gifpath field does not exist.


Templates.xml

<odoo>

    <data>
    <record id="product_product_inherit" model="ir.ui.view">
                <field name="name">product.template.inherit</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_only_form_view"/>
        <field name="arch" type="xml">
            <field name="default_code" position="after">
                <field name="gifpath" widget="image"/>
            </field>
        </field>
              </record>

       <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">
     
        <t t-if="trigger == 1">
                      <span t-field="product.image_1920"
                                t-options="{'widget': 'image', 'preview_image': 'gifpath'}"
                                class="d-flex h-100 justify-content-center align-items-center"/>
        </t>
          
        <t t-elif="trigger == 0">
            <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"/>

        </t>
          </xpath>

       </template>

    </data>

</odoo>

models.py


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

from odoo import models, fields, api


class imgtogif_r(models.Model):
    _inherit = ['product.product','product.template']
    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

1 Comment
Avatar
Discard
Avatar
Ermin Trevisan
-

Please provide your log entries.

2 Answers
0
Best Answer

Have you changed this one

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

  to

class imgtogif_r(models.Model):
    _inherit = ['product.product','product.template']
    gifpath = fields.Char('gifpath')

Avatar
Discard
0
Avatar
Niyas Raphy
Best Answer

Hi,

In the XML it seems you have used gifpath and in the python class you have defined the field as field_gifpath , so just change the name to gifpath instead of field_gifpath from python file and see.

    gifpath = fields.Char('gifpath')

Thanks

1 Comment
Avatar
Discard
Avatar
Raitis
-

Thank you for the answer, but issue remains the same. I have changed field_gifpath to gifpath in python file, but error remains.