Hi Cezar Jr,
Ofcourse this is possible! Just add the code inside your function that is triggered by a button. Don't forget to import your external Python library though! Let me show you an example. A new form with a button (xml):
<openerp>
<data>
<record model="ir.ui.view" id="view_buttons_form">
<field name="name">Buttons</field>
<field name="model">button.demo</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Button record">
<!--The header tag is built to add buttons within. This puts them at the top -->
<header>
<!--The oe_highlight class gives the button a red color when it is saved.
It is usually used to indicate the expected behaviour. -->
<button string="Run external function" type="object" name="run_external_function" class="oe_highlight"/>
</header>
<group>
<field name="name"/>
</group>
</form>
</field>
</record>
</data>
</openerp>
This part of the code will link to a Python function:
<button string="Run external function" type="object" name="run_external_function" class="oe_highlight"/>
Next just create a Python function that calls your code:
# WARNING! @api.one is deprecated in Odoo 9, use @api.multi with ensure_one instead!
@api.one
def run_external_function(self):
#From here on you can execute all the code you want. Don't forget to import the external Python library at the top though!
conn.sendall(vd_comms.setGateOpen(_tid))
Yenthe
Thanks!
This solve my problem!
No problem Cezar! Don't forget to upvote / accept an answer if it has helped you. :)