title: How to create and show image in odoo
body: <p>I need help about error in odoo.
  I have created models and xml for image in odoo.</p>
  
  <p>this is my models</p>
  
  <pre><code>class Test(osv.osv):
  _name = "digital.test"
  _description = "Test"
  
  _columns = {
      'Servicename': fields.char('Service Name'),
      'prodescription': fields.html('Product description'),
      'Subservicename': fields.char('Sub-Service Name'),
      'subprodescription': fields.html('Product Desc.'),
  }
  
  # image: all image fields are base64 encoded and PIL-supported
  image = openerp.fields.Binary("Photo", attachment=True,
      help="This field holds the image used as photo for the test, limited to 1024x1024px.")
  image_medium = openerp.fields.Binary("Medium-sized photo", attachment=True,
      help="Medium-sized photo of the test. It is automatically "\
           "resized as a 128x128px image, with aspect ratio preserved. "\
           "Use this field in form views or some kanban views.")
  image_small = openerp.fields.Binary("Small-sized photo", attachment=True,
      help="Small-sized photo of the test. It is automatically "\
           "resized as a 64x64px image, with aspect ratio preserved. "\
           "Use this field anywhere a small image is required.")
  
  def _get_default_image(self, cr, uid, context=None):
      image_path = get_module_resource('mymodule', 'static/src/img', 'default_image.png')
      return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
  
  defaults = {
      'active': 1,
      'image': _get_default_image,
      'color': 0,
  }
  
  @api.model
  def create(self, vals):
      tools.image_resize_images(vals)
      return super(digital.test, self).create(vals)
  </code></pre>
  
  <p>and this my xml</p>
  
  <pre><code>        &lt;record id="view_test_form" model="ir.ui.view"&gt;
          &lt;field name="name"&gt;digital.test.form&lt;/field&gt;
          &lt;field name="model"&gt;digital.test&lt;/field&gt;
          &lt;field name="arch" type="xml"&gt;
              &lt;form string="Test"&gt;
                  &lt;sheet&gt;
                      &lt;field name="image" widget='image' class="oe_avatar" options='{"preview_image":"image_medium"}'/&gt;
                      &lt;div class="oe_title"&gt;
                          &lt;label for="Service Name" class="oe_edit_only"/&gt;
                          &lt;h1&gt;
                              &lt;field name="Servicename" placeholder="Service Name"/&gt;
                          &lt;/h1&gt;
                      &lt;/div&gt;
                      &lt;notebook&gt;
                          &lt;page string="Product Description"&gt;
                              &lt;group string="Service Name"&gt;
                                  &lt;field name="prodescription" type="html"/&gt;
                              &lt;/group&gt;
                              &lt;group string="Sub-Service Name"&gt;
                                    &lt;field name="Subservicename"/&gt;
                                    &lt;field name="subprodescription" widget="html"/&gt;
                              &lt;/group&gt;
                          &lt;/page&gt;
                      &lt;/notebook&gt;
                  &lt;/sheet&gt;
              &lt;/form&gt;
          &lt;/field&gt;
      &lt;/record&gt;
  </code></pre>
  
  <p>But, my code is error when i create new data 
  like this
  <a href="https://i.stack.imgur.com/GnXwr.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>I can save data, when i remove @api.model def create
  but, my image can't save. </p>
  
  <p>Thank You</p>