summaryrefslogtreecommitdiff
path: root/addons/website_form/controllers/main.py
AgeCommit message (Collapse)Author
2021-04-27[FIX] website_form: cancel records creation if errorAdrien Widart
When running an automated action on record creation, if the action raises a UserError/ValidationError, the record will still be created. To reproduce the error: (Need website_crm,base_automation. Enable debug mode) 1. Create an Automated Action - Model: Lead/Opportunity - Trigger: On Creation & Update - Trigger Fields: Phone (crm.lead) - Action To Do: Execute Python Code - Python Code: ```python if record.phone: raise UserError("Lorem ipsum") ``` 2. On website, add a website form WF - Action: "Create an Opportunity" 3. Complete and submit WF including a phone number Error: An error message is displayed ("Lorem ispum"). However, the lead has been created and is present in CRM Pipeline. An on-creation automated action is executed once the record is executed, but nothing will cancel this records creation if the action raises a UserError/ValidationError. OPW-2423948 closes odoo/odoo#69477 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-02-26[FIX] website_form: display attachment on form web pageAdrien Widart
When submitting a ticket, if the user adds an attachement, he will not be able to see it on the ticket web page. To reproduce the error: (Need helpdesk,contacts) 1. Go to the settings of a Helpdesk Team (e.g., "Customer Care") 2. Enable "Website Form", Refresh 3. Go on Helpdesk web page and Publish the form 4. Create a partner P and grant him the portal access 5. Sign in with P 6. Submit a ticket with one attachment 7. Consult the ticket's web page Error: in "Message and communication history", OdooBot's message with the attachment is not displayed. However, when consulting the same page with the admin account, this message is considered as "Published". Thus, P should see the message and the attachment. When getting the messages, if the user is not an employee, the domain is restricted: https://github.com/odoo/odoo/blob/e92ac60a75462dfd830254a3d0dd5d7effe1528e/addons/portal/controllers/mail.py#L128-L130 with https://github.com/odoo/odoo/blob/cc32b7d1b396a42dd4575c681ceb422f99b6015a/addons/portal/models/mail_message.py#L30-L32 Problem is that, when creating the message with the attachement, `subtype_id` is not defined. OPW-2440069 closes odoo/odoo#66899 X-original-commit: b05a72d3cc181c601807b5e633766d504e06bb3a Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-01-04[FIX] website_form: prevent adding lang prefix to form action urlIvan Yelizariev
STEPS: * create fresh db with default lang fr_CH * install website * activate additional language, e.g. en_GB * set for website only one available language: fr_CH * for admin user set lang en_GB * open website and add form BEFORE: the form doesn't work, because action url is "/en_GB/website_form/" AFTER: action url is not changed WHY: 1. ``is_multilang_url`` returns ``True``, because there is no route ``/website_form/`` https://github.com/odoo/odoo/blob/0adcb9a09fe5714fe8479df9450ddcefa7ba0688/addons/http_routing/models/ir_http.py#L233-L244 2. Model name in action is added after rendering only, this is why ``is_multilang_url`` is called with ``/website_form/`` and not real url https://github.com/odoo/odoo/blob/0adcb9a09fe5714fe8479df9450ddcefa7ba0688/addons/website_form/static/src/js/website_form.js#L144 3. As result we get error on trying to make request ``/en_GB/website_form/mail.mail`` --- opw-2413960 closes odoo/odoo#63997 X-original-commit: e9e86e251b7e262c4fe9c71722c27cc69cc3b712 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-09-18[FIX] website_form: allow to submit form without csrf if not loggedLaurent Stukkens (LTU)
Chrome recently changed their SameSite policy default value from None to Lax, the session is no more shared between the webpage and the iframe. As a result, the csrf check systematically fails. After this commit, the csrf_token check is only made when you have a session. In case you are using your form in an iframe on another site, with the new cookies policy, your cookies with the session_id (linked to the csrf token) is not sent to the server and the check csrf always fails. Since the purpose of the csrf is to prevent another website to submit a form with your 'authenticated account', we can consider that if you are not logged and so have no session_id, it is no critical and we can ignore the csrf check. opw-2330286 closes odoo/odoo#58046 X-original-commit: 9a0c9f3192bc7043add89446cbe6c2650499a654 Signed-off-by: Olivier Dony (odo) <odo@openerp.com> Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-09-08[FIX] website_form: lang arabic for date/datetimeNicolas Lempereur
When we send dates with website_form, if the language of the website is eg. in arabic we will send moment.js arabic dates that can't be parsed by the server. This also happens with norwegian and any language which doesn't use ascii numbers or textual format of month or days (and possibly RTL language). With this changeset, if we detect we are in a use case where this matter (an existing field and a date format that will fail) the date will be sent as odoo server format. Expected change: - what worked still work with or without server restart - what didn't work works after server restart - special case such as "english" with custom format in res.language containing textual month might now not work with code update without server restart (probability of this is low). opw-2326882 closes #57042 closes odoo/odoo#57214 Note: the saas-13.5 version always force isoformat for existing fields X-original-commit: 9a5bb5e892bc40709fab77c2bc62adcba19e02d2 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-06-09[IMP] website_form: avoid string concatanationMartin Trigaux
This is a slow operation and string join is significantly faster https://stackoverflow.com/a/3055541/1398110 This can make a noticable difference when processing a long form Courtesy of Nils Hamerlinck closes odoo/odoo#52664 X-original-commit: 87a2702fdabdcfeb774ddfb9db2e28bdd5595f9a Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-06-05[IMP] google_recaptcha, *: integrate recaptchaV3fja-odoo
* = base_setup, website_form, website_sale, website_crm, crm_iap_lead_website, website_hr_recruitment, website_mass_mailing Integrate reCaptchaV3 on website_form submit and website_mass_mailing subscription. You can now use ReCaptchaV3 to add reCaptcha verification in any module using google_recaptcha. Also added a better error management on the form with custom messages. task-2217980 closes odoo/odoo#48466 Related: odoo/enterprise#9649 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-03-27[FIX] website_form: fix wrong user sending emailjvm-odoo
Issue When you send a form which create a customer from the website, you get a 400 error. I used the customer database to reproduce the issue. I guess this is due to specific settings who set a value for `meta` here https://github.com/odoo/odoo/blob/5381e9d900b344e7d48a6b347c5fc551d433b15e/addons/website_form/controllers/main.py#L187 Cause The cause is the same than the one for fc8a0474b4 Here, we use sudo: https://github.com/odoo/odoo/blob/5381e9d900b344e7d48a6b347c5fc551d433b15e/addons/website_form/controllers/main.py#L211 sudo adds a flag "su" and does not replace the user in env So we have "public user" who doesn't have email instead of OdooBot who has an email, there is a raise who explain the issue but it's not forwarded to the error in the website Solution Use with_user(SUPERUSER_ID) instead of sudo, in order to have the right user (as it is done few lines above. OPW-2220816 closes odoo/odoo#48481 X-original-commit: 1dba2ec8166b934d0698220e7062280d347f8af1 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-03-04[FIX] website_form: fix wrong user sending website formsjvm-odoo
Issue - Set outgoing mail server - Install Online Ticket Submission - Publish an Helpdesk Team - Log out - Create a ticket from the helpdesk form The user who created the ticket is "Public User" He has no email address, so the mail is not sent Cause insert_record method in website_form/main.py uses .sudo() In v12 => sudo replaces the user in env by the superuser => ok In v13 => sudo adds a flag "su" and does not replace the user in env Solution Add a with_user(SUPERUSER_ID) to the create method's call in insert_record OPW-2196668 closes odoo/odoo#46835 X-original-commit: 761ae16634b14bec7be522666bb2163490566ecc Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-02-25[FIX] website_form: binary work with website_crm_phone_validationNicolas Lempereur
With this change, a binary field in a website form works when website_crm_phone_validation (website_crm in 13.0) is installed. The module website_crm_phone_validation would call `extract_data` method to do some things, but when extract_data was called a second time to really save data, the FileStorage werkzeug object would already consumed and files would erroneously appear as empty. opw-2191873 closes odoo/odoo#46241 X-original-commit: a168fe23cc6d9b817b44c189822952a1ee98d81d Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-02-24[FIX] website_form: binary field do not need _filenameNicolas Lempereur
When a binary field is added to studio, the system will try to write the name to {binary_field_name}_filename: this works if the field was created with studio but could not work eg. if just a binary field is created manually. opw-2191873 closes #45994 closes odoo/odoo#46164 X-original-commit: 13b65d878d5240f07b279045e30d53915d176a61 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-12-30[FIX] website_form: fix several issues when editing a formPrakash Prajapati
This commit fixes the following points: - While dropping a form builder, the default action is now set to 'Send an email' instead of first available action. - Titles of the forms which previously were readonly, are now editable. - When sending an email, the 'reply-to' address is now set from the email field provided in the form, instead of the catchall mail. - Hitting 'Send' button for 'Send an email' option now immediately sends the mail instead of putting it in the queue. task-2082970 closes odoo/odoo#42515 X-original-commit: 7ada68cc91fde1b6eff151549808a20e85cb5bf7 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-12-17[IMP] website: redo res config settingsJeremy Kersten
task-2088625 closes odoo/odoo#40715 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-12-09[FIX] website_form: fix missing currency field in form builderJason Van Malder
Issue - Install CRM & Website - Edit the website contact form - Add "Expected revenue" field Traceback Cause Monetary fields are not handled by the form builder Solution Add the monetary field in the form builder core OPW-2150986 closes odoo/odoo#41558 X-original-commit: 6c27c3abf4907e1faac670ea8ef006992ec96063 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-11-29[FIX] website_form: link attachments to binary fieldsFanny He
If the name of a file input field is 'x_binary_input', before commit 9be29371abcdfe57b1738484c5057ad81e76b00d (opw 2092653), self.form_fields would have names of the form 'x_binary_input[i]'. After this commit, they are of the form 'x_binary_input[i][j]'. When calling extract_data, field_name would then be 'x_binary_input[i]' instead of 'x_binary_input'. Therefore, the file would be considered as orphan instead of being attached to x_binary_input. We thus change the split so that it always returns 'x_binary_input'. opw 2122624 closes odoo/odoo#41135 X-original-commit: 21ed2b971f66879fa3fa53dbd2c349ab39fa3fdb Signed-off-by: fah-odoo <fah-odoo@users.noreply.github.com>
2019-09-17[FIX] *: remove old deprecated modules/functionsJulien Castiaux
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-07-26[FIX] website_form: Allow to post a message with attachmentsYannick Tivisse
Coming from the sudo() modification. The mail.message is created in sudo, but the user is still the public user, who doesn't have a email address, leading to an raised error.
2019-07-12[MERGE] Forward port of saas-12.3 to saas-12.4 up to 87fc1554d6a1823Martin Trigaux
closes odoo/odoo#34820 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-01[FIX] website_form: set filename on studio binaryJulien Castiaux
Using studio, add a file field on a form. Using the web form builder, append that field on a form. Upload a file, `x_field_filename` is left empty thus the filename is lost. opw-2028071 closes odoo/odoo#34491 Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2019-06-05[REF] *: removes datas_fname from ir.attachmentThanh Dodeur
This commit removes the field `datas_fname` from `ir.attachment` as it was unnecessary and most of the time the duplicate of `name` or `url`. Task #1909865 closes odoo/odoo#32976 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-04-19[IMP] wesbite_form: change custom fields title for mail.mailJigar Patel
task-32212
2018-11-15[MERGE] forward port branch 11.0 up to 468dab6748aChristophe Simonis
2018-11-09[FIX] website_form: custom file -> mail attachmentsNicolas Lempereur
There was a code that on: - a form that sent a mail - with a custom file field would set the file as attachments, but the code was dead because of a typo in `if` statement order. opw-1906883 closes #28525
2018-05-23[MERGE] forward port branch 11.0 up to 02ee3fd88efChristophe Simonis
2018-05-23[MERGE] forward port branch saas-15 up to 1b81f1a5c9dChristophe Simonis
2018-05-23[MERGE] forward port branch 10.0 up to 682ae1cc64eChristophe Simonis
2018-05-23[FIX] website_form: set meta fieldDavid
Before this commit, if you enable website_form_enable_metadata, that will crash with a "KeyError: 'meta'" This commit closes #24848
2018-03-07[MERGE] forward port branch 11.0 up to d67b410dfcdChristophe Simonis
2018-03-07[MERGE] forward port branch saas-15 up to cb87388d727Christophe Simonis
2018-03-06[FIX] website_form: public user can send attachmentChristophe Matthieu
Issue: An additional information page is part of our shop process to allow additional information to be submitted. If this form is left blank, then selecting the next button allows the process to continue. However, if data is added to the form the form freezes and the process will not continue when 'next' is selected. Why: Public user can not read the field 'model' of 'ir.model' (to save the attachments) opw-1818592
2017-11-27[MOV] base: move ir_* models into models/Thibault Delavallée
2017-10-25[IMP] website_form: name of submitted attachmentsDeep Patel
In case of custom field 'upload file', the attachement name will be the technical name of the input tag of the form (aka 'attachments'). It is more user friendly to have the name of the uploaded file.
2017-09-14[FIX] website_form: custom field thing blows up in P3Xavier Morel
Custory reading seems to denote that field names are probably already text in the normal case, and thus should not need decoding? It only blows up in a tour so...
2017-08-20[FIX] P3: remove pycompat.{keys,items,values} helpersOlivier Dony
Now that we're closer to switching to P3 for good, these helpers have outlived their usefulness, and mostly add noise. All remaining dict.iter*() or dict.view*() must be converted to the normal keys(), values() or items() calls. Whenever the result is likely to be used for more than the scope of a loop, or when the dict needs to be modified during iteration, the calls must be wrapped in a ``list()``, to protect the new P3 semantics. Those cases are very exceptional. Also removed some dead code or improved the API to remove unnecessary conversions.
2017-05-16[MERGE] Forward-port saas-16 up to 5afe894f440eff3b58134d14fa7c9b43b19fe88bOlivier Dony
2017-05-16[MERGE] Forward-port saas-15 up to 878fbc75ff9ebade92f43748500e64350367a824Olivier Dony
2017-05-16[MERGE] Forward-port 10.0 up to 1545995b393a1d347c6c1988da03dd1c6f1ea037Olivier Dony
2017-05-10[FIX] P3: list -> iterable builtins (#16811)xmo-odoo
In Python 3: * various builtins and dict methods were changed to return view/iterable objects rather than lists * and the separate Python 2 view/iterable builtins and methods were removed altogether This is problematic when using these items as list (which the happens repeatedly in Odoo), but more viciously when iterating *multiple times* over them (which also happens, which I've messed up multiple times while writing this, and which is a pain to debug even when you've just created the issue). Convert all code using these to semantics-matching cross-version helper functions to get the LCD behaviour between P2 and P3, and forbid the builtins via lint. issue #8530
2017-05-09[FIX] website_form: do not subscribe administrator to all records from ↵Thibault Delavallée
website form As administrator is used to create all records from website form he is also put into followers. This creates a lot of unnecessary notifications and/or emails depending on the system configuration. Using the magic context key this behavior is modified. Administrator will not follow every records created through the website form anymore.
2017-04-11[#8530] convert exception handlers to except..as syntaxXavier Morel
Futurize fixers: * lib2to3.fixes.fix_except
2017-03-17[MERGE] forward port branch saas-15 up to c8f01e3b62fChristophe Simonis
2017-03-15[FIX] website_sale: fix extra-stepDenis Vermylen
truly fix 328a5a7ea393b8a3cc60ca36b2b41d606e2110e8 sudo() was applied at the wrong step. mea culpa
2017-03-10[IMP] website_form, website_hr_recruitment: improve thankyou pageJeremy Kersten
Improve thank page after the application to a job. Stop duplicate Magic field, using global fields Add helper method on website to retreive the last created record
2017-01-20[FIX] base: restrict read access to `ir.model` and `ir.model.fields` to ↵Raphael Collet
employees
2017-01-17[FIX] base: access rights of `ir.model` and `ir.model.fields`Raphael Collet
This partially reverts commits 5d746d0ac663232d656bb57e82fec290bb5d82fd and 73de86c7682a1433da7a755c3092dcb38fba3fd8. The tightening of access rights was too strong: regular users need to be able to read models and fields (to create an email templace, for instance.) [FIX] ir_values: in `get_actions`, exclude field `code`
2017-01-03[IMP] base, *: tighten `ir.model` access rightsRaphael Collet
Remove unrestricted "read" access. To make code internally using `ir.model` work, add a private method `_get` on `ir.model` to retrieve the record corresponding to a model name, without access rights issue. Change signature of method `get_authorized_fields` to make it use a model name instead of a model id. This removes the necessity of a search on `ir.model`.
2016-08-20[MERGE] forward port branch saas-12 up to 9ad5f26Christophe Simonis
2016-08-20[MERGE] forward port branch saas-11 up to 3a2147dChristophe Simonis
2016-08-19[MERGE] forward port branch 9.0 up to 58cbcbaChristophe Simonis
2016-08-17[FIX] website_form: traceback when sending an attachmentNicolas Martinelli
The form builder offers the possibility to add a "Custom File Upload" field. When the user clicks on "Send", an error occurs ("An error has occured, the form has not been sent."). This is because we try to send a mail linked to "mail.mail", which doesn't make sense. The case was actually taken into account in the code, there was just an oversight in the code. opw-684040