Odoo 10 - Custom Button with Action (Posting JSON customer data help !!)
Hi i have been able to create a button in the account.invoice with the following code in xml
<record id="invoice_form_shippinglabel" model="ir.ui.view">
<field name="name">account.invoice.form.shippinglabel</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<header>
<button name="label" string="Print Shipping Label" class="oe_highlight"/>
</header>
</field>
</record>
Now i want to add function after user press the button
so in my 'models.py' i have try to put this code
def label(self):
data = {
'ids': [12, 3, 4, 5, 6]
}
req = urllib2.Request('https://requestb.in/1bz11jv1')
req.add_header('Content-Type', 'application/json')
response = urllib2.urlopen(req, json.dumps(data))
so basically, i want to send some sample data to https://requestb.in/1bz11jv1
but it doesn't work when i restart odoo it give me this error in odoo.log
File "/odoo/odoo-server/addons/labelprint/models/models.py", line 14 def label(self): ^ IndentationError: unexpected indent
Am not very sure why it cause that error i have googled about Indentation and it doesnt help at all
Also i have a little more question on if i can post json data already
how do i get information like customer.address , customer.phone, customer.name because i will be need these in sending json data
Thank you very much