Hello
i use odoo version 8 and i use new API in my code..
this is my code:
test.py
from openerp import models, fields, api
class purchase_order(models.Model):
_inherit = 'purchase.order
name_name = fields.Char(string="Test")
def button_test(self):
for rec in self:
self.name_name = '123'
test_view.xml
<?xml version="1.0"?>
<openerp>
<data>
<record id="test_purchase" model="ir.ui.view">
<field name="name">test_purchase</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//header/button[@name='action_cancel']" position="after">
<button name="button_test" string="TEST" type="object"/>
</xpath>
</field>
</record>
</data>
</openerp>
but i always have this error when i click the button
Traceback (most recent call last): File "D:\odoo8\odoo8\odoo8\openerp\http.py", line 546, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "D:\odoo8\odoo8\odoo8\openerp\http.py", line 583, in dispatch result = self._call_function(**self.params) File "D:\odoo8\odoo8\odoo8\openerp\http.py", line 319, in _call_function return checked_call(self.db, *args, **kwargs) File "D:\odoo8\odoo8\odoo8\openerp\service\model.py", line 118, in wrapper return f(dbname, *args, **kwargs) File "D:\odoo8\odoo8\odoo8\openerp\http.py", line 316, in checked_call return self.endpoint(*a, **kw) File "D:\odoo8\odoo8\odoo8\openerp\http.py", line 812, in __call__ return self.method(*args, **kw) File "D:\odoo8\odoo8\odoo8\openerp\http.py", line 412, in response_wrap response = f(*args, **kw) File "D:\odoo8\odoo8\odoo8\openerp\addons\web\controllers\main.py", line 948, in call_button action = self._call_kw(model, method, args, {}) File "D:\odoo8\odoo8\odoo8\openerp\addons\web\controllers\main.py", line 936, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) TypeError: button_test() takes exactly 1 argument (5 given)