Commit Graph
39 Commits
Author SHA1 Message Date
Xavier-Do 288595f558 [FIX] *: add explicit license to all manifest
The license is missing in most enterprise manifest so
the decision was taken to make it explicit in all cases.
When not defined, a warning will be triggered starting from
14.0 when falling back on the default LGPL-3.

closes odoo/odoo#74245

Related: odoo/design-themes#48
Related: odoo/enterprise#19862
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2021-07-26 13:09:57 +00:00
dht-odoo 12469ef4d3 [IMP] various: improve the sequence of menu items
- Currently all menus are out of order in app switcher.
- For example, Sales app is 16 menu away from Accounting,
  Social Marketing app is 25 menu away from Email Marketing, etc.
  So, all menus should be reordered.

- This commit will reorder the menus of the app switcher in order to reduce
  the distance between correlated applications,
  and bring the most common apps upward.
- And in this commit we have left gap of 5 subsequent sequence for further new menus.

PR: #69984
TASK ID: 2513082

Related: odoo/enterprise#17989
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-07 05:54:18 +00:00
Julien MougenotandSimon Genin 03641610c2 [REF] *: convert all modules to new asset system
Conversion of all modules to the new manifest assets declaration.

Part of task: 2352566

Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Simon Genin <ges@odoo.com>
2021-03-31 13:57:18 +02:00
Julien Castiaux ca903577d2 [REF] test_*: Use Command helper for x2many
Task: 2366606
2020-11-30 10:16:09 +00:00
Raphael Collet 84aabd001e [FIX] test_translation_import: side effect between test methods
One test method was setting `env.context` instead of creating a new
environment.
2020-11-24 13:23:32 +00:00
Paul Morelle 43dd5c70d1 [IMP] translate: add add/radd methods on _lt class
In order to ease the usage of lazy translation, add the possibility to
add the _lt objects together and with strings.

Adding two _lt objects together or to a string will execute their
translation, so these operations still must be done once the user's
language has been defined.

For example, this is now possible:

    MESSAGES = {
        1: _lt("Hello, world!"),
        2: _lt("Lorem ipsum"),
    }

    def get_text(code):
        return _("Text is: ") + MESSAGES[code]

closes odoo/odoo#60844

X-original-commit: c4596664e5514018c565eaf14b93e000d972bd30
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
2020-10-27 15:18:38 +00:00
Martin Trigaux 3c3b88f676 [IMP] tools: add placeholder support to _
Mimic the syntax of logging to use placeholders in translatable
message.
The main advantage is to be able to fallback on the source term if the
translation can not be formatted properly.
It is very common to have errors in translations with missing
placeholders or badly translated (ie. the source
     "%(subject)s" -> "%(sujet)s").

Instead of blocking the execution of the code, fallback on source
string.

Task-id: 1853119
2020-06-18 13:03:34 +02:00
Martin Trigaux c142f1628d [FIX] tools: reimport translations in csv
Before this commit trying to reimport csv of a translation failed.
The reason was that before 632fa044c3 the parsing was common
between po and csv while now it's split in two different parsers.
The res_id column of the CSV is the external id of the record and is
handled by IrTranslationImport.

Use DictReader instead of csv_reader to easily add new keys and still
be flexible on the given csv files.

Match the POReader format with a imd_model and imd_name column.

As for the PoFileReader, the code translations are unique and must be
discarded in case of duplicate.

Correct the error message if the imported file is not correct (was
missing an argument)

Fixes odoo/odoo#50975

closes odoo/odoo#51468

X-original-commit: 3cedadb5ba606e156f52e70ed08b25ac2df8d58b
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-05-19 08:01:17 +00:00
Lucas Perais (lpe) 69b51ce05e [FIX] translate: do not export OWL directive's attribute
Have a static template of the form:

```xml
<div t-name="ComponentA">
 <ComponentB title="no export" />
</div>
```
To be used by OWL (github.com/odoo/owl)
In this context, the title in the attributes of ComponentB
should not be considered as *the* title attribute of HTML
but as a sort of variable declaration

Before this commit, the string contained in the value of this
title attribute was exported. It was not translated at runtime,
but we want to export as less stuff as possible in PO files

So, after this commit, none of the attributes held by a OWL directive
are exported

This commit relies on OWL Syntax, which makes mandatory
for a component directive's first letter to be capitalized
https://github.com/odoo/owl/blob/master/doc/reference/component.md#composition

Also, it relies on the good practice and widespread convention to have
every HTML node lower cased
https://www.w3schools.com/html/html5_syntax.asp

closes odoo/odoo#46191

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-04-17 12:55:32 +00:00
Yannick Tivisse 4c291e3f70 [IMP] base: Display searchpanel on ir.module.module views
Purpose
=======

The current kanban view is messy. It is difficult to identify which
apps are installed or not. The user can completely miss a module
that might have interested him. A search panel would make things way
more readable.

closes odoo/odoo#44401

Taskid: 2181557
Related: odoo/enterprise#8144
Related: odoo/upgrade#879
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-03-05 14:03:45 +00:00
Martin Trigaux 65530dfd6a [ADD] *: add ir.model.access on all transient models
Following changes needing ir.model.access on transient models too.
Remove groups declaration on the action to move it to ir.model.access
when possible.
Rules are strict by default with no unlink access by default and high
priviledge asked. Adaptations may be needed later.
Write access is given as a wizard may need to be modified in case the
action triggers an error and the user has to correct a value

account*: use account.group_account_user for all transient by default
	  remove account.print.journal relic
stock*: use stock.group_stock_user by default
survey: survey user can send invitations
mail: allow any employee to execute wizards
      additional verifications are made to ensure they are executed
      only on the documents the user has access to you
      give portal access to mail.compose.message as portal still does
      some actions like posting messages on the forum
      add ir.rule to avoid reading somebody else messages
      increase the query count because of undeterminist count
crm: saleman for lead2opp, manager for massmailing
     partner manager for actions linked to partners
     avoid a write in test_lead_lost
sms: any employee can send sms
mrp: mrp user can execute wizards
     give unlink access as making write during do_produce operation
base_import: employees can import files
delivery: stock user can deliver
event_sale: sale user can configure the wizards
	    event user inherit from  sale rights
gamification: employee can give badge
google_service: resolve FIXME
hr: add specific rights
    manager can set a plan according to group on button
    anyone who can write on an employee can register a departure
hr_expense: set rights based on buttons
hr_holidays: an approver can make a summary report
hr_recruitment: recruiter can refuse a candidate
hr_timesheet: can use the wizard if can create a timesheet
l10n_eu_service: managers can create fiscal positions
mass_mailing: same group as on mass.mailing.list
membership: accountant can create invoice from membership
payment: accountant can create a link
	 as the source is an account.move
	 keep the payment.acquirer.onboarding.wizard to system user
	 only as it is called during company configuration
point_of_sale: PoS manager only can use wizards
	       never create closing_balance_confirm_wizard records
product_expiry: stock user has rights on stock.picking
product_margin: access from accounting menus
repair: same rules as for above models
sale: set ir.rule for self wizard only
      add rule from model introduced in payment to add salesman group
sale_crm: saleman can create a quotation from a lead
sale_coupon: any saleman can generate coupon
	     add self ir.rule
sale_product_configurator: salesman can select product variants
snailmail: employee can send letters
website: designers can write on website
website_crm_partner_assign: same rule as group on action
website_sale: sale ACL as for payment.acquirer.onboarding.wizard
website_slides: anyone can send invitation

base: base.language.*: allow employee (cf lang_install)
      change.password.user: can not read change password wizard of
      other users
      test.*: no access is needed

Courtesy of Damien Bouvy, William Andre and Antoine Prieëls for review
of acl
2020-02-04 17:54:18 +01:00
Martin Trigaux b3d143761e [IMP] test_translation_import: stricter test
To be able to detect issues in .pot like at #41364 due to bad .pot
file (cf fix at #41650)

closes odoo/odoo#41778

Related: odoo/enterprise#7200
Original-signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
X-original-commit: ba39590b004655df55d5d182c4ad50caa7f583c1
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-12-12 09:23:35 +00:00
Martin Trigaux b175558ce7 [FIX] tools: no pollution during export translation
Before this commit, the export of translations was incorrect for code
and model translations:

For code translations, the field 'name' was used for the matching
while the _() method explicitly use None in the _get_source call to
only use the field 'src' for the search.

For model translations, the field 'res_id' was not used when searching
for a translation.
For instance, if a ir.model.fields did not have translated label,
exporting the translations was using the translations of the first
field having the same source.
While this could be convient during the import (to be discussed),
doing so in an export of translation is clearly an unexpected
side-effect.

closes odoo/odoo#40909

X-original-commit: 4534181f106cf5aa50c65c942c260eeec122d3d2
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-11-28 11:43:46 +00:00
Martin Trigaux 62d3675869 [IMP] tools: remove module_name parameter
It was misleading as only forced for translations of type 'code' but
for the other translations, it was retrieved from the imported file
(the comment in a .po file or column in a .csv)

This will allow another optimisation in the next commit, moving to a
TranslationModuleReader instance
2019-11-19 11:36:57 +01:00
Martin Trigaux ac63556e23 [IMP] base: explicitly pass parameters for translation methods
Instead of relying on the context content, pass explicit values for
overwrite and create_empty_translations
applu this to trans_load and trans_load_data
Adapt the test that was trying to create empty translations.
2019-11-19 10:37:07 +01:00
Martin Trigaux 49fbab5329 [IMP] base: split and deprecate load_lang
load_lang was a kind of hybrid method trying to active or creating a
language if not found. This was error prone.
Instead rely on two methods with clear purpose:
ResLang._create_lang(lang, lang_name=None)
  - create a new res.lang entry using the locale of the server
    return the res.lang record to match the API of _activate_lang

ResLang._active_lang(code)
  - activate the given code lang

Most of the time, _active_lang is what is expected

tools.trans_load_data and IrTranslation._load_module_terms no longer
activate the language if not active.
Loading the translations should be explicit on an activated language,
it is too error prone to silently activate/create a language if not
found.
Remove lang_name from trans_load_data as no longer needed.
2019-11-19 10:37:01 +01:00
Julien Castiaux 4f03a5f136 [FIX] *: remove old deprecated modules/functions
PEP-594 is deprecating a bunch of modules. As part of the cleanup, we
are also dealing with long deprecated modules, functions and aliases.

* `assert_` -> `assertTrue`
* `assertEquals` -> `assertEqual`
* `assertNotEquals` -> `assertNotEqual`
* `assertAlmostEquals` -> `assertAlmostEqual`
* `assertRaisesRegexp` -> `assertRaisesRegex`
* `assertRegexpMatches` -> `assertRegex`
* `base64.encodestring` -> `base64.encodebytes`
* `base64.decodestring` -> `base64.decodebytes`
* `inspect.getargspec` -> `inspect.signature`
* `inspect.formatargspec` -> `inspect.signature`
* `logging.warn` -> `logging.warning`

closes odoo/odoo#36863

Task: 2003936
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-09-17 11:36:42 +00:00
Martin TrigauxandRaphaël Collet 7593b887df [REF] fields: use ir.model.fields.selection
The selection values of a selection field are now stored in database in the
model ir.model.fields.selection

This will allow to have a modular approche on selections and each selection
is now linked to the module that declared it.
Previously to this change, the selections were linked to the field, meaning
uninstalling a module had no impact on the selections stored on database.

With this change, the selections will now be translated in the correct module
(having an external id) and the records having a used selection will now be
reset to null.

closes odoo/odoo#30228

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>


Co-authored-by: Raphaël Collet <rco@odoo.com>
2019-08-19 11:44:34 +00:00
Martin Trigaux 43d355c208 [IMP] base: better default for translation overwrite
FP request: hide the field from the view as too technical
MAT analysis: it should be true by default as most expected behaviour
(it was the reason why it was displayed in the first place)

closes odoo/odoo#35679

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-08-13 14:21:00 +00:00
Martin Trigaux 85ee046b37 [IMP] *: use res.lang methods
get_installed and _lang_get_id are both ormcached and correctly check
the context

Retrieving a res.lang from a code is a frequent action that can be
achieved with _lang_get (cf previous commit).
Using _lang_get ensure the active_test in the context is correct and
is not poluted with another context propagation issue.
odoo/odoo#35490 discussion is an example of bad context propagation

closes odoo/odoo#35504

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-08-07 13:06:17 +00:00
Martin Trigaux f4319580e5 [ADD] tools: lazy translation method
Introduces the method _lt

The translation method is now evaluated lazily.
It allows to declare global variables with translatable content

e.g. this code will now work:

LABEL = _lt("User")

def _compute_label(self):
    context = {'lang': self.partner_id.lang}
    self.user_label = LABEL
2019-08-01 12:39:56 +00:00
Hiral Bhavsar 3cd7ed07a2 [IMP] *: remove 'view_type' on window actions.
The old tree views don't really exist anymore, this odd pseudo-flag to
dispatch between "list" and "tree" tree views has no reason to remain.

Task 1937686

closes odoo/odoo#31243

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-17 11:34:17 +00:00
Martin Trigaux c5bb52f33e [FIX] test_translation_import: avoid selection clash
export.selection.withdefault and export.selection both have a selection field
with Foo and Bar as possible selections.
When doing
self.env["base.update.translations"].create({'lang': 'fr_FR'}).act_update()
the base.update.translations wizard exports the translations of ALL modules,
including the ones of the test_impex module.

The generate po entry is something like:

#. modules: test_impex, test_translation_import
#: selection:export.selection,value:0
#: selection:export.selection.withdefault,value:0
#: selection:test.translation.import,import_type:0
msgid "Bar"
msgstr "Bar in french"

but may also be

#. modules: test_translation_import, test_impex
#: selection:export.selection,value:0
#: selection:export.selection.withdefault,value:0
#: selection:test.translation.import,import_type:0
msgid "Bar"
msgstr "Bar in french"

(not sure where the indeterminism comes from)

which creates 3 translation entries that are sometimes linked to the module
test_impex (ignored when exporting the translations of test_translation_import)
but are sometimes linked to the module test_translation_import instead

In the second case, this makes 3 more translations that is was supposed to
exist.

This commit hides the symptom by making sure there is no longer a clash
when exporting the translations of the module test_translation_import.
A real fix to avoid creating unnecessary translations during an execution of
the base.update.translations wizard must also be made in the future.

It is assumed the unnecessary translations problem was already present before
a7621137cb but polib introduced the indeterminism
making the test fails from time to time.

closes odoo/odoo#33958

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-06-06 14:10:08 +00:00
Martin Trigaux 376f7983b0 [IMP] test_translation_import: reexport the .pot file
To be sure it is synchronized with the reality to make the maintenance easier
2019-06-05 09:44:11 +00:00
Martin Trigaux 632fa044c3 [IMP] tools: remove custom pofile reader
Use polib library that handles this correctly
The complexity of the parser is moved to the library
2019-06-05 09:44:11 +00:00
Christophe Simonis 2a06f4dcf3 [MERGE] forward port branch 12.0 up to 09fb2469b4 2019-03-29 18:10:57 +01:00
Martin Trigaux c9d01b136f [ADD] test_translation_import: add new test
This test also fails before the module extraction commit as the code
translations like the one for 'Ijkl' have no 'module' value during the reimport
and are ignored by the following search

closes odoo/odoo#32022

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-03-29 14:50:56 +00:00
Martin TrigauxandRaphael Collet 257ccdf83c [FIX] tools: extract module from po file
When a single po file is processed (i.e. direct po import, not read from a i18n
directory inside a module), there was no module information on code translations

The module information is important for web translations where the list of
modules is given in the call to the route '/website/translations' and
'/web/webclient/translations' and only the web translations of these specific
modules is retrieved and used.

To manually import the translations of a custom module (e.g. openerp_enterprise),
the base.language.import wizard is typically used and the give .po file is
directly imported.
For model and model_terms, the module information is easily deducted from the
the record external id (<module>.<reference>) but for code translation, we
relied on the global variable module_name.

The .po file do contain the module information but this information was ignored.
Real example:

  #. module: openerp_enterprise
  #. openerp-web
  #: code:addons/openerp_enterprise/static/src/js/odoo_enterprise_start_trial.js:249
  #, python-format
  msgid "Please choose your domain name"
  msgstr "Veuillez choisir votre nom de domaine"

Before this commit, the above translation was imported without the module and
was not retrieved in the '/website/translations' call on the /trial page

The global module_name is still used when set for backward compatibility.

Co-authored-by: Raphael Collet <rco@odoo.com>
2019-03-29 14:48:57 +00:00
Nicolas Lempereur ed99544dfa [FIX] translate.py: really generate missing terms
With 12.0's (#28297) empty translations were no longer added by default
with the idea that if needed the "Generate Missing Terms" wizard should
be used.

But that wizard itself used what was modified so also did not added
empty translation.

With this changeset, empty translations are added when using the
"Generate Missing Terms" wizard.

fixes #29184
closes #30037
2019-01-09 15:00:43 +00:00
Nicolas Lempereur 233bae7de9 [FIX] translate.py: fallback on base lang if noterm
When there is a language and its base language translation files in a
module, in 12.0 an empty translation in the language translation file
will not fallback on the base language.

eg.

 fr.po : {'one': 'un', 'seventy': 'soixante-dix'}
 fr_BE.po: {'one': '', 'seventy': 'septante'}

 => the translation in fr_BE will be {'one': '', 'seventy': 'septante'}

 but before 7288b477 it would have been {'one': 'un', 'seventy': 'septante'}

With this commit, an empty translation is no longer created so does not
override base language.

Also the intention of d84b795b0a that was also lost is restored by
upserting only noupdate==false translation, and inserting the other
ones.

opw-1904638
closes #28297
2018-11-07 09:07:02 +00:00
Christophe Simonis 43b63a0465 [MERGE] forward port branch saas-11.4 up to 57e387b645 2018-10-01 16:01:54 +02:00
Yannick Tivisse c67ac34ee4 [IMP] base: Add missing _description on models 2018-09-21 16:13:59 +02:00
Martin Trigaux 1421949c67 [FIX] tools: import translation file without pot
Due to fccfd36 and 4ba7fbb the translations were only imported, considering the
.pot as the reference.

During import or a manual csv or po file, there is no pot file.

Add tests with Klingon and Dothraki

Fixes #27044
2018-09-18 18:02:19 +02:00
Martin Trigaux 4ba7fbbf81 [FIX] tools: use pot as reference file
In the first attempt at #26134, the pot_targets was cleared after creating
the pot_rows object.

Since the rows not present in the pot_targets are now skipped, clearing the pot
should not be done.

Still use a temporary list pot_rows to avoid modifying the list we are iterating
on.

Update the .po test file to match the new file format

Closes #26881
2018-09-11 09:16:59 +02:00
Christophe Simonis 1884c71245 [FIX] test_translation_import: correct test and add required i18n files ignored during forward-port 2018-09-07 12:06:24 +02:00
Christophe Simonis f19e6ce561 [MERGE] forward port branch 11.0 up to 213759b03e 2018-09-05 18:52:27 +02:00
Martin Trigaux 5700f960d4 [ADD] test_translation_import: new duplication test
To make sure what was corrected is tested
2018-09-03 11:02:56 +02:00
Martin Trigaux e656a350a6 [FIX] test_translation_import: correct test
Now that it is tested, actually correct it
2018-09-03 11:02:56 +02:00
Martin Trigaux a9cd97f58e [MOV] tests: move test to be executed
The test was in a folder not checked by the runbot
The test, as it, is actually failing and it will be corrected in the next commit
2018-09-03 11:02:55 +02:00