title: Inheritance of customized module in Odoo
body: <p>I'm trying to create a module (<code>project_photo</code>) for uploading photos related to customer projects with a button next to "Documents":</p>
  
  <p><img src="https://i.stack.imgur.com/VLDcX.png" alt="enter image description here"></p>
  
  <p>Since I need the photo count for each project, I'm inheriting the <code>project.project</code> module so I can add the <code>photo_count</code> function field. Something like this:</p>
  
  <p><strong>project_photo.py</strong></p>
  
  <pre><code># -*- encoding: utf-8 -*-
  from openerp.osv import fields, osv
  from openerp.tools.translate import _
  
  
  class my_project(osv.osv):
      def _get_attached_photos(self, cr, uid, ids, field_name, arg, context):
          res = {}
          project_photos = self.pool.get('project.photo')
          for id in ids:
              photo = project_photos.search(cr, uid, [('project_id', '=', id)], context=context, count=True)
              res[id] = photo or 0
          return res
  
      def photo_tree_view(self, cr, uid, ids, context):
          photo_ids = self.pool.get('project.photo').search(cr, uid, [('project_id', 'in', ids)])
          domain = [
               '|',
               '&amp;', ('res_model', '=', 'project.project'), ('res_id', 'in', ids),
               '&amp;', ('res_model', '=', 'project.photo'), ('res_id', 'in', photo_ids)
          ]
          res_id = ids and ids[0] or False
          return {
              'name': _('Photos'),
              'domain': domain,
              'res_model': 'ir.attachment',
              'type': 'ir.actions.act_window',
              'view_id': False,
              'view_mode': 'kanban,tree,form',
              'view_type': 'form',
              'limit': 80,
              'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id)
          }
  
      _name = 'project.project'
      _inherit = 'project.project'
      _columns = {
          'photo_count': fields.function(
              _get_attached_photos, string='Number of photos attached', type='integer'
          ),
      }
  
  my_project()
  
  
  class project_photo(osv.osv):
      _name = 'project.photo'
      _columns = {
          'project_id': fields.many2one(
              'project.project',
              'Project',
              ondelete='cascade'
          ),
          'photo': fields.binary('Photo'),
      }
  
  project_photo()
  </code></pre>
  
  <p>My view is inheriting <code>project.edit_project</code> and I'm placing my button after the <code>doc_count</code> button:</p>
  
  <p><strong>project_photo.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;openerp&gt;
      &lt;data&gt;
          &lt;record id="project_photos" model="ir.ui.view"&gt;
              &lt;field name="name"&gt;project.project.form&lt;/field&gt;
              &lt;field name="model"&gt;project.project&lt;/field&gt;
              &lt;field name="inherit_id" ref="project.edit_project" /&gt;
              &lt;field name="arch" type="xml"&gt;
                  &lt;field name="doc_count" position="after"&gt;
                       &lt;button  class="oe_inline oe_stat_button" name="photo_tree_view" type="object" icon="fa-picture-o"&gt;
                          &lt;field string="Photos" name="photo_count" widget="statinfo" /&gt;
                      &lt;/button&gt;
                  &lt;/field&gt;
              &lt;/field&gt;
          &lt;/record&gt;
      &lt;/data&gt;
  &lt;/openerp&gt;
  </code></pre>
  
  <p>I'm getting this error when trying to install the module:</p>
  
  <pre><code>...
  ParseError: "ValidateError
  Field(s) `arch` failed against a constraint: Invalid view definition
  
  Error details:
  Field `photo_count` does not exist
  ...
  </code></pre>