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

Form view is not using field in generated SQL [Closed]

By
Seth Boyd
on 3/15/14, 9:24 PM 1,662 views

The Question has been closed

by
Ray Carnes
on 03/16/2014 13:41:19

I've created a simple extended product model that I'm not trying to use in a form view. The creation view renders properly, but when I try and save the new object I receive an error about not filling out a required field on my model, "name". I did fill this field out, though, so I'm not sure where the problem is coming from.

Here is the pertinent code

My Model:

class product_product(osv.Model):
    _inherit = "product.product"
    _columns = {
        'ismeetingroom':fields.boolean('Is Meeting Room'),
        'ismeetingroomextra': fields.boolean('Is Meeting Room Amenity'),
    }

product_product()


class hotel_meetingroom(osv.Model):
    _name = "hotel.meetingroom"
    _inherits = {'product.product': 'product_id'}
    _description = "Hotel Meeting Room"
    _columns = {
        'product_id': fields.many2one('product.product', 'Product_id', required=True, ondelete='cascade'),
        'name':fields.char('Meeting Room Name', size=64, required=True),
        'capacity':fields.integer('Capacity'),
    }
    _defaults = {
        'ismeetingroom': 1,
        'ismeetingroomextra': 0,
    }

hotel_meetingroom()

My View which I've really simplified:

<record model="ir.ui.view" id="view_hotel_meetingroom_form">
    <field name="name">hotel.meetingroom.form</field>
    <field name="model">hotel.meetingroom</field>
    <field name="arch" type="xml">
        <form string="Hotel Meeting Meeting Room" version="7.0">
            <group>
                <field name="name" select="1"/>
            </group>
        </form>
    </field>
</record>

And the traceback from my server log:

2014-03-15 23:36:31,102 31318 ERROR test-demo-data openerp.sql_db: bad query: insert into "product_template" (id,"supply_method","list_price","standard_price","mes_type","uom_id","cost_method","categ_id","uos_coeff","sale_delay","procure_method","sale_ok","produce_delay","company_id","uom_po_id","rental","type",create_uid,create_date,write_uid,write_date) values (81,'buy','1.00','0.00','fixed',1,'standard',1,'1.000',7.0,'make_to_stock','True',1.0,1,1,'False','consu',1,(now() at time zone 'UTC'),1,(now() at time zone 'UTC'))
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/sql_db.py", line 226, in execute
    res = self._obj.execute(query, params)
IntegrityError: null value in column "name" violates not-null constraint
2014-03-15 23:36:31,109 31318 ERROR test-demo-data openerp.netsvc: Integrity 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: name - name]
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 174, in wrapper
    netsvc.abort_response(1, _('Integrity Error'), 'warning', msg)
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 71, in abort_response
    raise openerp.osv.osv.except_osv(description, details)
except_osv: ('Integrity Error', 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: name - name]')

I'm sure I must be doing something wrong, but I just can't figure it out.

1

Ray Carnes

--Ray Carnes--
15677
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 3/16/14, 1:18 AM

Your new model requires a value for product_id which itself requires a name field. If you show the field product_id in your view I suspect you will see it is blank, waiting for a value.

Thanks! That was indeed the problem. I removed the name field, which isn't necessary if the product stores it, and everything works fine now.

Seth Boyd
on 3/16/14, 11:45 AM

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 3/15/14, 9:24 PM
Seen: 1662 times
Last updated: 3/16/15, 8:10 AM