Conversation
* [T2945] REFACTOR: gift limits are now translatable - REFACTOR: Added 'Gift' to the get_gitf_type_selection() method - REFACTOR: Added methods to select the value of the sponsorship gifts - REFACTOR: Added a method to convert and round funds * [T2945] REFACTOR: simplified code * [T2945] STYLE: pre-commit * [T2945] FEATURE: added frequency indicator method - FEATURE: templates using this model can now directly call this function to display 0-2 starts depending on the condition
* [FIX] Add obfuscated location to the project model * [STYLE] Add comments * [STYLE] Refactor comments * [FIX] Add timeout for the geocode API request * [FIX] Fix typos * Update child_compassion/models/project_compassion.py Co-authored-by: ecino <ecino@users.noreply.github.com> * [T2792][FIX] Make obfuscated coord computed fields Co-authored-by: ecino <ecino@users.noreply.github.com> * [T2792][FIX] Make the obfuscated coords computed fields * [T2792][STYLE] Add comments * [T2792][STYLE] Remove useless get method * [T2792][STYLE] Use proper randomization of coordinates * [T2792][FIX] Updates conditionning of the updates * [T2792][FIX] Add lat long 0 fallback when no data are provided * [T2793][STYLE] Modularize calls to _compute_gps_obfuscated * [T2792][FIX] Use proper compute method on the gps_obfuscated * [T2792][Refactor] Renames compute functions * FIX obfuscation --------- Co-authored-by: ecino <ecino@users.noreply.github.com> Co-authored-by: Emanuel Cino <ecino@compassion.ch>
* [T2987] REFACTOR: moved language detection to generator - REFACTOR: Moved original language detection to generator and made sure everyone can access it -> sudo() * [T2987] FIX: added 'advanced_translation' dependency to __manifest__.py
…2075) * [T2986] FIX: direction is now explicitly set through message values - FIX: fetch the whole action instead of only the id and set the id and direction for the message - REFACTOR: added type to super().create() in gmc_message for clarity * [T2986] STYLE: pre-commit
- FIX: updated the Docstrings of the create method - FIX: added email_read: now() to the values which create the correspondence
- Happy path should use main cursor - Only exceptions should use a new cursor in DB - Remove redundant calls
* [FEAT][T2840] add category and description code snippet * [FEAT][T2840] add category and description code snippet * T2840 ADD search view --------- Co-authored-by: Aurelien Vuffray <zivi1@compassion.ch> Co-authored-by: Emanuel Cino <ecino@compassion.ch>
* [IMP][T1142] New Suspension Communication Rules * Update partner_communication_compassion/data/ir_cron_data.xml Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * FIX migration script --------- Co-authored-by: Aurelien Vuffray <zivi1@compassion.ch> Co-authored-by: ecino <ecino@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Emanuel Cino <ecino@compassion.ch>
…language in some cases (#2082) - FIX: language detector now overwrites correct translation (source/target) - FIX: correspondence created first and then sent to translation pool if applicable - STYLE: added docstrings comments to compute write letter
* Update gift_thresholds.xml avoid the updates of gift threshold to be reset * Apply suggestion from @gemini-code-assist[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: ecino <ecino@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* [T3059] FIX: last lifecycle event now takes date into account - FIX: take all events, sort by date descending, take first date and calculate state according to this event * [T3059] FIX: added post-migration script - FIX: post-migration script should now update the last event date on all projects - FIX: changed the sorting of the lifecycle events in the projects view - FIX: updated module version * [T3059] FIX: GCA and pre-commit
add full set of fund hierarchy. manually updated the ir.model.data table accordingly
- FIX: this change makes the intervention_compassion module installable again (main groups need to come first)
* [T2747] FIX: moved state update to after payment configuration - FIX: changing state triggers the creation of the communication job, but the payment information/pdf is not yet in the db at the time. This should solve that issue. Testing is still needed! * Update sponsorship_compassion/models/contracts.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: Daniel Gergely <dgergely@compassion.ch> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request introduces several enhancements and fixes across multiple modules. Key changes include the implementation of GPS coordinate obfuscation for projects using the Google Maps API, improved lifecycle event tracking, and a new automated communication system for project suspensions and follow-ups. Additionally, it introduces categories for communication snippets, updates analytic account structures, and refines language detection for correspondence. Feedback was provided regarding a missing email template body, the use of broad exception handling, and hardcoded IDs in migration scripts.
| <record id="email_project_suspension_follow_up" model="mail.template"> | ||
| <field name="name">FCP Suspension Follow Up</field> | ||
| <field | ||
| name="model_id" | ||
| ref="partner_communication.model_partner_communication_job" | ||
| /> | ||
| <field name="use_default_to" eval="True" /> | ||
| <field | ||
| name="partner_to" | ||
| >${object.partner_id and object.partner_id.email and object.partner_id.id or False }</field> | ||
| <field name="subject">Project Reactivation</field> | ||
| name="subject" | ||
| >Additional information about the center</field> | ||
| <field | ||
| name="email_from" | ||
| >"${object.user_id.company_id.name}" <${object.user_id.company_id.email}></field> | ||
| <field name="body_html" type="html"> | ||
| <div> | ||
| % set child = object.get_objects() | ||
| % set project = child.mapped('project_id')[0] | ||
| % set reactivation = project.lifecycle_ids[0] | ||
| % set details = reactivation.fcp_improvement_desc | ||
| </div> | ||
| <p> | ||
| ${object.partner_id.salutation}, | ||
| <br /> | ||
| <br /> | ||
| A few time ago the project ${project.fcp_id} where ${child.get('your sponsored child')} ${child.get('is')} registered was on suspension. | ||
| We are happy to inform you that the problem is resolved and that the project is again sane and active. | ||
| The project will do regular tuitions and spiritual activites to keep the situation healthy. | ||
| <br /> | ||
| <br /> | ||
| % if details: | ||
| ${details} | ||
| <br /> | ||
| <br /> | ||
| % endif | ||
| Yours sincerely | ||
| </p> | ||
| </field> | ||
| </record> |
There was a problem hiding this comment.
The email template email_project_suspension_follow_up is defined without a body_html field. This will result in sending an empty email when this template is used, for example when a project is reactivated or in the 2-month suspension follow-up cron. You should add a body to this template to provide meaningful information to the recipient.
<record id="email_project_suspension_follow_up" model="mail.template">
<field name="name">FCP Suspension Follow Up</field>
<field
name="model_id"
ref="partner_communication.model_partner_communication_job"
/>
<field name="use_default_to" eval="True" />
<field
name="subject"
>Additional information about the center</field>
<field
name="email_from"
>"${object.user_id.company_id.name}" <${object.user_id.company_id.email}></field>
<field name="body_html" type="html">
<div>
% set child = object.get_objects()
% set project = child.mapped('project_id')[0]
% set last_lifecycle = project.last_lifecycle_id
</div>
<p>
${object.partner_id.salutation},
<br /><br />
This is a follow-up regarding the center ${project.fcp_id}.
<br /><br />
<!-- TODO: Add relevant information based on the context (e.g., reactivation, continued suspension) -->
<br /><br />
Yours sincerely
</p>
</field>
</record>
| location = data["results"][0]["geometry"]["location"] | ||
| project.gps_latitude_obfuscated = location["lat"] | ||
| project.gps_longitude_obfuscated = location["lng"] | ||
| except Exception: |
There was a problem hiding this comment.
The try...except block uses a broad except Exception. This can hide unexpected errors and make debugging more difficult. It's better to catch more specific exceptions that you expect to handle, such as requests.exceptions.RequestException for network issues, and KeyError or IndexError for issues with the response data structure.
| except Exception: | |
| except (requests.exceptions.RequestException, KeyError, IndexError): |
| logs.write( | ||
| {"config_id": 1} | ||
| ) # Set to Default config (ID=1) to avoid orphaned logs |
There was a problem hiding this comment.
Using a hardcoded ID 1 for the default configuration is fragile and might break if the record ID changes in different environments. It's safer to look up the record using its XML ID.
| logs.write( | |
| {"config_id": 1} | |
| ) # Set to Default config (ID=1) to avoid orphaned logs | |
| default_config = env.ref('partner_communication.default_communication', raise_if_not_found=False) | |
| if default_config: | |
| logs.write({"config_id": default_config.id}) |
No description provided.