Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] shift attendance: migration to 16.0 #538

Open
wants to merge 26 commits into
base: 16.0
Choose a base branch
from

Conversation

remytms
Copy link
Collaborator

@remytms remytms commented Dec 5, 2024

Description

Odoo task (if applicable)

task

Checklist before approval

  • Tests are present (or not needed).
  • Credits/copyright have been changed correctly.
  • Change log snippet is present.
  • (If a new module) Moving this to OCA has been considered.

@remytms remytms force-pushed the 16.0-mig-shift_attendance branch 2 times, most recently from 3cc8164 to 292d8e3 Compare December 10, 2024 17:33
Copy link
Collaborator

@polchampion polchampion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functional test on 16-test-shift
@remytms see bug reports below when clicking on today's attendance sheet submenu

features

  • add attendance sheet configs, model, menu and submenus
  • automated action - attendance sheet generation
  • apply attendance sheet content to shift upon validation
  • raise validation errors when the shift hasn't started
  • add permission group to validate attendance sheets
  • trigger email in case of missed shift NOK : default template content baldy rendered

bug report: can't access Attendance Sheet > "Today's sheets" submenu

Promesse non interceptée > fnValue is not a function
TypeError: fnValue is not a function
    _innerEvaluate@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1299:8
    _evaluate@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1306:49
    _innerEvaluate@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1295:33
    _evaluate@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1306:49
    _innerEvaluate@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1295:33
    _evaluate@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1306:49
    evaluate@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1308:8
    evaluateExpr@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:1155:109
    _preprocessAction@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:5881:150
    doAction@https://odoo16.main.test.srv.coopiteasy.be/web/assets/231-3bfc478/web.assets_backend.min.js:5966:170
    ```

@polchampion
Copy link
Collaborator

@remytms
I reset the shift attendance email template and have errors in the preview.
Also, probably linked, I can't validate this attendance sheet:


Échec de rendu du modèle QWeb : 
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">

    <t t-if="object.replaced_id">
        <p>Hello <t t-out="object.replaced_id.name" />,</p>

        <p>
            You have been recorded as non-attended during your last shift
            (<t t-out="format_tz(object.start_time,object.replaced_id.tz or 'Europe/Brussels','%d.%m.%Y - %H:%M')" />),
            and you were supposed to replace
            <t t-out="object.worker_id.name" />.
        </p>
    </t>

    <t t-else="">
        <p>Hello <t t-out="object.worker_id.name" />,</p>

        <p>
            You have been recorded as non-attended during your last shift
            (<t t-out="format_tz(object.start_time,object.worker_id.tz or 'Europe/Brussels','%d.%m.%Y - %H:%M')" />).
        </p>
    </t>

    <t t-if="object.worker_id.working_mode == 'regular'" >
        <p t-if="object.state == 'absent_0'">
            Super-cooperator assigned you 0 compensation, so you
            won't have any additionnal shift to do before your
            next regular shift.
        </p>

        <p t-elif="object.state == 'absent_1'">
            Super-cooperator assigned you 1 compensation, so you
            have to attend one additionnal shift before your
            next regular shift.
        </p>

        <p t-elif="object.state == 'absent_2'">
            Super-cooperator assigned you 2 compensations, so
            you have to attend two additionnal shifts before
            your next regular shift.
        </p>

        <p t-if="object.replaced_id">
            You were supposed to replace <t t-out="object.worker_id.name" />.
            You have to do
            <t t-out="(object.replaced_id.cooperative_status_ids.sr + object.replaced_id.cooperative_status_ids.sc) * -1" />
            shifts before your next regular shift.
        </p>

        <p t-else="">
            You have to do
            <t t-out="(object.worker_id.cooperative_status_ids.sr + object.worker_id.cooperative_status_ids.sc) * -1" />
            shifts before your next regular shift.
        </p>
    </t>

    <t t-if="objec.worker_id.working_mode == 'irregular'>
        <p>
            Your shift counter is at
            <t t-out="object.worker_id.cooperative_status_ids.sr" />.
        </p>
        <p t-if="object.worker_id.cooperative_status_ids.future_alert_date">
            It should be superior or equal to 1 before the
            <t t-out="object.worker_id.cooperative_status_ids.future_alert_date" />.
        </p>
    </t>

    <p t-if="object.replaced_id">
        Your current status is
        "<t t-out="object.replaced_id.cooperative_status_ids.get_status_value()" />".
    </p>

    <p t-else="">
        Your current status is
        "<t t-out="object.worker_id.cooperative_status_ids.get_status_value()" />".
    </p>

    <p>
        If you have any question regarding this non-attendance,
        just answer this e-mail.
    </p>

    <br>
    <p>Cooperatively yours,<br>
    The Members' office volunteers</p>
    <p><t t-out="object.create_uid.company_id.name"/>.</p>

    <t t-if="object.create_uid.company_id.street">
        <t t-out="object.create_uid.company_id.street" />
    </t>
    <t t-if="object.create_uid.company_id.street2">
        <t t-out="object.create_uid.company_id.street2"/><br/>
    </t>
    <t t-if="object.create_uid.company_id.city or object.create_uid.company_id.zip">
        <t t-out="object.create_uid.company_id.zip"/> <t t-out="object.create_uid.company_id.city"/><br/>
    </t>
    <t t-if="object.create_uid.company_id.country_id">
        <t t-out="object.create_uid.company_id.state_id and ('%s, ' % object.create_uid.company_id.state_id.name) or ''"/> <t t-out="object.create_uid.company_id.country_id.name or ''"/><br/>
    </t>
    <t t-if="object.create_uid.company_id.phone">
        Phone:&nbsp; <t t-out="object.create_uid.company_id.phone"/>
    </t>

    <t t-if="object.create_uid.company_id.website">
        <div>
            Web: <a t-att-href="'%s' % object.create_uid.company_id.website"><t t-esc="object.create_uid.company_id.website"/></a>
        </div>
    </t>
    <t t-if="object.create_uid.company_id.logo">
    <div>
        <img src="/web/binary/company_logo" style="vertical-align:baseline;max-width:100px;" />
    </div>
    </t>
</div>
        

Traceback (most recent call last):
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 736, in _generate_code
    + self._compile_node(element, compile_context, 2)
  File "/home/odoo16/src/odoo/addons/web_editor/models/ir_qweb_fields.py", line 67, in _compile_node
    return super()._compile_node(el, compile_context, indent)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1265, in _compile_node
    return self._compile_static_node(el, compile_context, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1357, in _compile_static_node
    body = self._compile_directive(el, compile_context, 'inner-content', level)
  File "/home/odoo16/src/odoo/odoo/tools/profiler.py", line 327, in _tracked_compile_directive
    return method_compile_directive(self, el, options, directive, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1410, in _compile_directive
    return compile_handler(el, compile_context, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1700, in _compile_directive_inner_content
    body.extend(self._compile_node(item, compile_context, level))
  File "/home/odoo16/src/odoo/addons/web_editor/models/ir_qweb_fields.py", line 67, in _compile_node
    return super()._compile_node(el, compile_context, indent)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1265, in _compile_node
    return self._compile_static_node(el, compile_context, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1357, in _compile_static_node
    body = self._compile_directive(el, compile_context, 'inner-content', level)
  File "/home/odoo16/src/odoo/odoo/tools/profiler.py", line 327, in _tracked_compile_directive
    return method_compile_directive(self, el, options, directive, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1410, in _compile_directive
    return compile_handler(el, compile_context, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1700, in _compile_directive_inner_content
    body.extend(self._compile_node(item, compile_context, level))
  File "/home/odoo16/src/odoo/addons/web_editor/models/ir_qweb_fields.py", line 67, in _compile_node
    return super()._compile_node(el, compile_context, indent)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1297, in _compile_node
    return body + self._compile_directives(el, compile_context, level)
  File "/home/odoo16/src/odoo/addons/mail/models/ir_qweb.py", line 16, in _compile_directives
    return super()._compile_directives(el, compile_context, indent)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1383, in _compile_directives
    code.extend(self._compile_directive(el, compile_context, directive, level))
  File "/home/odoo16/src/odoo/odoo/tools/profiler.py", line 327, in _tracked_compile_directive
    return method_compile_directive(self, el, options, directive, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1410, in _compile_directive
    return compile_handler(el, compile_context, level)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1721, in _compile_directive_if
    code.append(indent_code(f"if {self._compile_expr(expr)}:", level))
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 1185, in _compile_expr
    assert_valid_codeobj(_SAFE_QWEB_OPCODES, compile(expression, '<>', 'eval'), expr)
  File "<>", line 2
    <values.get('p')>
    ^
SyntaxError: invalid syntax

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/odoo16/src/odoo/addons/mail/models/mail_render_mixin.py", line 304, in _render_template_qweb
    render_result = self.env['ir.qweb']._render(
  File "/home/odoo16/src/odoo/odoo/tools/profiler.py", line 294, in _tracked_method_render
    return method_render(self, template, values, **options)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 584, in _render
    template_functions, def_name = irQweb._compile(template)
  File "/home/odoo16/src/odoo/odoo/tools/profiler.py", line 302, in _tracked_compile
    return method_compile(self, template)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 653, in _compile
    return self._load_values(base_key_cache, generate_functions)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 2458, in _load_values
    return get_value()
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 622, in generate_functions
    code, options, def_name = self._generate_code(template)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_qweb.py", line 761, in _generate_code
    raise QWebException("Error when compiling xml template",
odoo.addons.base.models.ir_qweb.QWebException: Error when compiling xml template
SyntaxError: invalid syntax (<>, line 2)
Template: <Element div at 0x7ff9508546d0>
Path: /div/div/t[4]
Node: <t t-if="objec.worker_id.working_mode == 'irregular'&gt;&#10;        &lt;p&gt;&#10;            Your shift counter is at&#10;            &lt;t t-out=" object.worker_id.cooperative_status_ids.sr=""/>
)```

@remytms remytms marked this pull request as ready for review December 23, 2024 10:05
carmenbianca and others added 24 commits December 23, 2024 11:12
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
* rename many2many tables and their columns.
* rename constraints and indexes.
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
There are two fixes in this commit:

- Use .search() instead of .get_param() for a more robust search of the
  old value.
- Rename all XMLIDs. When they XMLIDs aren't renamed, the values get
  overridden during init, even though the config_parameter keys were
  renamed.

Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
@remytms remytms force-pushed the 16.0-mig-shift_attendance branch from 68687b2 to e45e1ba Compare December 23, 2024 10:12
@polchampion
Copy link
Collaborator

polchampion commented Jan 6, 2025

@remytms Still having similar issues, try previewing the email template here.

@remytms
Copy link
Collaborator Author

remytms commented Jan 21, 2025

@polchampion I also add some trouble with transalation in french that does not reflect the changes.

I deleted the email template, and updated the module.

Now the mail template, does not contain the typo "objec.xxx" that shows up in your previous error.

I also face issue when choosing to preview with a shift with no worker assigned. I’m not sure that this case should be taken into account, knowing that the worker is needed also for the "To" field o the email.

Can you test again ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants