This question has been flagged
2 Replies
4134 Views

0 down vote favorite

I am working on module. it has a button, its name is creates, as shown in following code.

<button name="creates" string="Create" type="object" groups="base.group_erp_manager" /> def creates(self,cr,uid,ids,context=None): for id in ids: deg_obj=self.pool.get('deg.form').browse(cr,uid,id) pr=int(deg_obj.categg_temp) ctx=dict(context) ctx.update({'default_pr':pr}) return{ 'view_type': 'form', 'view_mode': 'form', 'res_model': 'product.product', 'context': ctx, 'type': 'ir.actions.act_window', 'target': 'current', }

when i click this button i get

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]

On my server log i have

2014-12-31 08:18:40,566 7407 ERROR new_db 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","company_id","produce_delay","uom_po_id","rental","type",create_uid,create_date,write_uid,write_date) values (639,'buy','1.00','0.00','fixed',1,'standard','9','1.000',7.0,'make_to_stock','True',1,1.0,1,'False','consu',1,(now() at time zone 'UTC'),1,(now() at time zone 'UTC')) Traceback (most recent call last): File "/opt/openerp/server/openerp/sql_db.py", line 226, in execute res = self._obj.execute(query, params) IntegrityError: null value in column "name" violates not-null constraint DETAIL: Failing row contains (639, 1, 2014-12-31 08:18:40.463017, 2014-12-31 08:18:40.463017, 1, null, null, 1.00, null, null, null, 0.00, fixed, 1, null, standard, 9, null, 1.000, null, t, null, null, 1, null, 1, 1, f, consu, null, null, 7, null, buy, make_to_stock). 2014-12-31 08:18:40,569 7407 ERROR new_db 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 "/opt/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/server/openerp/osv/osv.py", line 174, in wrapper netsvc.abort_response(1, _('Integrity Error'), 'warning', msg) File "/opt/openerp/server/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]')

My first question is. Why I am getting an error with sql insert command although there is nothing like insert related to creates method. It simply opens a form where i will press save button or something to save value. Secondly, how i can bypass this and move to next step where i can create item.

NOTE: I have Edit, View methods and buttons too, which simply opens Value in View and Edit mode. but have same issue with them too.




I have provided `name`:'' in defaults. Have same issue. This class deg_form is inherited from product.product. I want to open Edit/create form on button click. This button's method is never called. All i get is exception of name

Avatar
Discard
Best Answer

Hello,

You have to add default_name: YOUR_VALUE in context because sql error is: ``name`` is required and not set ...`.

After, it depends form where you have this button. Is it on a product form or on other model form ?
I understand you whant to create a new product, name is a requiered field so, you have to set a default value.

 

Avatar
Discard
Author Best Answer

Please check my edit. Pardon me, as i am unable to comment because of low karma

Avatar
Discard