← Back to team overview

c2c-oerpscenario team mailing list archive

Re: [Bug 839915] [NEW] Database views fail silently on function fields

 

On Saturday 03 September 2011, you wrote:
> Public bug reported:
> 
> I am creating database views as a basis for reports. I've done three
> that work fine. The fourth does not. When I click on its menu item I get
> this error:
> 
> ProgrammingError: relation "citrus_fruit_received_report" does not exist
> LINE 1: SELECT "citrus_fruit_received_report".id FROM "citrus_fruit_...
> 

Let me try to /guess/ from your sayings: (if I'm wrong, please correct
me)

you have a real orm model like:
 class foo(osv.osv):
   _columns {
      'name': fields.char('Name', ...),
      'frob': fields.function(some_fn, 'Fr-ob', store=False ...),
  }

and then you define a view/report like:
  class bar(osv.osv):
    _auto = False,
   
    _columns = {
       'name': fields.char('Name of foo'),
       'frob': fields.char('Content of foo frob' ...),
    }
 
    def _init(self, cr):
      cr.execute(" CREATE VIEW bar AS SELECT name, frob FROM foo ")
      ......


Well, if it is so, this is not a bug, but a missing ORM API implementation. 
The framework is NOT supposed to check your "bar" view, you are manually 
creating it with a direct SQL query and you are 100% responsible for it.

I agree that the framework, in some future version, _should_ provide something 
more clever for those views. The current implementation is naive and has 
already allowed many mishaps with the views. Then, the "holy grail" question 
is how to mix those function fields and SQL code. (Dr. Ferdinand, are you 
reading this? )

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/839915

Title:
  Database views fail silently on function fields

Status in OpenERP Server:
  New

Bug description:
  I am creating database views as a basis for reports. I've done three
  that work fine. The fourth does not. When I click on its menu item I
  get this error:

  ProgrammingError: relation "citrus_fruit_received_report" does not exist
  LINE 1: SELECT "citrus_fruit_received_report".id FROM "citrus_fruit_...

  Sure enough, the view is not in the database.
  Now I've gone through my code, the query works fine in pgadmin, if I make _auto=True I get a working object, the field names and types all match.

  Stepping through in the debugger I see that the view is created in the
  database but then it gets dropped again. I cannot see why, or how.
  What could cause this?

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/839915/+subscriptions


References