Useless _('...') in _constraints messages (v. 6.0)

Bug #660506 reported by Jordi Esteve (www.zikzakmedia.com)
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 2

Bug Description

There are some useless _('...') in _constraints and _sql_constraints messages (v. 6.0) that could be removed. I suppose that the English texts extracted from this messages to create .pot files will be wrong if _('...') are no removed.

$ grep -r " _constraints" * -A 1|grep "_("

account/account.py- (_check_percent, _('Percentages for Payment Term Line must be between 0 and 1, Example: 0.02 for 2% '), ['value_amount']),

marketing_campaign/marketing_campaign.py- (_check_model, _('Model of filter must be same as resource model of Campaign '), ['ir_filter_id,campaign_id']),

marketing_campaign/marketing_campaign.py- (_check_campaign, _('The To/From Activity of transition must be of the same Campaign '), ['activity_from_id,activity_to_id']),

product/pricelist.py- (_check_recursion, _('Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList Item!'), ['base_pricelist_id'])

project/project.py- (_check_recursion, _('Error ! You cannot create recursive tasks.'), ['parent_ids'])

$ grep -r "sql_constraints" * -A 1|grep "_("

base/res/res_user.py- ('login_key', 'UNIQUE (login)', _('You can not have two users with the same login !'))

email_template/email_template.py- ('name', 'unique (name)', _('The template name must be unique !'))

stock/stock.py- ('name_ref_uniq', 'unique (name, ref)', _('The combination of serial number and internal reference must be unique !')),

Revision history for this message
Numérigraphe (numerigraphe) wrote :

Sorry, I don't understand how this is useless, can't _constraints and _sql_constraints be translated?
Lionel

Revision history for this message
Jordi Esteve (www.zikzakmedia.com) (jesteve-zikzakmedia) wrote :

I suppose that OpenERP translates the warning messages in _constraints and _sql_constraints automatically, like OpenERP translates the name fields, the help of the fields, ... There is not need to add _(...) to translate them.

There are a lot of _constraints and _sql_constraints without _(...) and only a few (the ones I have listed above) that includes them, so I suppose that the last ones are wrong.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello Jordi,

It's true that it is not necessary to use _( ) in constraints because the ORM translates the constraints automatically when needed.
However you should not worry about it because these calls are in fact evaluated only once when the server starts, outside of any language context, so the _( ) call has no effect.

But you're right, we can remove them :-)

Changed in openobject-addons:
importance: Undecided → Low
milestone: none → 6.0-rc2
status: New → Confirmed
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Thanks for making this clear Jordy and Olivier.
Is it mentioned somewhere in the docs?
Lionel

Revision history for this message
Numérigraphe (numerigraphe) wrote :

In the same kind of logic, isn't it useless to have _()'s in YAML test files?
Like in sale/manual_order_policy.yaml
Lionel

Revision history for this message
Numérigraphe (numerigraphe) wrote :

I changed the status in the wrong bug, sorry.

Changed in openobject-addons:
status: Confirmed → Fix Committed
status: Fix Committed → Confirmed
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
Revision history for this message
Kirti Savalia(OpenERP) (ksa-openerp) wrote :

hello
It has been fixed in
branch : lp: ~openerp-dev/openobject-addons/ksa-dev-addons2
revision id : <email address hidden>
revision no : 3457

Thanks

Changed in openobject-addons:
status: Confirmed → Fix Committed
Changed in openobject-addons:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.