What's the relationship between res.partner and res.user? - postgresql

I am new to odoo v8 and i am not able to understand the relationship between res_partner and res_users tables and also with hr_employee table are they all related?

The relationship between res.partner and res.user is that res.user inherits from res.partner using an inheritance type called "Delegation Inheritance" (see documentation).
Because of "Delegation Inheritance" every res.user record has a mandatory internal connection to a corresponding res.partner record using a field partner_id. What is this connection all about is to directly use all the fields of res.partner to store data shared by res.user and res.partner (i.e. name, phone, etc... if for example you refer to phone property of a record of res.user you'll get the value stored in the corresponding res.partner record) so res.user has to define fewer number of fields on it's own, like password, login, etc..
Note also that because of this relation res.user can NOT exist in the system without corresponding res.partner, it's why every res.user has one, but nonetheless res.partner can exist without res.user.

hr.employee have m21 with res.users (user_id)
res.users have m21 with res.partner(partner_id)

Actually only res.users has a "real" relationship to res.partner, because with every user odoo will create a partner (per default no customer and no supplier). this partner will be used e.g. for emails and the followers system in odoo.
But you can have partners without users, too. That will be a normal partner, for defining customers and suppliers.
And finally there is the employee. You can set a user on it. If i recall right, the user will be used for attendances and timesheets.

Related

Microsoft Master Data Services 2016 Additonal Domain Atrribute Referencing

Is it possible to reference additional columns apart from the 'Code' and 'Name' columns when using a domain attribute in an entity?
E.g. A person entity has a code of '1' and a name of 'Smith' and a Gender of 'Male'
In a customer entity there is a domain value referencing the person entity which displays the following 1 {Smith}. The users would like an additional read only attribute which would copy the Gender value of 'Male' into the customer entity based on the domain value. Can this be done using out of the box MDS UI?
I know this is duplicate data and breaks normal form but for usability this would be useful. It would be the equivalent of referencing additional columns in an MS Access drop down list.
Many thanks in advance for any help
This is not possible with the standard UI. One option would be to develop a custom UI where you can handle these kind of requests.
If you want to stick with the standard product I can see a workaround but this is a bit of a "dirty" one.
You can misuse (abuse) the Name attribute of the Person entity by adding a business rule to the Person entity that generates the content of the Name attribute as a concatenation of multiple attributes. You of course need an additional attribute that serves as a place holder for the original Name. The concatenated field will then show in your customer entity.
One question that does come to mind is why a user would like/need to see the gender of a person in a customer list? As you have a separate Person entity I expect you to have multiple persons per customers. What would the gender of one person - even if it is the main contact - matter?

Can't add or edit records in form after updating relationship MS Access

Previously I had a Payment table's Form and a Current Tenant's Table's form. The Payment table was related with the Current Tenant's email address.
Later I realized the Payment table needed to include details of old tenants. So i created an append query to create a table containing details of all the tenants. And I changed the relationship so that the payment table is related to the email address from all tenant's table. Now using the Form, if i try to add a record using the form, it shows "You can't go to the specified record" and if i try to edit the records, it displays "The record set is not updateable". But i can add and edit record using the table. This problem only exists when i try to include the "Name of Tenant", "Tenant's Contact Information" or any other field from the "All Tenant's Table" in the form. How can i fix this?
Note: The email address in All tenant's contains duplicate records due to different Check out and Check in date. Except those, all other records are same.
When you join multiple tables in Access in order to allow updates across both tables, you need to join using a Primary Key.
Here is a great reference on the subject of Primary Keys.
Be sure that your "Current Tenants" table uses email address as a primary key, and then join it to the "Payment Table". The Payment table should also have a primary key (likely an 'auto number' field).
Ok, i found a way to solve the problem... I edited the relationship so that the All tenant's table is joined with Current tenant's table by Type 3 relationship. And Then joined the All tenant's table with the Payment table... It then solved the problem...

Zend Framework Doctrine insert one-to-many

Amongst order tables i have a Customers table and Addresses table. A customer can have many addresses so I have setup a one-to-many relationship in a yaml file. The thing is the id for the Customers table is auto generated so I would not know the Customers_id until after the insert however, the Customers_id is a foreign key in the Addresses table.
The information for both tables is captured on the same form although each set of data is in a subform. How do I get Doctrine to insert the data into the Customers table then fetch the Customers_id just entered and use it as the foreign key for the Addresses table.
Hope I have been able to get the essence of the question across.
BTW I am using Zend Framework and Doctrine 1.2.3
Once you do $customer->save(), you may use $customer->id (if "id" is the Customers_id column name of your customer table) to get the Customers_id to put in Addresses table.
Once you do $customer->save(); the following statement $customer->identifier(); should give you the id.
Assuming you are using Doctrine 1.x you could do the following:
$cusomer->Address[] = $address; // Assign multiple addresses in this manner
$customer->save();
This will first save the customer details to the db and then store the address data. Since doctrine understands the relationship between customer and address, the ORM will insert the customer id in the address table. Further this will be run within a transaction by Doctrine which ensures that if one of the operations fail the entire transaction will be rolled back.

FileMaker - Finding Primary Key of First Related Record

I'm using a script to create a new Invoice record. I'd like to automatically set the invoice's fClient fContactID column to the ID of the client's first contact.
In my script, how would I find/compute the ID of the client's first contact? SetField with a calculated result of Min(Contact_Invoice Contact::ContactID) didn't work.
Tables:
Client - primary key: ClientID
Contact - has foreign key: fClientID (a client can have many contacts)
Invoice - has foreign keys: fClientID & fContactID (an invoice is associated with one client and with one of that client's contacts)
Thank you,
Ben
You say you want to set the "fClientID", but from your description it sound more like you're wanting to set the fContactID. Is that right?
If that's the case, then you have an Invoice, related to a Client, which is directly related to a Contact. What you're doing is right, but if it's not working then your context isn't right. Your context at the time is the Invoice table, so the related Contact needs to be accessible from there.
You could also use an auto enter calc instead of a script to set this. Extra bonus is that this will only let you select a valid context and related table.

Adding a property to an Entity Framework Entity from another table

I'm just starting out with the Entity Framework and ADO.NET Data Services and I've run into an issue that I can't seem to figure out. I have two tables, one that has user information and the other that has a created by field. Within the database, there isn't a foreign key between these tables. The user table contains an arbitrary Id, a username, and a display name. The created by field contains the user's username. In my entity I would like to have the user's display name since this is what I need to display and expose over the ADO.NET Data Service? I'm aware that I could restructure the database, but I was hoping that I could do the join using the username as I would in a SQL statement.
Thanks in advance,
-Damien
You can make a view using a join of both tables, and then use this object to display the user's name.
There's some info on mapping custom queries here.