I have 4 models with same fields name. I need to show records from the 4 models on one view
how can I do it?
A Odoo view is usually a representation of a record in the database. To accomplish what you are speaking of you need to create a view which is the representation of a record which has relationships to all the other records you are speaking of. So a hackish way would be to create a model with 4 many2one fields each point at the model and records you are referring to.
Another option is to create a custom view or widget and using javascript to gather the data you need using the Odoo javascript api and then rendering it in a fashion that makes it usable for your use case.
This all depends on what you are trying to accomplish by displaying the 4 records. If it is simply a matter of displaying some information to the user a wizard model (models.TransientModel) with 4 many2one values may accomplish what you need.
Related
I'm using Odoo 9 SA and I want to make a report view (either a tabular list view, or a pivot table) that pulls data out of the sales model, the inventory model and the partner model. How can I accomplish this? From reading, it seems that I should make a new model that has reference fields to the other models and then build a new view from that model.. I'm just not sure if this is the best way and then if so, how to approach it.
Any advice?
For complex reports and pivot views you can create a Model that uses an SQL view to get the data. You can then provide list or pivot view for it, or even QWeb reports.
Here is an example of this, in the core Project module:
https://github.com/odoo/odoo/blob/9.0/addons/project/report/project_report.py
I've got a nice SSAS tabular model with users processing away. Certain users need access to certain information, such as confidential info (e.g., SS numbers), that should not be visible to everyone. How should I handle this?
This indicates that there is no way to use roles to remove columns, only rows. Is my only option to make a copy of the model and maintain both? This can't be such an edge case...
I guess I can jury-rig something with a scm fork and code-generation, but I'd rather not go down that road.
Alternatively, is there any way to hide the columns (per user/role), so that at least they don't show up in client tools?
One method that requires very little additional development is to use the method described in the following blog post. http://blog.westmonroepartners.com/a-workaround-for-column-security-in-the-sql-server-analysis-services-bism-tabular-model/
The blog contains a link to an SSIS package which will replicate an existing cube, with the exception of the sensitive data columns. The users who cannot view the sensitive data columns can be given access to the second cube that does not contain sensitive data columns.
One way to achieve this is to create Perspectives. You can create different perspectives for different group of users. And end users can connect to their specific model.
My MVC 4 application is using Entity Framework 5 as its ORM.
And an Oracle 10 database is used as its back-end.
MVC Views are displaying data from Oracle DB Views, and I have no control over database schema.
The Views are updatable, and there is also a requirement of managing concurrency. There is no timestamp sort of column in the underlying table/ view.
In such scenario, how can I manage concurrency?
Any advice on this will be much appreciated.
Sorry for the late answer but I just came across this.
As you have no access to the database, it would not be easy at all to prevent 2 users from requesting edit on the same record (even if you did, I am not sure there is a bullet proof way of doing this in a web application). What you can do is prevent a user from editing an object that was modified between the time it was retrieved and the time of change submission. I am going to assume that in your MVC application you are using view models to represent the domain model objects on the screen. You can include as an additional field in the view model a field for a hash computed based on the state of the object at time of retrieval. When an edit is posted, you would need to retrieve the record again from the database, compare its current hash with the one submitted by the MVC view. In case of discrepancy, inform the user of change and show the values as they are now in the database informing the user of what happened (e.g. by adding a model state error).
I want to build an online form builder much like wufoo that allows the users to create and publish their own web forms. Each submission should be saved to a data base where the user can later retrieve the submissions.
As these forms will be dynamic, ie. the user has complete control over the amount and type of form fields I am trying to think of a solid database design to store this information.
I would have one table fieldtype which contains every type of field available to the users, ie. textfield, emailfield etc.
One baseform table which will hold each forms id, url etc.
I would then have a table formfields which would contain ref to the baseform and to fieldtype, this table could also include custom validation to be done on each field.
Is this design good as a base structure? I imagine it will be easy to add new types of fields to the application however I don't know what the potential downsides are as I am far from a sql expert.
store user defined data in SQL
I think you are looking for the Entity–attribute–value database model in which:
The basic idea is to store attributes, and their corresponding values,
as rows in a single table.
Typically the table has at least three columns: entity, attribute, and
value. Though if there is only a single relevant entity, e.g. a table
for application configuration or option settings, the entity column
can be excluded.
See this pages as a start:
Using Database Metadata and its Semantics to Generate Automatic and Dynamic Web Entry Forms (pdf)
Planning and Implementing a Metadata-Driven Digital Repository (pdf)
I retagged your question with entity-attribute-value tag, in which you can browse a lot of threads that relate to your case.
As Mahmoud Gamal writes, The model you describe is "Entity/Attribute/Value"; as Borys writes, there are many known problems with this model.
As an alternative, you might consider storing the form entries in a "document" - e.g. XML or JSON - within a relational model.
For instance, you might have a table along the lines of:
FORM_SUBMISSION
--------------------
Submission_ID (pk)
Client_ID (fk to clients table)
Submission_date
SubmissionDocument
I'm using "client" to represent the users who create the form; to retrieve all submissions for a given client, you use a where clause on client_id.
This model makes it harder to run SQL queries against the form submission (though that becomes hard with EAV too when going beyond very simple queries), but it dramatically simplifies the persistence solution.
I have a SQL view to integrate with my application. I have been using Entity Framework till now. But the problem is that when I add a view to Entity Framework it starts treating my view as a table.
What I really want to know is, am I missing on something? Also if I use Nhibernate will this problem be resolved? Will it treat the view as a view only?
This view is a very complex query which has multiple joins and aggregation. That is why I am using a view.
But the problem is that when I add a view to Entity Framework it
starts treating my view as a table.
No it doesn't. If you add view to your model through wizard (EDMX designer) it will internally handle the view as a defining query which makes readonly entity. At entity level (the conceptual model) you don't see a difference because it is just another entity / class but if you try to make changes to instance of that class and save them you will get an exception (unless you map stored procedures or custom SQL commands to insert, update and delete operations for that entity).
Edit:
Database views as well as other database specific features like stored procedures or SQL functions are only for database first scenario (when you are using Update model from database in the designer).
Using Generate database from model is for Model first scenario where you tell VS: "Here is my model and I want some database to store it." First of all only information from conceptual model is used (original mapping and database description is replaced with a new one every time you run this command so even mapping to original database can be broken). It cannot create database specific features for you because it doesn't know that class should be mapped to view and moreover it doesn't know how should the view be created (the query from original view is unknown).
You can force VS to create the view for you but it is a lot of work in T4 templates where you will have to somehow provide SQL creation script for the view.