Monday, 25 April 2016

Adding a new language in ODOO

Following are the steps for adding a new language in ODOO(OpenERP):

1. Login to your database as Administrator user and go to 'Settings->Languages->Load a Translation'. Select a language in the pop up window(wizard). You can also select the 'Overwrite Existing Terms' and 'Website to translate' in the wizard. Then click on Load button for loading the new language.


Once the language is created you will get the following confirmation message.


You can also see the list of languages installed in your ODOO databse in 'Settings->Translations->Languages'.

2. After installing the language translations for all the labels(terms) in base modules will be created in the database automatically. But for your customized modules to get translated we need to setup the translation for all the terms(field labels, button names, menu names etc) manually. For this go to 'Settings->Translations->Import / Export->Export Translation'. In the wizard which opens on clicking the above menu, select the following values:
    a. Language
    b. File format: Select 'PO File'.
    c. Modules To Export: Select your customized modules here. For example I am selecting the Sales         Management module. In your case it might be something like Sales Management Customization         or Purchase Management Customization etc.
Then click on 'Export' button.


Once the export translation is completed you will get the following window from which you can download the PO file for your selected language.



3. Open the downloaded PO file and add the translations for each labels in English. In the file add value to 'msgstr' which should be the translation of the value in 'msgid' to your new language.









4. After making the changes in the PO file, copy the file to 'i18n' folder of your module in addons. If there is no folder named i18n create the folder in your module and copy the PO file in it.























5. Now restart the server and upgrade your module.
6. Then select the language in 'Preferences' in your user and it will load your database in  new language.





























The translated view will look like the following:






















For any doubts, suggestions or problems you can comment below or contact me via email.

Thanks,

Gopan

Saturday, 23 April 2016

Remove a field from Messages and communication history in ODOO

To remove a field from Messages and Communication history in Odoo models you can set the attribute track_visibility='none' in the field definition.

For example to remove the 'Expected Revenue' in opportunity form view's messages and communication history you can do the following:












For removing the Expected Revenue(planned_revenue) field we have inherit the crm_lead model and override the planned_revenue field.

class CrmLead(models.Model):
    _inherit = 'crm.lead'
planned_revenue = fields.Float(string='Expected Revenue', track_visibility='none') #Expected revenue field.

After upgrading the module the field expected revenue will not be tracked on making changes to the table.





How to track a field in messages in Odoo

For tracking the state changes, field changes etc for a model in Odoo, the model should inherit 'mail.thread' and in the form view of the model we have to provide the following code after the <sheet> tag.

Python file:
class SaleOrder(models.Models):
    _name = "sale.order"
    _inherit = ['mail.thread', 'ir.needaction_mixin']

XML view:
<div class="oe_chatter">
   <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
   <field name="message_ids" widget="mail_thread"/>
</div>

Adding the above code will show the following:

  • Created by
  • Modified by etc
For tracking a field we have to specify it in the field definition with parameter track_visibility set to 'always' or 'onchange' like the following:


state = fields.Selection([('draft', 'Unconfirmed'), ('open', 'Confirmed')], string='Status', readonly=True, track_visibility='always')
The following image shows the tracking of field Untaxed Amount in sales orders.