Commit Graph
384 Commits
Author SHA1 Message Date
Thomas Lefebvre (thle) 5fe2866cc4 [FIX] base_automation: differentiate between creating and writing
Steps to reproduce:
-------------------
[A] Create an automated action with:
- Model: Tasks (project.task)
- Trigger: On save
- When updating: ID (to mimic "on_create" trigger)
- Execute code:
```py
record.message_post(body="This is a message from automated action (fields triggers: ['id'])")
```

[B] Create a server action (contextual action) with:
- Type: execute code
- Model: Tasks (project.task)
- code:
```py
record.write({})
```

[C] Test:
- create a new task --> message has been posted (OK)
- write some values on the task --> no message has been posted (OK)
- run the server action --> message has been posted (KO)

Issue:
------
No message should be posted as the ID field has not been modified.

Cause:
------
`if not self._context.get('old_values')` is considered as `True`
because we have an empty dict.
In fact, when we make a write on a record, old_values will be always a dict.

```py
old_values = {
    old_vals.pop('id'): old_vals
    for old_vals in (records.read(list(vals)) if vals else [])
}
```

Solution:
---------
Old values are not defined in the context during a create.
We can compare `self._context.get('old_values')` with `None`
to differentiate between creating and writing on records.

opw-3736068

closes odoo/odoo#155832

Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2024-04-16 14:12:46 +00:00
Odoo Translation Bot a19537ea69 [I18N] Update translation terms from Transifex 2024-04-07 00:08:33 +02:00
Odoo Translation Bot 684745f5de [I18N] Update translation terms from Transifex 2024-03-31 00:09:16 +01:00
Odoo Translation Bot 395140671f [I18N] Update translation terms from Transifex 2024-03-24 00:12:07 +01:00
Raphael ColletandNasreddin Boulif 89d259c65d [FIX] base_automation: double trigger caused by computed field
Imagine the following situation: an automated action A is triggered when
some stored computed field F has a certain value.  When a record is
created and no value is given for field F, then the automated action A
may be run twice: once when evaluating A's domain forces the computation
of F, and once again because A's domain is satisfied.

The implementation already uses context flags to reflect which automated
actions have already been run, in order to avoid automated actions to be
run recursively.  The fix consists in enabling those context flags to be
shared among the evaluation of the domain and processing of the
automated actions.

opw-3731182

closes odoo/odoo#157272

Signed-off-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Nasreddin Boulif (bon) <bon@odoo.com>
2024-03-22 11:20:04 +00:00
Odoo Translation Bot c4bc200b47 [I18N] Update translation terms from Transifex 2024-03-17 00:11:43 +01:00
Odoo Translation Bot 1b9fd01d46 [I18N] Update translation terms from Transifex 2024-03-10 00:13:03 +01:00
Mattis Megevand (mmeg) 5fc24f84ea [FIX] base_automation: allow multiple automation rules for same trigger
Steps to reproduce:
- Install base_automation_hr_contract and helpdesk
- Setup two automation rules with model "Helpdesk Ticket" and "On
  incoming message" as trigger
- Create a ticket in helpdesk

Issues:
Traceback is shown because `_message_post` doesn't have the origin
attributes. This is due to the closure being wrong as explained here: https://github.com/odoo/odoo/blob/e2ad568e6cd4de2d721149eb76d04f58c8510191/addons/base_automation/models/base_automation.py#L686-L691

Solution:
Encapsulate the `_message_post` function definition, so that each times
we patch message_post we patch it with a new function.
This wasn't the case before since `_message_post` wasn't isolated.
This solution is similar to the other method patched.
https://github.com/odoo/odoo/blob/e2ad568e6cd4de2d721149eb76d04f58c8510191/addons/base_automation/models/base_automation.py#L711-L734

opw-3758851

closes odoo/odoo#155596

Signed-off-by: Raphael Collet <rco@odoo.com>
2024-03-06 14:30:38 +00:00
Odoo Translation Bot cb45934163 [I18N] Update translation terms from Transifex 2024-03-03 00:09:56 +01:00
Odoo Translation Bot 4f4ca50e8d [I18N] Update translation terms from Transifex 2024-02-25 00:13:04 +01:00
Odoo Translation Bot 1cf48deef9 [I18N] Update translation terms from Transifex 2024-02-18 00:12:23 +01:00
Odoo Translation Bot dd40867949 [I18N] Update translation terms from Transifex 2024-02-11 00:14:17 +01:00
Gaetan Vanden Bergh (gavb) 17973e473f [FIX] base_automation: wrong arguments order
Steps:
- Create an automation rule with a model X
- Delete model X (need a way that keep the rule)

Actual result:
- Crash due to warning message

Expected result:
- Warning message is logged without issue

opw-3722953

closes odoo/odoo#153078

Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2024-02-09 11:57:27 +00:00
Tiffany Chang (tic) 94c58407f6 [I18N] *: add in Russian translations
For a first iteration, Russian translations were done using DeepL using
1 large .pot file of all the standard modules to translate (e.g. no
localizations, no test modules, etc). Unfortunately for some reason
doing a msgmerge with the existing ru.po files didn't seem to work, so
old "Translators" metadata at top of files were lost (maybe they will be
re-added during next Transifex sync?)

Part-of: odoo/odoo#152285
2024-02-06 18:49:02 +00:00
Odoo Translation Bot c95419af44 [I18N] Update translation terms from Transifex 2024-02-04 00:11:05 +01:00
Aaron Bohy bc800ae093 [FIX] (test_)base_automation: clear cache for on_change rules
Create an automation rule for a field for which there's no onchange
yet. The rule type is "on_change" (on UI change).

This type of automation rule adds an onchange method on the
selected fields, which thus involve the onchange mecanism: the
"on_change" attribute will be set on that field nodes in views,
s.t. when the user changes it, onchange rpcs are done.

However, views are cached, and creating such a rule didn't clear
the cache. So if the view was already in cache, the rule seemed
not to work, because the client still received the old version of
the view, without the "on_change" attribute.

This commit clears the cache when such a rule is created, s.t.
after a client reload, the feature gets enabled as expected.

opw 3701125

closes odoo/odoo#152498

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2024-02-03 06:59:49 +00:00
Odoo Translation Bot 625dac5a10 [I18N] Update translation terms from Transifex 2024-01-28 00:16:34 +01:00
Odoo Translation Bot 95a4b6dfdc [I18N] Update translation terms from Transifex 2024-01-21 00:17:03 +01:00
bve-odoo 72c1a4f96a [IMP] *: replace type where possible
do not compare types, for exact checks use `is` / `is not`,
for instance checks use `isinstance()`Flake8(E721)

Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2023-11-07 17:09:34 +00:00
Odoo Translation Bot b81790505b [I18N] Update translation terms from Transifex 2024-01-14 00:16:26 +01:00
Odoo Translation Bot 0e23020b84 [I18N] Update translation terms from Transifex 2024-01-07 00:23:19 +01:00
Damien Bouvy 897296208f [FIX] base_automation: avoid key error when trying to return a warning
Before the refactoring introduced at 0a744ac, it was possible to return
a warning from a `code`-type base automation with the `action` variable:
```py
if len(record.name) > 20:
    action = {
        "warning": {
            "title": "Name too long",
	    "message": "The name of the record is too long",
	}
    }
```

This would trigger a visual dialog with the title and message in the
client.

Due to a louche `+=` operator change in the refacto, this kind of
automation raises a key error on the server, as the additive part of
the operator will try to access the 'warning' key in the result dict,
which may not (and usually will not) exist.

I assume this was done in an attempt to 'accumulate' warnings, but the
warnings in questions are dict that are not really additive anyway.
Better to support the *last* returned warning rather than none at all.

This commit basically returns to the previous situation for onchange
warnings.

closes odoo/odoo#148140

Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
2024-01-04 18:17:34 +00:00
Odoo Translation Bot ad35458e8b [I18N] Update translation terms from Transifex 2023-12-31 00:18:24 +01:00
Odoo Translation Bot 50e8e08183 [I18N] Update translation terms from Transifex 2023-12-24 00:18:24 +01:00
Aaron Bohy b3ddb46aab [FIX] base_automation: correctly trigger on_change rules
Before this commit, and since [1], automated rules of type
"on_change" (i.e. on UI update) didn't run. This is because the wrong
field (trigger_field_ids) was used to record fields for which the
rule must be triggered. For that type of rule, the field to use is
on_change_field_ids. As a consequence, those rules were not
correctly created, and thus they didn't properly react to field
changes.

[1] odoo/odoo@8bdac7e26c

opw 3632084
opw 3595411

closes odoo/odoo#146780

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-12-19 16:19:43 +00:00
Yannick Tivisse a8e010c7b5 [FIX] hr_holidays: Make tests demo data independent
Part-of: odoo/odoo#146649
2023-12-18 23:32:05 +00:00
Yannick Tivisse 0f447989d1 [FIX] base_automation: Make tests demo data independent
Part-of: odoo/odoo#146649
2023-12-18 23:32:05 +00:00
Odoo Translation Bot 304a6caa14 [I18N] Update translation terms from Transifex 2023-12-17 00:08:26 +01:00
Lucas Perais 3e4d889749 [FIX] base_automation: webhooks send and receive work together
Before this commit, the sending webhook did not work well naturally
with the receiving end.

After this commit, it does since default values on base_automation have been adapted.

closes odoo/odoo#142710

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-12-15 08:44:19 +00:00
Lucas Perais 51077cc514 [FIX] base_automation: webhooks: put the request payload in eval_context
Set a webhook that executes a ir.actions.server of type python code.

Before this commit, the code had no access to any request's parameters. This was a limitation
in the basic flows that the feature is supposed to support.

After this commit, we pass in the context a key "payload" that contains a copy of the request parameters.

task-id-3599629

Part-of: odoo/odoo#142710
2023-12-15 08:44:19 +00:00
Odoo Translation Bot 8ab45d4a85 [I18N] Update translation terms from Transifex 2023-12-10 00:12:46 +01:00
nda eb11df17a7 [FIX] base_automation: allow more than one trigger fields
Before this commit:
If you select more than one trigger field on base.automation:

File "/home/odoo/src/odoo/17.0/addons/base_automation/models/base_automation.py", line 302, in _compute_trg_field_ref__model_and_display_names
relation = automation.trigger_field_ids.relation
File "/home/odoo/src/odoo/17.0/odoo/fields.py", line 1146, in __get__
record.ensure_one()
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 5819, in ensure_one
raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: ir.model.fields(<NewId origin=3241>, <NewId origin=3238>)

After this commit:
trg_field_ref_model_name and trg_field_ref_display_name are only used for the
base_automation_trigger_reference widget, which is only used when trigger in
['on_stage_set', 'on_tag_set']. We only need to compute them in this case,
and there will be no errors since they use only one trigger field.

opw-3607314

closes odoo/odoo#144810

Signed-off-by: Florent Dardenne (dafl) <dafl@odoo.com>
2023-12-05 19:53:34 +00:00
Sébastien Theys 5455bfcfdc [FIX] mail: fix test failing at "Write something in composer"
The issue is not easy to reproduce, so the fix is not a guaranteed one.

Estimation: the click on the "send message" buttons happens too early,
and it is either doing nothing, or being immediately reset by another
action that happens at page load.

Adding a little bit of extra delay (in particular waiting for messages
to be loaded) might resolve the issue.

Also back-port code allowing to use contains in tours.

runbot-27847

closes odoo/odoo#144435

X-original-commit: 3b261b6856e935f8fe9d4e23cfddc09df8ff7fdf
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-12-04 17:47:31 +00:00
Odoo Translation Bot 2ac98dc2e5 [I18N] Update translation terms from Transifex 2023-12-03 00:18:54 +01:00
Sébastien Theys 8a99a9d281 [FIX] mail, base_automation: fix composer tour without demo
runbot-26628

closes odoo/odoo#144402

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-12-01 18:14:17 +00:00
Odoo Translation Bot 3ffba892de [I18N] Update translation terms from Transifex 2023-11-26 00:20:02 +01:00
Odoo Translation Bot f6fe982853 [I18N] Update translation terms from Transifex 2023-11-19 00:28:08 +01:00
Odoo Translation Bot b61c1ac0b3 [I18N] Update translation terms from Transifex 2023-11-12 00:21:23 +01:00
Odoo Translation Bot 593ac17031 [I18N] Update translation terms from Transifex 2023-11-09 11:30:34 +01:00
Louis (wil) 68b4dfc2bb [I18N] *: import translations
closes odoo/odoo#141655

Related: odoo/enterprise#50484
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2023-11-08 20:48:14 +00:00
Odoo Translation Bot 5d2bc9e9b3 [I18N] Update translation terms from Transifex 2023-11-05 00:21:55 +01:00
Louis (wil) 548198ed2b [FIX] base_automation, website_sale_wishlist: correct typos
Corrects typos found when translating Odoo 17.

closes odoo/odoo#140627

Related: odoo/enterprise#49981
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2023-11-03 16:43:31 +00:00
Odoo Translation Bot 6739c317d1 [I18N] Update translation terms from Transifex 2023-10-29 00:07:17 +02:00
Lucas Perais d04ca8fa60 [FIX] base_automation: fix check and execute time based
Before this commit, the ir.cron "Automation Rules: check and execute" crashed
because the "_check" method used get_eval_context where it shouldn't

This is due to b846d1ebe9, which makes _get_eval_context a record's
method, not a model one.

closes odoo/odoo#140153

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-10-27 23:44:52 +00:00
Louis (wil) 3f6f949fa5 [I18N] export sources
closes odoo/odoo#140002

Related: odoo/enterprise#49687
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2023-10-27 08:36:16 +00:00
Damien Bouvy b020a0276c [IMP] base_automation: add dependency on sms
Since server actions names are computed automatically when (and only
when) they are linked to an automation, not having a dependency at all
between `sms` and `base_automation` meant that we would have either needed
a link module or an ugly `_fields` introspection to correctly name server
actions that send SMSes created through automation rules.

Since `sms` is a rather basic module which has very little impact on the
UI and no impact on pricing, it makes sense to add it to the list of
dependencies of base_automation instead, similarly to `mail`.

Task-3450200

closes odoo/odoo#138804

Related: odoo/enterprise#48987
Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
2023-10-26 13:41:07 +00:00
Damien Bouvy b4c63eb0ab [IMP] base_automation: adapt views to boolean update
Changes to the UX of boolean field updates via server actions
required some adaptations of the views of base_automation.

Task-3450200

Part-of: odoo/odoo#138804
2023-10-26 13:41:07 +00:00
Damien Bouvy f11d98ce7d [IMP] base_automation: default record_getter matches default webhook payload
The goal of this commit is to make it simpler for users to match an
incoming Odoo webhook automation rules with an outgoing webhook action
from another Odoo by having a default record_getter that uses the same
syntax as the default payload of a webhook action.

Task-3450200

Part-of: odoo/odoo#138804
2023-10-26 13:41:07 +00:00
Damien Bouvy 82b00574f6 [IMP] base_automation: allow users to keep notes about their automations
Task-3450200

Part-of: odoo/odoo#138804
2023-10-26 13:41:07 +00:00
Damien Bouvy 28260dc234 [FIX] base_automation: prevent crash in m2o_ref because of unset model
Task-3450200

Part-of: odoo/odoo#138804
2023-10-26 13:41:07 +00:00