I'm trying to create a new file on my pc using an odoo button. this is the function in the models file of the Module:
class AccountMove(models.Model):
_inherit = "account.move"
#some fields here
@api.model
def write_new_file(self):
with open('/home/msaeb/newFile.txt', 'w') as new_file:
new_file.write("some text here")
and this the button in the view file:
<record id="account_move_order_inherit" model="ir.ui.view">
<field name="name">account.move.order.inherit</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<field name="invoice_date" position="after">
<field name="expire_date"/>
</field>
<field name="ref" position="after">
<field name="some_field_here"/>
<span>
<button name="write_new_file" string="creates new text file" type="object" class="btn btn-primary"/>
</span>
</field>
...
...
whenever I click the button I got the following error:
خطأ:
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/http.py", line 664, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 345, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 93, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 338, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 910, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 510, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1324, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1312, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 391, in call_kw
result = _call_kw_model(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 364, in _call_kw_model
result = method(recs, *args, **kwargs)
TypeError: write_new_file() takes 1 positional argument but 2 were given
please help. thanks in advance