Skip to Content
Menu
This question has been flagged
2 Replies
2455 Views

Hi 

I keep getting this error

what am i doing wrong?????!??!!?!

Field `drawing` does not exist

Error context:
View `product.product.form.inherit`
[view_id: 853, xml_id: n/a, model: product.product, parent_id: 388]
None" while parsing file:/c:/program files (x86)/odoo 12.0/server/odoo/addons/product_inherit/views/product_inherit.xml:3, near
<record id="view_product_form_inherit" model="ir.ui.view">
			<field name="name">product.product.form.inherit</field>
			<field name="model">product.product</field>
			<field name="inherit_id" ref="product.product_normal_form_view"/>
			<field name="arch" type="xml">
				<xpath expr="//field[@name='default_code']" position="after">
					<field name="drawing"/>
				</xpath>
			</field>
		</record>


here is my code

Model

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

from odoo import models, fields, api

class product_product(models.Model):
_name = "product.product"
_description = "Product"
_inherit = 'product.product'
_columns = {
'drawing' : fields.binary('Drawing'),
'date_modify' : fields.datetime('Date Modified')
}

product_product()



xml file


<odoo>
<data>
<record
id="view_product_form_inherit" model="ir.ui.view">
<field
name="name">product.product.form.inherit</field>
<field
name="model">product.product</field>
<field
name="inherit_id" ref="product.product_normal_form_view"/>
<field
name="arch" type="xml">
<xpath
expr="//field[@name='default_code']" position="after">
<field
name="drawing"/>
</xpath>
</field>
</record>
</data>
</odoo>
    
Avatar
Discard
Best Answer

Hello Justin,

Instead of adding new fields to  product table, try to add product template table.

If you product template table automatically same field will create in product table.

So inherit product template form view and your fields.
 
from odoo import models, fields, api

class ProductTemplate(models.Model):
    _inherit = 'product.template'
    
    drawing = fields.Binary('Drawing')
    date_modify = fields.Datetime('Date Modified')

Avatar
Discard
Best Answer

Try it bro!

# -*- coding: utf-8 -*-
from odoo import models, fields, api

class product_product(models.Model):
    _description = "Product"
    _inherit = 'product.product'
   
    drawing = fields.Binary('Drawing')
    date_modify = fields.Datetime('Date Modified')

Avatar
Discard
Related Posts Replies Views Activity
1
May 21
4620
1
Mar 18
6776
3
Mar 24
4958
0
Mar 24
207
2
Jan 24
15982