Commit Graph
34 Commits
Author SHA1 Message Date
Louis Wicket (wil) 9afe7c74c9 [IMP] *: remove "French spacing" 👺
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.

The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.

closes odoo/odoo#114533

Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-14 15:52:10 +01:00
Arnaud Joset e01352f806 [FIX] google_calendar: fix logging parameters
Before this commit, _do_request can either receive json or dict as parameters.
requests.request param value can also be a string or a dict.

When the params is a string, the code tries to copy it with the copy method
which is only available on the dict, resulting in an error.

TaskId-2999194

X-original-commit: 75f889ca013d41939c669f07035e39d056d581d7
Part-of: odoo/odoo#101492
2022-09-28 20:29:50 +02:00
Jeremy Kersten 05b409f8f1 [REF] google_account, google_calendar: clean and make it overridable
This commit removes outdated method no more used since we delete oog
apps like gdrive.
This commit remove the logging of sensitive infos.
This commit allows to override easily api key.

task-2497212
pr-95744

Part-of: odoo/odoo#95744
2022-08-10 14:43:01 +02:00
std-odoo e9f712278d [IMP] microsoft_outlook, fetchmail_outlook *: improve usability
* fetchmail, google_gmail, fetchmail_gmail

Purpose
=======
Improve the usability of the outlook modules.

Specifications
==============
Remove the checkbox "Use Outlook" and instead use the
smtp_authentication and the server_type, to be consistent with Gmail.

Hide the password field for Outlook / Gmail mail servers.

Add constraints on the outgoing mail server to force the user to use
the right configuration (e.g. the from_filter, so the sending does not
fail).

Add an option in the mail module to install Outlook.

Show a message for the outgoing mail servers to explain each
authentication methods.

Task-2811567

Part-of: odoo/odoo#88215
2022-07-12 15:36:50 +02:00
qmo-odoo 04e86613c8 [ADD] {google,fetchmail}_gmail: OAuth for gmail servers
Purpose
=======
Less secured apps are no longer supported by google, therefore, we need
to transition to the OAuth2 authentication system.

Specifications
==============
1. User will need to fill their Gmail API credentials in the main
   settings page
2. Then, in the incoming / outgoing mail server form view, they will
   need to tick the Gmail support checkbox
3. A link will be available to be redirected to Gmail and accept the
   permission
4. The user can now copy / paste the authorization code in Odoo, set
   his email as "login" and then send / receive emails with Gmail

Task-2170676

closes odoo/odoo#83424

X-original-commit: ff223afc5300b2421b8ce935bb468f503c938c5d
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-01-27 09:12:50 +00:00
Thibault Francois e564b0d8da [FIX] google_(account|calendar): Concurrent Synchro
Each time the calendar view of event.calendar is loaded,
the synchronization with google calendar was launched
and if a user open many tabs, it can lead to deadlock

Solution: Check for lock before launching the synchro,
if the transaction cannot acquire the lock, it's proably
because another synchro already started

closes odoo/odoo#69540

X-original-commit: 101598fae6fc32a49bb6d422a82b621a81201cb5
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-04-20 12:23:10 +00:00
Thibault Francois 30f4be4889 [FIX] (google|microsoft)_calendar: make sync more resilient
Issue
-----
- Currently the cron can take too much time and timeout.
  In case of timeout process data are rollback.
  The sync per user also crash and stop the process for all user and make
  the transaction rollback

  In both case we cannot ensure that all user will end up synchronized

- The real time sync can end up in deadlock:
  If you create a holiday, it trigger a write on the user and the
  creation of an event that will be synchronize with google

  The synchronization may ask for a new token if this request fail
  a new cursor is create to empty on the user the refresh token.
  2 cursor that are trying to write on the same record => Deadlock

- Bad refresh token management
  When the refresh token is not anymore valid it's erased but
  the calendar_token and validity are kept. Is odoo consider
  the token valid it will try to sync an event with google|microsoft
  despite the refresh token is not valid anymore. Of course this lead to
  an error and the impossibility to create an event anymore without
  manually wiping the calendar_token and calendar_token_validity

- Error 401 are handled in context manager
(google|microsoft)_calendar_token, but get_*_calendar_token never raise
http error only user error.

Solution
---------

- Improve cron resilience
	- Commit between each user and rollback in case of issue for a user
	- Solve the issue when stop < start
        - Solve issue with rrule not being the first element in the list
          of recurrence
	- Improve perf when searching for organizer
	- In order to limit the volume during the first synchronization, we only
	synchronized event from x days in the past to x days in the future with
	x = 365 by default
	- Limit the number of event to synchronize to google each time to 200,
	since this operation is time consuming (1 request is sent per event)

- Avoid deadlock
  A new cursor is not needed, we only need to ensure that write on the
  user is done with a clean cursor and will be commited despite the error
  raise. So rollabck before the write and commit explicitly afterwards

- Erase properly all the token and the token validity if the refresh token is not valid anymore
	- For google calendar, erase also the token in case of 401
          error: Wrong client id, this mean the database parameter have been
          change and all the user should reconfigure the synchronization

- Directly handle error 401 with error 400 in refresh_token method

closes odoo/odoo#66250

X-original-commit: 486f69abad6226e5ce016ad89a0eeb103d709a3f
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-03-25 09:55:10 +00:00
Yannick Tivisse 1a9be3a869 [REF] calendar: Lint + Clean code 2020-04-09 10:59:34 +02:00
Lucas Lefèvre ae3d37c201 [REF] google_calendar: Refactor synchronisation
This commit refactors calendar synchronization between Odoo and Google after the
main calendar application refactoring.

This refactoring takes advantage of two new features from the Google API:

- New way of synchronizing resources efficiently[1]
Incremental sync is performed repeatedly and updates Odoo with all the changes that
happened ever since the previous sync. Each time, Odoo provides the previous sync
token it obtained from Google and stores the new sync token from the response.

- Event metadata[2]
Ability to set hidden key-value pairs with an event, called extended properties.
These extended properties are used to store the related odoo event id and the Odoo
owner id (see known limitations)

Known limitations
=================
- Let A and B be two new users (no tokens available). A creates an event in Odoo and
invites B. A is the owner of the event (user_id). Now B authenticates to his Google Calendar
account and synchronizes his calendar. We cannot send the event to A's calendar since we
don't have any access to his Google Calendar. Hence the event his sent to B's calendar.
This leads to data de-synchronisation: The owner is A in Odoo but B in Google.
The "real" owner (user A) is stored in the Google event's metadata to be able to
reconcile the owner for following synchronizations.

- Let A and B be two users of Odoo and Google Calendar. And let the Google Calendar of B
be private (e.g. if A creates an event in Google Calendar and invites B, B won't see the
event in his calendar). If A creates an event in Odoo and invites B. The event is synced
to Google Calendar of A. Now B can see the event in Odoo but he can't see it in his
Google Calendar.

Task 2126717
PR #42031
PR Enterprise odoo/enterprise#8006

[1] https://developers.google.com/calendar/v3/sync
[2] https://developers.google.com/calendar/extended-properties
2020-04-09 10:59:33 +02: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
jev-odoo b4587e9553 [FIX] google_account: no access error when token refresh fails
Before this fix, when a refresh of the google token was triggered
and error 400 where returned, if the user did not have write rights
on res_users, an access rights was raised

Now, the write is done and the real error is raised for the client.

Part of OPW-2123045 (needed to further investigations)

closes odoo/odoo#41777

X-original-commit: b4f794c55bdfbf2a5482b7ee30780fdef8d4978f
Signed-off-by: Richard Mathot (rim) <rim@openerp.com>
2019-12-10 14:47:32 +00:00
Julien Castiaux 67c281c6a8 [FIX] google_account: use HTTPError over UserError
In an attempt to ease the error reporting, some Google Error were raised
as UserError so they are shown on screen and the user can take immediate
action when the error is their side.

As shown by the different commits bellow, the introduced changes had
some bad side effects. Empty request body, empty response body, non-json
response. The resulting code got complicated.

Apart from the Google API itself, some Odoo module (i.e.
google_calendar) excepted HTTPErrors on some endpoints that are now
raised as incompatible UserErrors. There are no straightforward
solutions for those endpoints.

This commit reverts:
- da13c704
- 9c369a44
- 85ab9238

opw-2000950

closes odoo/odoo#34532

Signed-off-by: Richard Mathot (rim) <rim@openerp.com>
2019-07-02 14:55:41 +00:00
Julien Castiaux 85ab9238c5 [FIX] google_account: improve logging of errors
There is no guaranty that both the request body and the response body
will contain JSON data. This fix corrects the logging by printing the
raw text in case of json decode error.

opw-2006561
opw-2024242

closes odoo/odoo#34221

Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2019-06-19 09:12:27 +00:00
Julien Castiaux 9c369a4485 [FIX] google_account: log error message on screen
Include the Google Error message in the error message showed on screen.

Fine tuning of da13c70484 : missing transiflex translations, empty body,
wrong string format.

opw-1966309

closes odoo/odoo#33216

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-05-16 09:51:41 +00:00
Julien Castiaux da13c70484 [FIX] google_account: error type on wrong request
Configure google to be synchronized with Odoo, create a contact with a
wrong email address (I used `foo@.test.`), create an event in the
calendar, add the contact as attendee, sync with google. Traceback.

The traceback is a `request.exception.HTTPError` reraise by
`_do_request` in the `google.service` model on several HTTP errors, 400
amoung them. The real error is "Invalid attendee email." but the
information is lost in the error message.

The error hanlding has been rethink so it raise a user friendly error
via the UserError modal with just the error message sent by the Google
API. The logged error has been rethink to pretty print both the request
and the response.

opw-1974295

closes odoo/odoo#33058

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-05-06 12:47:04 +00:00
Nimesh Jethva 2c1549cc59 [IMP]tools, technial modules: Improvement in model description
Purpose of this commit is to give description more "business oriented"
because those descriptions appears in Odoo Studio which is supposed to be used by end users, not only by developers.

Related Task ID : 37311
2018-09-21 11:45:15 +02:00
Benjamin Stiens 6383120f3b [IMP] all: Improve error messages
Many error messages are misleading or too "vague"
This task aims to improve all error message.

Task #47042
PR #23321
2018-05-28 16:45:48 +02:00
Nicolas Lempereur a6a6cf8005 [FIX] google_account: typo python3 from 01e35141
The typo caused a traceback instead of an error message.

opw-801237
closes #21790
2017-12-21 15:35:41 +01:00
Nicolas Lempereur b1886ef60e [FIX] google_{account,calendar}: typo PY3 01e35141
When an error happen (which may have been intended as such and ignored
down the error pipeline) in google_account/google_calendar there was
some typos that tracebacked.

opw-783271
closes #21263
2017-12-06 12:40:41 +01:00
Christophe Simonis 30bd5ac0e9 [MERGE] forward port branch saas-16 up to aec6248bb3 2017-08-23 16:44:58 +02:00
Christophe Simonis 59f8b849fb [MERGE] forward port branch saas-15 up to d5f2a38b50 2017-08-23 11:23:08 +02:00
Christophe Simonis 6956ad54de [MERGE] forward port branch 10.0 up to 6dc0f31415 2017-08-22 16:45:43 +02:00
Christophe Simonis 6dc0f31415 [MERGE] forward port branch saas-11 up to 92ec666f8d 2017-08-22 16:28:10 +02:00
Christophe Simonis e68da600de [MERGE] forward port branch 9.0 up to caf78d22e1 2017-08-22 13:55:05 +02:00
Christophe Simonis 6f3eada2c3 [MERGE] forward port branch saas-15 up to f687a27b79 2017-06-06 19:23:03 +02:00
Olivier Dony de38d0262b [MERGE] Forward-port 10.0 up to 76cd8d2558 2017-06-03 01:24:21 +02:00
Wolfgang Taferner c444b5a293 [FIX] google_account: fix google request exception management
Error thrown by google request is an urllib2.HTTPError that can be read
and loaded in JSON. However in some cases the result of the read may
be void or not JSON-ready. This was causing a crash in the error
management and hid the actual issue.

This commit tries to read and JSON-load the error but fall back on
simply displaying the raw error in case of issue when handling it.

Closes #17308 .
2017-06-01 11:28:43 +02:00
Xavier Morel 01e3514147 [FIX] P3: urllib, urllib2 and urlparse
In Python 3, all of these were "consolidated" under urllib(.request,
.parse, .errors) which is inconvenient.

Since we already have hard dependencies on requests and
werkzeug(.urls, which is a backport of Python 3's unicode-aware
urllib.parse) migrate *everything* to that.

A sticking point is urllib2.URLError, those were (mostly) replaced by
the slightly more general IOError which URLError extends.
2017-05-15 12:26:30 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Xavier Morel 3979f6802e [#8530] convert exception handlers to except..as syntax
Futurize fixers:
* lib2to3.fixes.fix_except
2017-04-11 14:53:29 +02:00
Raphael Collet d0ca2d115e [REF] ir_config_parameter: remove group_ids and simplify
Add `sudo()` to call `get_param` where necessary, and make the web client use a
controller instead of directly accessing parameters.
2017-01-03 16:52:49 +01:00
Jérome Maes c5baaa3bdc [REF] google_account : code cleaning
- remove unused helpers
- add command in case of deeper refactoring one day ...
- better variable naming
- use contants for Google services urls
- add docstrings
2016-04-27 16:35:45 +02:00
Deep Bundela 3e1fb87e93 [MIG] google_account: migrate into new API 2016-04-27 16:35:45 +02:00
Deep Bundela 65ec248883 [MOV] google_account: restructure module directory 2016-04-27 16:35:45 +02:00