Odoo Help


I have added a extra product type in the product.template as Packing Materials but when I slect and enter some values it gives this arror as ----Odoo Warning - Validation Error The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it - creation/update: a mandatory field is not correctly set [object with reference: product.specification.line - product.specification.line] ?

Karan Gupta
on 7/11/16, 9:35 AM 893 views

The following Code is :---

class prakrutiTemplate(models.Model):

 _inherit = 'product.template'

pm_name = fields.One2many('packing.material.line','name',string= 'PName', store=True)

ps_name = fields.One2many('product.specification.line','name',string= 'PSName', store=True)

def _get_product_template_type(self, cr, uid, context=None):

res = super(prakrutiTemplate, self)._get_product_template_type(cr, uid, context=context)

if 'packing' not in [item[0] for item in res]:

res.append(('packing', _('Packing Materials')))

return res

class packingMaterialline(models.Model):

_name= 'packing.material.line'

name = fields.Many2one('packing.material.line', string= 'Package name')

pname = fields.Many2one('packing.material',string='Name')

desc = fields.Char(related='pname.desc',string='Package Description')

class productSpecificationline(models.Model):

_name = 'product.specification.line'

name = fields.Many2one('product.specification.line',string= 'Name')

pname = fields.Many2one('product.specification', string= 'Name')

parameter = fields.Char(related='pname.desc',string='Product Specification')

class packingMaterial(models.Model):

_name= 'packing.material'

name = fields.Char(string= 'Package name')

desc = fields.Char('Package Description')

class productSpecification(models.Model):

_name= 'product.specification'

name = fields.Char(string= 'Product name')

desc = fields.Char('Specification')

Please use short and concise titles and place your message in the message body. This is very annoying.

Ermin Trevisan
on 7/11/16, 9:41 AM
On 7/12/16, 1:04 AM

class productSpecificationline(models.Model):

_name = 'product.specification.line'

name = fields.Many2one('product.specification.line',string= 'Name')

Wrong relation in your many2one field that is error. ( product.specification.line)

class openerp.fields.Many2one(comodel_name=Nonestring=None**kwargs)

Bases: openerp.fields._Relational

The value of such a field is a recordset of size 0 (no record) or 1 (a single record).


  • comodel_name -- name of the target model (string)

  • domain -- an optional domain to set on candidate values on the client side (domain or string)

  • context -- an optional context to use on the client side when handling that field (dictionary)

  • ondelete -- what to do when the referred record is deleted; possible values are: 'set null','restrict''cascade'

  • auto_join -- whether JOINs are generated upon search through that field (boolean, by defaultFalse)

  • delegate -- set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

 The attribute comodel_name is mandatory except in the case of related fields or field extensions.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/11/16, 9:35 AM
Seen: 893 times
Last updated: 7/12/16, 1:04 AM