Odoo Help

Welcome!

This community 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.

0

Error On Saving : ProgrammingError: can't adapt type 'dict'

By
MoayadRayyan
on 11/17/14, 5:54 AM 4,089 views

Greetingz,

after i have added many2one field , once i tried to save i got this error : ProgrammingError: can't adapt type 'dict'

File "/opt/odoo/odoo-server/openerp/sql_db.py", line 158, in wrapper return f(self, *args, **kwargs) File "/opt/odoo/odoo-server/openerp/sql_db.py", line 234, in execute res = self._obj.execute(query, params) ProgrammingError: can't adapt type 'dict'

check my code bellow :

PYTHON FILE

from openerp.osv import fields, osv

class product_rolls(osv.osv):
      _name = 'product.template'
      _inherit = "product.template"

      _columns = {
        'product_rolls_id': fields.char('Product Pices'),
    'product_rolls_rolls':fields.many2one('new.roll','roll_id'),
      }

      _defaults ={
        'product_rolls_id': 10
      }
product_rolls()


class new_roll(osv.osv):
   _name='new.roll'
   _columns={
       'roll_id':fields.integer("ID"),
           'roll':fields.char('Roll'),
           'size':fields.char("Size"),
           }
new_roll()

XML FILE :

<?xml version="1.0" encoding="utf-8"?>
    <openerp>
    <data>
    <record model="ir.ui.view" id="product_rolls_product_product">
        <field name="name">product.template.stock.property.form.inherit</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="stock.view_template_property_form" />
        <field name="arch" type="xml">
        <xpath expr="//field[@name='qty_available']" position="after">
        <newline/>
        <label for="product_rolls_id" />
            
            <field name="product_rolls_id" on_change="onchange_product_rolls_id(product_rolls_id)" />
            <field name="product_rolls_rolls" widget="one2many_list" colspan="4" nolabel="1">
                <tree editable='bottom'>
                <field name="roll"/>  
                <field name="size"/>                           
                </tree>
                <form>
                <field name="roll"/>
                <field name="size"/>
                </form>
            </field>
        </xpath>
        </field>
    </record>
        </data>
    </openerp>

note : before adding the many2one tree it was working perfectly .

 

Regards

@moayad your field 'product_rolls_rolls' is a 'many2one' field and in 'xml' file you are trying to treat it as one2many field. I am not getting it why? This kind of widgets are used one2many fields not for many2one field. Also another thing, although this thing is not affecting your code but I can see is that you are trying to add "ID" field in the "new_roll" table, because Openerp automatically adds ID field in the table.

Emipro Technologies Pvt. Ltd.
on 11/17/14, 6:18 AM

Ok , i make it one2many and i removed ID field , now there is no errors but no value saved ! Regrads

MoayadRayyan
on 11/17/14, 6:48 AM

@moayad if possible please share your code with latest changes that you have made, which will give better idea to solve the issue.

Emipro Technologies Pvt. Ltd.
on 11/17/14, 7:16 AM
0
sameer alhwety
On 11/19/14, 9:43 AM

Try this :

class product_rolls(osv.osv):
      _name = 'product.rolls'
      _inherit = "product.template"

      _columns = {
        'product_rolls': fields.char('Product Pices'),
    'product_rolls_id':fields.many2one('new.roll','Product Roll'),
      }

      _defaults ={
        'product_rolls': 10
      }
product_rolls()


class new_roll(osv.osv):
   _name='new.roll'
   _columns={
       'roll_id':fields.one2many('product.rolls','product_rolls_id','Column Name'),
           'roll':fields.char('Roll'),
           'size':fields.char("Size"),
           }
new_roll()

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 11/17/14, 5:54 AM
Seen: 4089 times
Last updated: 2/23/16, 2:33 AM