I have created a button of type action. This button calls an action, and this action calls a form. This form was totally created by me, and has a button Create, which calls the function create, directly inherited from orm.Model (I did not touch it).
When I click on Create, the record is perfectly stored on the database, but then I get this error:
File "/opt/openerp7/openerp_70_ocb_devel/ocb-server/openerp/osv/orm.py", line 4342, in create
if vals.pop(f, None) is not None:
TypeError: pop() takes at most 1 argument (2 given)
I was looking for the content of vals, and when I click on the button, the method create seems to be called twice. The first time, vals brings the values of the record in a dictionary (all right), the second time brings the ID of the new record generated in a list, and provokes the error.
I would like to know why is this happening and how to solve this. I left here my code:
The button which calls the action:
<button name="%(res_partner_extended.action_create_res_partner_link_category)d" string="Link to category" type="action"/>
The action:
<record id="action_create_res_partner_link_category" model="ir.actions.act_window">
<field name="name">Link to a new category</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner.link.category</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="res_partner_link_category_create_form_view"/>
<field name="target">new</field>
</record>
And the form, with the button which is getting the error:
<record id="res_partner_link_category_create_form_view" model="ir.ui.view">
<field name="name">res.partner.link.category.create.form</field>
<field name="model">res.partner.link.category</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Linked category" version="7.0">
<group>
<group col="2">
<field name="partner_id" readonly="1" options="{'no_open': True,}"/>
<field name="link_category_id" required="1" options="{'no_open': True}"/>
<field name="type" required="1"/>
</group>
<group col="2">
<field name="date" required="1"/>
<field name="observations"/>
</group>
</group>
<footer>
<button name="create" string="Create" type="object" class="oe_highlight"/>
or
<button string="Discard" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
Can you post your create function?
@Pau Ubach I did not made any create function. I am calling the create function which every class inherited from orm.Model has.
Maybe I'm suggesting something stupid, in case the method should be called twice, but I'd try to make CREATE function, check the content in vals, if OK, call create, otherwise, don't call it.
Thank you @Pau Ubach. That's not stupid, in fact, I tried it before, creating my own create function and from there calling the ORM create method. But the result was exactly the same. I do not know what I am doing wrong. I am thinking to ignore ORM method and make a SQL query directly, but that would not be a right way to manage my target.
Neither using a SQL nor overriding the CREATE function to act this way aren't good solutions, as this could affect the normal system behavior. I'm sorry to can't be more helpful. You should wait until it comes someone with better background in openERP than me.