diff --git a/farm_onboarding/README.rst b/farm_onboarding/README.rst index 4adfd3f..0080a1e 100644 --- a/farm_onboarding/README.rst +++ b/farm_onboarding/README.rst @@ -32,19 +32,31 @@ enterprise types), how you keep books today (QBO / QBD / Excel / paper / nothing), done — with a state machine, progress bar, save-as-you-go, and back/next/skip/restart actions. -This MVP uses a regular form view with state-conditional groups so -sessions persist across browser closes. The original plan called for an -OWL client action with full-screen modal; that polish is deferred to v1 -in favor of shipping the data model and flow first. +The wizard surfaces itself two ways: + +- **Navbar bell.** A leaf icon with a red badge dot appears in the + systray when the current farm user has an unfinished session. Click it + to jump straight into the wizard. The bell is hidden for users outside + ``farm_base.group_farm_user`` and disappears once the session is + marked done. +- **Farm → Setup Wizard menu item.** Same destination, accessible at any + time for a re-run. + +The form itself is a regular Odoo form view with state-conditional +groups so sessions persist across browser closes. A richer custom- +chrome design pass lives in a follow-on PR (Step 2 of the UX refinement +plan). Adds 12 pre-loaded ``farm.enterprise.type`` records (eggs, vegetables, fruit, herbs, orchard, cattle, dairy, poultry, hogs, sheep/goats, value- added, workshops) with emoji icons — these drive product catalog and report pre-configuration in downstream modules. -The "Setup Wizard" menu item routes each user to their own open session -(creates one if none exists), so multiple farm-users on the same company -each get an independent walkthrough. +Each user gets their own session per company, so multiple farm-users on +the same company each get an independent walkthrough. The umbrella +``farm_pack`` module's ``post_init_hook`` seeds a session for every +existing internal farm user on install; new users created later pick one +up lazily on first wizard open. .. IMPORTANT:: This is an alpha version, the data model and design can change at any time without warning. @@ -59,14 +71,16 @@ each get an independent walkthrough. Usage ===== -1. **Farm → Setup Wizard** — opens (or resumes) your active session. +1. **Look for the leaf icon + red dot in the navbar.** That's the + onboarding bell — click it to jump into the wizard. (Or use **Farm → + Setup Wizard** for the same destination.) 2. Click **Next** to step through: Welcome → Your Farm → What You Grow → Books Today → All Set. 3. Each screen saves on Next/Back so closing the browser doesn't lose progress. Skip jumps straight to Done. -4. Once done, the Farm menu's other items (Eggs, CSA, Markets, Delivery, - QuickBooks) are where the actual work happens — the wizard pre-tells - the pack what to surface for your operation. +4. Once done, the bell disappears and the Farm menu's other items (Eggs, + CSA, Markets, Delivery, QuickBooks) are where the actual work happens + — the wizard pre-tells the pack what to surface for your operation. Bug Tracker =========== diff --git a/farm_onboarding/__manifest__.py b/farm_onboarding/__manifest__.py index eeb5990..a3884d4 100644 --- a/farm_onboarding/__manifest__.py +++ b/farm_onboarding/__manifest__.py @@ -1,7 +1,7 @@ { "name": "Farm Onboarding", "summary": "60-second first-run wizard for new farm-pack installs", - "version": "19.0.1.0.0", + "version": "19.0.1.1.0", "license": "AGPL-3", "author": "Ledo Enterprises, Odoo Community Association (OCA)", "website": "https://github.com/ledoent/farm-pack", @@ -16,6 +16,12 @@ "views/farm_enterprise_type_views.xml", "views/farm_onboarding_menu.xml", ], + "assets": { + "web.assets_backend": [ + "farm_onboarding/static/src/js/onboarding_systray.esm.js", + "farm_onboarding/static/src/xml/onboarding_systray.xml", + ], + }, "demo": [], "installable": True, "application": False, diff --git a/farm_onboarding/models/farm_onboarding_session.py b/farm_onboarding/models/farm_onboarding_session.py index 49100fa..0874b88 100644 --- a/farm_onboarding/models/farm_onboarding_session.py +++ b/farm_onboarding/models/farm_onboarding_session.py @@ -131,6 +131,22 @@ def get_or_create_for_current_user(self): ) return session + @api.model + def count_pending_for_current_user(self): + """Pending-session count for the systray bell. + + Kept separate from `get_or_create_for_current_user` so the + bell's mount path is read-only — the systray must not create + session rows on every page load. + """ + return self.search_count( + [ + ("company_id", "=", self.env.company.id), + ("user_id", "=", self.env.user.id), + ("state", "!=", "done"), + ] + ) + def action_open_for_current_user(self): session = self.get_or_create_for_current_user() return { diff --git a/farm_onboarding/readme/DESCRIPTION.md b/farm_onboarding/readme/DESCRIPTION.md index 0b63335..3792c1b 100644 --- a/farm_onboarding/readme/DESCRIPTION.md +++ b/farm_onboarding/readme/DESCRIPTION.md @@ -4,16 +4,28 @@ enterprise types), how you keep books today (QBO / QBD / Excel / paper / nothing), done — with a state machine, progress bar, save-as-you-go, and back/next/skip/restart actions. -This MVP uses a regular form view with state-conditional groups so -sessions persist across browser closes. The original plan called for an -OWL client action with full-screen modal; that polish is deferred to -v1 in favor of shipping the data model and flow first. +The wizard surfaces itself two ways: + +- **Navbar bell.** A leaf icon with a red badge dot appears in the + systray when the current farm user has an unfinished session. Click + it to jump straight into the wizard. The bell is hidden for users + outside `farm_base.group_farm_user` and disappears once the session + is marked done. +- **Farm → Setup Wizard menu item.** Same destination, accessible at + any time for a re-run. + +The form itself is a regular Odoo form view with state-conditional +groups so sessions persist across browser closes. A richer custom- +chrome design pass lives in a follow-on PR (Step 2 of the UX +refinement plan). Adds 12 pre-loaded `farm.enterprise.type` records (eggs, vegetables, fruit, herbs, orchard, cattle, dairy, poultry, hogs, sheep/goats, value- added, workshops) with emoji icons — these drive product catalog and report pre-configuration in downstream modules. -The "Setup Wizard" menu item routes each user to their own open session -(creates one if none exists), so multiple farm-users on the same company -each get an independent walkthrough. +Each user gets their own session per company, so multiple farm-users on +the same company each get an independent walkthrough. The umbrella +`farm_pack` module's `post_init_hook` seeds a session for every existing +internal farm user on install; new users created later pick one up +lazily on first wizard open. diff --git a/farm_onboarding/readme/USAGE.md b/farm_onboarding/readme/USAGE.md index 26c04da..e97f303 100644 --- a/farm_onboarding/readme/USAGE.md +++ b/farm_onboarding/readme/USAGE.md @@ -1,8 +1,11 @@ -1. **Farm → Setup Wizard** — opens (or resumes) your active session. +1. **Look for the leaf icon + red dot in the navbar.** That's the + onboarding bell — click it to jump into the wizard. (Or use + **Farm → Setup Wizard** for the same destination.) 2. Click **Next** to step through: Welcome → Your Farm → What You Grow → Books Today → All Set. 3. Each screen saves on Next/Back so closing the browser doesn't lose progress. Skip jumps straight to Done. -4. Once done, the Farm menu's other items (Eggs, CSA, Markets, Delivery, - QuickBooks) are where the actual work happens — the wizard pre-tells - the pack what to surface for your operation. +4. Once done, the bell disappears and the Farm menu's other items + (Eggs, CSA, Markets, Delivery, QuickBooks) are where the actual work + happens — the wizard pre-tells the pack what to surface for your + operation. diff --git a/farm_onboarding/readme/newsfragments/+systray_bell.feature.md b/farm_onboarding/readme/newsfragments/+systray_bell.feature.md new file mode 100644 index 0000000..3301c3c --- /dev/null +++ b/farm_onboarding/readme/newsfragments/+systray_bell.feature.md @@ -0,0 +1,10 @@ +Adds a navbar systray bell (leaf icon + red badge dot) that surfaces +the setup wizard whenever the current farm user has an unfinished +onboarding session. The bell is hidden for users outside the +`farm_base.group_farm_user` group and disappears once the session +is marked done. + +New `farm.onboarding.session.count_pending_for_current_user` RPC +endpoint drives the bell's visibility — read-only, scoped to the +current `(user, company)`, kept separate from +`get_or_create_for_current_user` so page loads cannot create rows. diff --git a/farm_onboarding/static/description/index.html b/farm_onboarding/static/description/index.html index d0dfde5..94cee15 100644 --- a/farm_onboarding/static/description/index.html +++ b/farm_onboarding/static/description/index.html @@ -380,17 +380,29 @@

Farm Onboarding

enterprise types), how you keep books today (QBO / QBD / Excel / paper / nothing), done — with a state machine, progress bar, save-as-you-go, and back/next/skip/restart actions.

-

This MVP uses a regular form view with state-conditional groups so -sessions persist across browser closes. The original plan called for an -OWL client action with full-screen modal; that polish is deferred to v1 -in favor of shipping the data model and flow first.

+

The wizard surfaces itself two ways:

+ +

The form itself is a regular Odoo form view with state-conditional +groups so sessions persist across browser closes. A richer custom- +chrome design pass lives in a follow-on PR (Step 2 of the UX refinement +plan).

Adds 12 pre-loaded farm.enterprise.type records (eggs, vegetables, fruit, herbs, orchard, cattle, dairy, poultry, hogs, sheep/goats, value- added, workshops) with emoji icons — these drive product catalog and report pre-configuration in downstream modules.

-

The “Setup Wizard” menu item routes each user to their own open session -(creates one if none exists), so multiple farm-users on the same company -each get an independent walkthrough.

+

Each user gets their own session per company, so multiple farm-users on +the same company each get an independent walkthrough. The umbrella +farm_pack module’s post_init_hook seeds a session for every +existing internal farm user on install; new users created later pick one +up lazily on first wizard open.

Important

This is an alpha version, the data model and design can change at any time without warning. @@ -413,14 +425,16 @@

Farm Onboarding

Usage

    -
  1. Farm → Setup Wizard — opens (or resumes) your active session.
  2. +
  3. Look for the leaf icon + red dot in the navbar. That’s the +onboarding bell — click it to jump into the wizard. (Or use Farm → +Setup Wizard for the same destination.)
  4. Click Next to step through: Welcome → Your Farm → What You Grow → Books Today → All Set.
  5. Each screen saves on Next/Back so closing the browser doesn’t lose progress. Skip jumps straight to Done.
  6. -
  7. Once done, the Farm menu’s other items (Eggs, CSA, Markets, Delivery, -QuickBooks) are where the actual work happens — the wizard pre-tells -the pack what to surface for your operation.
  8. +
  9. Once done, the bell disappears and the Farm menu’s other items (Eggs, +CSA, Markets, Delivery, QuickBooks) are where the actual work happens +— the wizard pre-tells the pack what to surface for your operation.
diff --git a/farm_onboarding/static/src/js/onboarding_systray.esm.js b/farm_onboarding/static/src/js/onboarding_systray.esm.js new file mode 100644 index 0000000..7c4a99c --- /dev/null +++ b/farm_onboarding/static/src/js/onboarding_systray.esm.js @@ -0,0 +1,65 @@ +/** @odoo-module **/ + +import {Component, onWillStart, useState} from "@odoo/owl"; +import {registry} from "@web/core/registry"; +import {useService} from "@web/core/utils/hooks"; + +/** + * Systray bell that surfaces unfinished farm-onboarding sessions. + * + * Hidden when the current user has no pending session (count == 0), + * so non-farm users see nothing. When pending, a pulsing dot draws + * the eye; click opens the wizard via the existing + * `action_open_for_current_user` server action. + * + * Deliberately lightweight — one `search_count` RPC on mount, no + * polling. The bell hides immediately on click (optimistic); if the + * user backs out of the wizard without finishing, the next page + * reload will surface it again. + */ +export class FarmOnboardingSystray extends Component { + static template = "farm_onboarding.SystrayBell"; + static props = {}; + + setup() { + this.orm = useService("orm"); + this.action = useService("action"); + this.state = useState({pending: 0, loaded: false}); + + onWillStart(async () => { + // The systray is registered globally; users without + // farm_base.group_farm_user will hit AccessError on the + // search_count. Swallow it so we don't spam the console — + // a user who can't access the wizard shouldn't see the bell. + try { + this.state.pending = await this.orm.call( + "farm.onboarding.session", + "count_pending_for_current_user", + [] + ); + } catch { + this.state.pending = 0; + } finally { + this.state.loaded = true; + } + }); + } + + async openWizard() { + const action = await this.orm.call( + "farm.onboarding.session", + "action_open_for_current_user", + [] + ); + await this.action.doAction(action); + this.state.pending = 0; + } +} + +registry + .category("systray") + .add( + "farm_onboarding.SystrayBell", + {Component: FarmOnboardingSystray}, + {sequence: 100} + ); diff --git a/farm_onboarding/static/src/xml/onboarding_systray.xml b/farm_onboarding/static/src/xml/onboarding_systray.xml new file mode 100644 index 0000000..a8685d7 --- /dev/null +++ b/farm_onboarding/static/src/xml/onboarding_systray.xml @@ -0,0 +1,28 @@ + + + + +
+