Rails: cannot change email after signed up? - ruby-on-rails-3

i have a User model and some common columns, such as name, email, password, etc.
and here is the thing:
i donot want a user changing his email address after signed up, what should i do?
just don't include the email field in the update form?
and i think the attr_accessible is not for this use either.
what do you suggest? thanks a lot.

What you need is
attr_readonly
The documentation says the following
Attributes listed as readonly will be used to create a new record but update operations will ignore these fields.
So, a new record can be created with an email but you can never change it (without a hack) after the record has been created.

Related

How to add data to res.partner fields for mlutiple companies via API

I'm trying to add account payable and receivable fields for a partner in Odoo via API. However, they are only being applied to the default company. I hope the following images clarify.
How it appears for our default company :
How it appears for the other company :
I'm creating a partner as follows :
user_id = models.execute_kw(db, uid, password, 'res.partner', 'create', [{'name': name,'email':email,'company_id': odoo_company_id,'property_account_payable_id':account_payable_id,'property_account_receivable_id':account_receivables_id,'property_product_pricelist':pricelist_id}])
Any idea how this can be done ? Thanks in advance.
Those are properties and values are stored in ir.property objects. You probably have to write those entries for each company.
Remember that accounts are company-depending objects as well, so you cannot use same account.account object to every company. They are different objects with different ids in database even if accounts may have same code and name and you cannot see any difference on user interface.
You can also define default property for each company, if that is what you want. It can be done through GUI.

Is it possible to show additional cabinets to a user even if it is not added in restricted_folder_ids?

I have a cabinet say "tcabinet" in a repository "trepository".
In this repository there are multiple users however their access is restricted by adding the cabinet IDs to the restricted_folder_ids column in dm_user object.
The user has access to the ACL. But still they can not see tcabinet as their access is restricted. There are thousands of such users.
For these users to see the tcabinet. I'll have to add the object id of tcabinet to restricted_folder_ids column of each user which would definitely be a large task.
Is there any way to make them able to see the cabinet without adding the cabinet id to each user?
As confirmed by OpenText also, there is no other way to achive this. However we can add the cabinet to everyone's 'restricted_folder_id' attribute in dm_user table.
UPDATE dm_user object
APPEND restricted_folder_ids=’<Object ID of the Cabinet>’
WHERE user_name='<user_name>'
NOTE: If you are using this method, make sure to filter out the users which does not have any existing 'restricted_folder_id' in dm_user table, else this method will restrict the access of these users to a single folder which might not be the intention.

Podio External ID change

We use an external setup that sends information on our orders into Podio and from there we manage them. We have had an issue with our Email field and it's lead to the External ID 'email' being lost (we are up to email-6' now before realising the issue). Is it possible to reset/restore the External ID to be 'Email' instead of 'Email-6' and if so could you please point to how we can do it. The developers we use don't work with us anymore so it's a bit of a nightmare to sort out. We are reasonably tech savvy but not wiz kids by any stretch of the imagination. I've copied below what our old developers said:
"What I'm pretty sure is your case, is that you have deleted the original Email field from the template, and now you are trying to put it back. The problem is that, only by appearance, you have a single Email field in your template, but when Fabnami is sending the data, the collected customer email is attached to the field with external ID "email", not the one you have only labeled as Email. The result is that podio will exhume the deleted field and will display it using the last labels it has. In your case there will be the original field with label "Email" and ExternalID "email" plus a second empty field with label "Email" but different External ID."
I hope you can help :)
Each time, when the field get created, external_id get created in parallel(1 to 1 mapping). If you delete the field the external id get deleted along with that. You can't reset the external id "email" to "email-6".
There is a option to recover the first deleted field "Email" -> external is id "email", but with the recovery payment.
Each time, when the field get created, external_id get created in parallel. If you delete the field the external id get deleted along with that. You can't reset the external id "email" to "email-6".
There is a option to recover the first deleted field "Email" -> external is id "email", but with the recovery payment.

Unique and Mandatory Email-id while adding new lead in OpenERP7

I am new in OpenERP and have a task to achieve.
I want to keep Email-id unique and mandatory while adding new lead in CRM. I would like to know which is the best way to achieve it.
Thank You
you have to use _constraint for the field email address where it checks for the uniqueness of the field. use required=True for making it required for each data.
Cheers,
Parthiv

Nested resource check

I have a Rails form, where is reported the user and the skills of the user (the association is many to many) so I use accepted_nested resource in the form
Everything works okkey, the user have the chance to create a new skill and associate themself to it.
The problem is that if a skill with the same name already exists, I don't want that one more skill with the same name is created, I just want an association with the user and the already existing skill.
Do I have to leave the nested resource approach and performing some controls in the controller in order to choose if create or just associate the skill ?
Tnx
You could use Rails' find_or_create_by method to find or create the skill by whatever criteria you choose. Then add that to the user's skill collection. I don't know what your code looks like, but something like this:
#skill = Skill.find_or_create_by_name(params[:skill][:name])
#user.skills << #skill