feat(plating): comprehensive timezone fix across dashboards/PDFs/emails

Database stores datetimes naive-UTC, but the dashboards and emails were
showing UTC strings to users in EST/EDT — making 9pm Toronto look like 1am
the next day. Adds a single helper module + auto-detection on install.

Core changes (fusion_plating):
- New fp_tz.py helper: fp_user_tz, fp_format, fp_isoformat_utc, fp_time_ago
  Resolves user.tz → company.x_fc_default_tz → UTC.
- res.company.x_fc_default_tz Selection (full pytz IANA list)
- res.config.settings exposes the company tz under a new "Regional
  Settings" block in Settings > Fusion Plating
- post_init_hook auto-populates the tz on first install: tries admin
  user → server /etc/timezone → America/Toronto fallback
- fp_process_node._to_dict now sends create_date/write_date as ISO with
  explicit +00:00 marker so JS new Date() parses it as UTC and the
  recipe tree editor's "time ago" math works correctly

Shop-floor controllers:
- shopfloor_controller.py: every fields.Datetime.to_string() and naive
  .strftime() swapped for fp_format(env, ...) — due_at, bake times,
  last_log_date, gates, server_time all now in user's tz
- _time_ago() removed; replaced with fp_time_ago helper which compares
  tz-aware datetimes (the local one was naive-vs-naive and could be
  off by hours)
- manager_controller.py date_planned: str(...)[:10] slice replaced
  with fp_format MM/DD in user's tz

Notifications + reports:
- mail_template_data.xml: 5 .strftime() calls in body_html → babel
  format_datetime / format_date with tz=(user.tz or company tz)
- report_fp_job_traveller.xml: rec.received_date (Datetime) gets
  t-options="{'widget':'datetime'}" so Odoo's QWeb renders in user tz

Settings view layout:
- fusion_plating now owns the Settings page "Fusion Plating" app shell
- fusion_plating_certificates xpaths into it instead of redefining
  (prevents app-name collision)

Verified on odoo-entech (LXC 111): post_init_hook detects
America/Toronto from /etc/timezone, MO date_start 2026-04-17 05:28 UTC
correctly displays as 2026-04-17 01:28 EDT.

Module versions bumped: fusion_plating 19.0.3.0.0,
fusion_plating_shopfloor 19.0.9.0.0, plus certificates / notifications /
reports → 19.0.3.0.0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-18 21:03:02 -04:00
parent 956678dd27
commit 6c4ff7751f
17 changed files with 370 additions and 115 deletions

View File

@@ -5,7 +5,7 @@
{
'name': 'Fusion Plating — Certificates',
'version': '19.0.2.0.0',
'version': '19.0.3.0.0',
'category': 'Manufacturing/Plating',
'summary': 'Certificate registry for CoC, thickness reports, and quality documents.',
'description': """

View File

@@ -1,60 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!--
Extends the Fusion Plating settings app (created in core
fusion_plating/views/res_config_settings_views.xml) with the
certificate / accreditation blocks. xpath into the existing app
rather than redefining it so the two modules don't collide.
-->
<record id="res_config_settings_view_form_fp" model="ir.ui.view">
<field name="name">res.config.settings.view.form.fusion.plating</field>
<field name="name">res.config.settings.view.form.fusion.plating.certificates</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="inherit_id" ref="fusion_plating.res_config_settings_view_form_fp_core"/>
<field name="arch" type="xml">
<xpath expr="//form" position="inside">
<app data-string="Fusion Plating" string="Fusion Plating"
name="fusion_plating" groups="fusion_plating.group_fusion_plating_manager">
<block title="Certificate of Conformance"
name="fp_coc_settings"
help="Branding, accreditation logos, and default signer for Certificates of Conformance.">
<setting id="fp_coc_owner"
string="Certificate Owner (Default Signer)"
help="Their HR Employee signature appears on issued certificates by default.">
<field name="x_fc_owner_user_id"
options="{'no_create': True, 'no_open': True}"/>
</setting>
<setting id="fp_coc_sig_override"
string="Signature Override Image"
help="Upload a scanned signature here to override the owner user's employee signature (useful if they don't have an HR record).">
<field name="x_fc_coc_signature_override"
widget="image" class="oe_avatar"/>
</setting>
</block>
<xpath expr="//app[@name='fusion_plating']" position="inside">
<block title="Certificate of Conformance"
name="fp_coc_settings"
help="Branding, accreditation logos, and default signer for Certificates of Conformance.">
<setting id="fp_coc_owner"
string="Certificate Owner (Default Signer)"
help="Their HR Employee signature appears on issued certificates by default.">
<field name="x_fc_owner_user_id"
options="{'no_create': True, 'no_open': True}"/>
</setting>
<setting id="fp_coc_sig_override"
string="Signature Override Image"
help="Upload a scanned signature here to override the owner user's employee signature (useful if they don't have an HR record).">
<field name="x_fc_coc_signature_override"
widget="image" class="oe_avatar"/>
</setting>
</block>
<block title="Accreditation Logos"
name="fp_accreditation_logos"
help="Upload the logos and toggle each on to display it in the CoC header. Sized automatically in the PDF.">
<setting id="fp_nadcap"
string="Nadcap Accredited"
help="Administered by PRI. Upload the official Nadcap Accredited logo.">
<field name="x_fc_nadcap_active"/>
<field name="x_fc_nadcap_logo"
widget="image" class="oe_avatar"
invisible="not x_fc_nadcap_active"/>
</setting>
<setting id="fp_as9100"
string="AS9100 / ISO 9001"
help="AS9100D / ISO 9001 certified. Upload the combined logo.">
<field name="x_fc_as9100_active"/>
<field name="x_fc_as9100_logo"
widget="image" class="oe_avatar"
invisible="not x_fc_as9100_active"/>
</setting>
<setting id="fp_cgp"
string="Controlled Goods Program (CGP)"
help="Registered with Canada's Controlled Goods Program.">
<field name="x_fc_cgp_active"/>
<field name="x_fc_cgp_logo"
widget="image" class="oe_avatar"
invisible="not x_fc_cgp_active"/>
</setting>
</block>
</app>
<block title="Accreditation Logos"
name="fp_accreditation_logos"
help="Upload the logos and toggle each on to display it in the CoC header. Sized automatically in the PDF.">
<setting id="fp_nadcap"
string="Nadcap Accredited"
help="Administered by PRI. Upload the official Nadcap Accredited logo.">
<field name="x_fc_nadcap_active"/>
<field name="x_fc_nadcap_logo"
widget="image" class="oe_avatar"
invisible="not x_fc_nadcap_active"/>
</setting>
<setting id="fp_as9100"
string="AS9100 / ISO 9001"
help="AS9100D / ISO 9001 certified. Upload the combined logo.">
<field name="x_fc_as9100_active"/>
<field name="x_fc_as9100_logo"
widget="image" class="oe_avatar"
invisible="not x_fc_as9100_active"/>
</setting>
<setting id="fp_cgp"
string="Controlled Goods Program (CGP)"
help="Registered with Canada's Controlled Goods Program.">
<field name="x_fc_cgp_active"/>
<field name="x_fc_cgp_logo"
widget="image" class="oe_avatar"
invisible="not x_fc_cgp_active"/>
</setting>
</block>
</xpath>
</field>
</record>