[IMP] web, *: milk adaptations

*: hr_holidays, stock, sale, product, web, sale, purchase, stock,
   website, survey

Adapt some custom control panels (mainly for custom reports) to the
milk controlpanel.

hr_holidays:
Move the buttons to create a new time off or a new allocation to the
"create button" slot and transform it into a dropdown (creating
allocation requests is clearly a secondary action, not a primary one)

stock:
3 lines does not fit, must be on 2 lines

Part-of: odoo/odoo#116641
This commit is contained in:
Damien Bouvy
2023-05-12 22:59:19 +02:00
committed by Pierre Paridans
parent 1136803dc5
commit 1e706d3069
18 changed files with 119 additions and 109 deletions
@@ -3,6 +3,7 @@
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { CalendarController } from '@web/views/calendar/calendar_controller';
import { FormViewDialog } from '@web/views/view_dialogs/form_view_dialog';
import { Dropdown, DropdownItem } from "@web/core/dropdown/dropdown";
import { serializeDate } from "@web/core/l10n/dates";
@@ -113,5 +114,8 @@ export class TimeOffCalendarController extends CalendarController {
}
TimeOffCalendarController.components = {
...TimeOffCalendarController.components,
Dropdown,
DropdownItem,
FilterPanel: TimeOffCalendarFilterPanel,
}
TimeOffCalendarController.template = "hr_holidays.CalendarController"
@@ -1,17 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="hr_holidays.CalendarController.controlButtons" t-inherit="web.CalendarController.controlButtons" t-inherit-mode="primary" owl="1">
<xpath expr="." position="inside">
<span class="o_timeoff_buttons">
<button class="btn btn-primary btn-time-off mx-1" t-on-click="newTimeOffRequest" type="button">
New Time Off
</button>
<button class="btn btn-secondary" t-on-click="newAllocationRequest" type="button">
<t t-if="employeeId">New</t> Allocation Request
</button>
</span>
<t t-name="hr_holidays.CalendarController" t-inherit="web.CalendarController" t-inherit-mode="primary" owl="1">
<xpath expr="//Layout" position="inside">
<t t-set-slot="control-panel-create-button">
<span class="o_timeoff_buttons btn-group">
<div class="btn-group">
<button class="btn btn-primary btn-time-off " t-on-click="newTimeOffRequest" type="button">
New
</button>
<Dropdown togglerClass="'btn btn-primary'" showCaret="true" class="'btn-group'">
<button class="btn btn-link" t-on-click="newAllocationRequest" type="button">
New Allocation Request
</button>
</Dropdown>
</div>
</span>
</t>
</xpath>
</t>
</templates>
</templates>
@@ -14,8 +14,6 @@ const TimeOffCalendarView = {
Controller: TimeOffCalendarController,
Renderer: TimeOffCalendarRenderer,
Model: TimeOffCalendarModel,
buttonTemplate: "hr_holidays.CalendarController.controlButtons",
}
registry.category('views').add('time_off_calendar', TimeOffCalendarView);
@@ -3,7 +3,7 @@
<t t-name="mrp.BomOverviewControlPanel" owl="1">
<ControlPanel display="controlPanelDisplay">
<t t-set-slot="control-panel-bottom-left-buttons">
<t t-set-slot="control-panel-always-buttons">
<div class="o_cp_buttons">
<div class="o_list_buttons o_mrp_bom_report_buttons">
<button t-on-click="() => this.props.print()" type="button" class="btn btn-primary">Print</button>
@@ -15,47 +15,44 @@
</div>
</t>
<t t-set-slot="control-panel-top-right">
<form class="row gx-0">
<div class="col-lg-8 row">
<div class="col-lg-11 row gx-1 mb-2">
<label for="bom_quantity" class="col-xl-2 col-lg-3 col-sm-4">Quantity:</label>
<div t-attf-class="{{ props.showOptions.uom ? 'col-xl-7 col-lg-6 col-sm-5' : 'col-xl-10 col-lg-9 col-sm-8' }}">
<input id="bom_quantity" type="number" step="any" t-on-change="ev => this.updateQuantity(ev)" t-on-keypress="ev => this.onKeyPress(ev)" t-att-value="props.bomQuantity" min="1" class="o_input"/>
</div>
<div t-if="props.showOptions.uom" class="col-xl-3 col-lg-3 col-sm-3">
<span t-esc="props.uomName"/>
</div>
<t t-set-slot="layout-actions">
<div class="d-flex flex-column gap-1">
<form class="d-flex w-100 gap-2">
<label class="visually-hidden" for="bom_quantity">Quantity</label>
<div class="input-group">
<div class="input-group-text">Quantity</div>
<input id="bom_quantity" type="number" step="any" t-on-change="ev => this.updateQuantity(ev)" t-on-keypress="ev => this.onKeyPress(ev)" t-att-value="props.bomQuantity" min="1" class="o_input form-control text-end"/>
<div t-if="props.showOptions.uom" t-esc="props.uomName" class="input-group-text">Quantity</div>
</div>
<div t-if="props.showVariants" class="col-lg-11 row gx-1 mb-1">
<label class="col-xl-2 col-lg-3 col-sm-4">Variant:</label>
<div class="col-xl-10 col-lg-9 col-sm-8">
<select class="o_input" t-on-change="(ev) => this.props.changeVariant(ev.target.value)">
<option t-foreach="props.variants" t-as="variant" t-att-value="variant" t-key="variant">
<t t-esc="props.variants[variant]"/>
</option>
</select>
</div>
<t t-if="props.showVariants" >
<label class="visually-hidden" for="bom_quantity">Variant</label>
<div class="input-group">
<div class="input-group-text">Variant</div>
<select class="o_input form-control" t-on-change="(ev) => this.props.changeVariant(ev.target.value)">
<option t-foreach="props.variants" t-as="variant" t-att-value="variant" t-key="variant">
<t t-esc="props.variants[variant]"/>
</option>
</select>
</div>
</div>
</form>
</t>
<t t-set-slot="control-panel-bottom-right">
<div class="o_search_options">
<t t-if="props.warehouses.length > 1">
<Dropdown class="'btn-group'" togglerClass="'btn btn-secondary'">
<t t-set-slot="toggler">
<span class="fa fa-home"/> Warehouse: <span t-esc="props.currentWarehouse.name"/>
</t>
<t t-foreach="props.warehouses" t-as="wh" t-key="wh.id">
<DropdownItem onSelected="() => this.props.changeWarehouse(wh.id)" t-esc="wh.name"/>
</t>
</Dropdown>
</t>
<BomOverviewDisplayFilter
showOptions="props.showOptions"
changeDisplay.bind="props.changeDisplay"/>
</form>
<div class="d-flex w-100 gap-1">
<div class="col d-flex gap-1">
<t t-if="props.warehouses.length > 1">
<Dropdown class="'btn-group'" togglerClass="'btn btn-secondary'">
<t t-set-slot="toggler">
<span class="fa fa-home"/> Warehouse: <span t-esc="props.currentWarehouse.name"/>
</t>
<t t-foreach="props.warehouses" t-as="wh" t-key="wh.id">
<DropdownItem onSelected="() => this.props.changeWarehouse(wh.id)" t-esc="wh.name"/>
</t>
</Dropdown>
</t>
<BomOverviewDisplayFilter
showOptions="props.showOptions"
changeDisplay.bind="props.changeDisplay"/>
</div>
</div>
</div>
</t>
</ControlPanel>
@@ -5,7 +5,7 @@
<Dropdown class="'btn-group'" togglerClass="'btn btn-secondary'">
<t t-set-slot="toggler">
<span class="fa fa-filter"/>
Display: <span t-esc="currentDisplayedNames"/>
Display: <span class="text-wrap" t-esc="currentDisplayedNames"/>
</t>
<t t-foreach="displayableOptions" t-as="optionKey" t-key="optionKey">
<DropdownItem parentClosingMode="'none'" class="{ o_menu_item: true, selected: props.showOptions[optionKey] }" onSelected="() => this.props.changeDisplay(optionKey)" t-esc="displayOptions[optionKey]"/>
@@ -2,14 +2,16 @@
<templates xml:space="preserve">
<div t-name="mrp.MoOverview" class="o_action" owl="1">
<Layout display="{ controlPanel: { 'top-right': false } }">
<t t-set-slot="control-panel-bottom-right">
<Layout display="{ controlPanel: {} }">
<t t-set-slot="layout-actions">
<MoOverviewDisplayFilter showOptions="state.showOptions" limited="state.isDone" changeDisplay.bind="onChangeDisplay"/>
</t>
<t t-set-slot="control-panel-bottom-left">
<button class="btn btn-primary" t-on-click="onPrint">Print</button>
<button class="btn btn-primary" t-on-click="onUnfold">Unfold</button>
<t t-set-slot="control-panel-create-button">
<div class="d-flex gap-1">
<button class="btn btn-primary" t-on-click="onPrint">Print</button>
<button class="btn btn-primary" t-on-click="onUnfold">Unfold</button>
</div>
</t>
<div class="py-3 py-lg-5 overflow-auto border-bottom bg-view">
@@ -5,16 +5,16 @@
<t t-name="product.ProductPricelistReport" owl="1">
<div class="o_action">
<Layout display="{ controlPanel: { 'bottom-right': false } }">
<t t-set-slot="control-panel-bottom-left">
<t t-set-slot="control-panel-always-buttons">
<button t-on-click="onClickPrint" type="button" class="btn btn-primary" title="Print">Print</button>
</t>
<t t-set-slot="control-panel-top-right">
<form class="o_pricelist_report_form d-flex flex-column ">
<div class="d-flex align-items-center gap-3 w-100 ">
<div class="d-flex align-items-center">
<label class="fw-bold">Pricelist:</label>
<div class="o_select_dropdown">
<select name="pricelists"
<t t-set-slot="layout-actions">
<form class="o_pricelist_report_form d-flex flex-column gap-1">
<div class="d-flex align-items-center gap-3 w-100">
<label class="visually-hidden" for="pricelists">Username</label>
<div class="input-group w-auto">
<div class="input-group-text fw-bold">Pricelist</div>
<select name="pricelists"
id="pricelists"
class="o_select form-select border-0"
t-on-change="onSelectPricelist">
@@ -25,20 +25,20 @@
</t>
</t>
</select>
</div>
</div>
<div class="form-check m-0 p-0">
<div class="form-check w-auto">
<input class="o_display_pricelist_title form-check-input ms-0 me-2"
id="display_pricelist_title"
type="checkbox"
t-att-checked="displayPricelistTitle"
t-on-click="onToggleDisplayPricelist"/>
<label class="form-check-label">Display Pricelist</label>
<label for="display_pricelist_title" class="form-check-label">Display Pricelist</label>
</div>
</div>
<div class="d-flex align-items-center gap-3 w-100">
<div class="input-group d-flex flex-nowrap w-50" style="min-width:210px;">
<span class="input-group-text fw-bold">
Quantities:
Quantities
</span>
<input type="number"
class="form-control add-quantity-input"
+6 -6
View File
@@ -90,9 +90,9 @@
groups="purchase.group_purchase_user"
type="object" icon="fa-credit-card" attrs="{'invisible': [('purchase_ok', '=', False)]}" help="Purchased in the last 365 days">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="purchased_product_qty" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="purchased_product_qty" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">Purchased</span>
</div>
@@ -111,9 +111,9 @@
groups="purchase.group_purchase_user"
type="object" icon="fa-credit-card" attrs="{'invisible': [('purchase_ok', '=', False)]}" help="Purchased in the last 365 days">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="purchased_product_qty" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="purchased_product_qty" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">Purchased</span>
</div>
+6 -6
View File
@@ -49,9 +49,9 @@
groups="sales_team.group_sale_salesman"
attrs="{'invisible': [('sale_ok', '=', False)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="sales_count" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="sales_count" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">Sold</span>
</div>
@@ -82,9 +82,9 @@
groups="sales_team.group_sale_salesman"
attrs="{'invisible': [('sale_ok', '=', False)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="sales_count" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="sales_count" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">Sold</span>
</div>
@@ -2,7 +2,7 @@
<templates>
<div t-name="spreadsheet_dashboard.DashboardAction" owl="1" class="o_action o_spreadsheet_dashboard_action o_field_highlight">
<ControlPanel display="controlPanelDisplay">
<t t-set-slot="control-panel-top-right">
<t t-set-slot="layout-actions">
<t t-set="status" t-value="state.activeDashboard and state.activeDashboard.status"/>
<FilterValue
t-if="status === Status.Loaded"
@@ -3,7 +3,7 @@
<div t-name="stock.ReceptionReportMain" class="o_action" owl="1">
<ControlPanel display="controlPanelDisplay">
<t t-set-slot="control-panel-bottom-left-buttons">
<t t-set-slot="control-panel-always-buttons">
<div class="o_cp_buttons" role="toolbar" aria-label="Control panel buttons">
<div class="d-inline-block">
<button t-on-click="onClickPrint" type="button" class="btn btn-primary" title="Print">Print</button>
@@ -2,10 +2,10 @@
<templates id="template" xml:space="preserve">
<div t-name="stock.Forecasted" class="o_action" owl="1">
<ControlPanel display="{ 'top-right' : false }">
<t t-set-slot="control-panel-bottom-left-buttons">
<t t-set-slot="layout-buttons">
<ForecastedButtons action="props.action" reloadReport.bind="reloadReport" resModel="resModel"/>
</t>
<t t-set-slot="control-panel-bottom-right">
<t t-set-slot="layout-actions">
<div class="btn-group o_search_options position-static" role="search">
<ForecastedWarehouseFilter action="props.action" warehouses="warehouses" setWarehouseInContext.bind="updateWarehouse"/>
</div>
+12 -12
View File
@@ -263,9 +263,9 @@
type="object"
attrs="{'invisible':[('show_on_hand_qty_status_button', '=', False)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="qty_available" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="qty_available" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">On Hand</span>
</div>
@@ -276,9 +276,9 @@
context="{'default_product_id': id, 'active_model': 'product.template'}"
class="oe_stat_button" icon="fa-cubes">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="virtual_available" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="virtual_available" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">Forecasted</span>
</div>
@@ -370,9 +370,9 @@
attrs="{'invisible':[('show_on_hand_qty_status_button', '=', False)]}"
class="oe_stat_button" icon="fa-cubes">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value" widget="statinfo">
<field name="qty_available" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="qty_available" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">On Hand</span>
</div>
@@ -383,9 +383,9 @@
context="{'default_product_tmpl_id': id}"
class="oe_stat_button" icon="fa-cubes">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="virtual_available" widget="statinfo" nolabel="1" class="mr4"/>
<field name="uom_name"/>
<span class="o_stat_value d-flex gap-1">
<field name="virtual_available" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="uom_name" class="oe_inline"/>
</span>
<span class="o_stat_text">Forecasted</span>
</div>
@@ -30,6 +30,9 @@
.o_kanban_record {
width: 100%;
margin: 0px;
}
.o_survey_kanban_card {
border-top: 0px !important;
}
}
+8 -8
View File
@@ -244,10 +244,10 @@
<div class="col-lg-2 col-sm-8 py-0 my-2 my-lg-0 col-12">
<div class="d-flex flex-grow-1 flex-column my-0 my-lg-2">
<span class="fw-bold"><field name="title"/></span>
<span t-if="!selection_mode">
<span t-if="!selection_mode" class="d-flex align-items-center">
<field name="user_id" widget="many2one_avatar_user"
options="{'display_avatar_name': True}"/>
-
<span class="mx-1">-</span>
<t t-esc="luxon.DateTime.fromISO(record.create_date.raw_value).toFormat('MMM yyyy')"/>
</span>
</div>
@@ -292,34 +292,34 @@
<span class="text-muted" t-else="">Certified</span>
</a>
</div>
<div t-if="!selection_mode" class="col-lg-3 col-sm-12 d-none d-sm-block py-0 my-2 pb-lg-3 ms-auto text-lg-end">
<div t-if="!selection_mode" class="col-lg-3 col-sm-12 d-none d-sm-flex justify-content-end gap-2 my-2 ms-auto pb-lg-3 py-0">
<button name="action_send_survey"
string="Share" type="object"
class="btn btn-secondary border"
class="btn btn-secondary"
attrs="{'invisible': [('active', '=', False)]}">
Share
</button>
<button name="action_test_survey"
string="Test" type="object"
class="btn btn-secondary border"
class="btn btn-secondary"
attrs="{'invisible': [('active', '=', False)]}">
Test
</button>
<button name="action_result_survey"
string="See results" type="object"
class="btn btn-secondary border"
class="btn btn-secondary"
attrs="{'invisible': [('active', '=', False)]}">
See results
</button>
<button name="action_start_session"
string="Start Live Session" type="object"
class="btn btn-secondary border"
class="btn btn-secondary"
attrs="{'invisible': ['|', '|', ('session_state', '!=', False), ('certification', '=', True), ('active', '=', False)]}">
Start Live Session
</button>
<button name="action_end_session"
string="End Live Session" type="object"
class="btn btn-secondary border"
class="btn btn-secondary"
attrs="{'invisible': ['|', ('session_state', 'not in', ['ready', 'in_progress']), ('active', '=', False)]}">
End Live Session
</button>
@@ -36,7 +36,7 @@
</t>
<t t-set-slot="control-panel-additional-actions">
<div t-if="nbSelected" class="d-flex ms-3">
<div t-if="nbSelected" class="d-flex ms-3 gap-1">
<t t-call="web.ListView.Selection"/>
<t t-foreach="archInfo.headerButtons" t-as="button" t-key="button.id">
<MultiRecordViewButton
@@ -4,7 +4,7 @@
<t t-name="web.ReportAction" owl="1">
<div class="o_action">
<Layout display="{ controlPanel: { 'top-right' : false, 'bottom-right': false } }">
<t t-set-slot="control-panel-bottom-left">
<t t-set-slot="control-panel-create-button">
<button t-on-click="print" type="button" class="btn btn-primary" title="Print">Print</button>
</t>
<iframe t-ref="iframe" t-on-load="onIframeLoaded" class="h-100 w-100" t-att-src="reportUrl" />
@@ -2,7 +2,7 @@
<templates xml:space="preserve">
<t t-name="website.RedirectField" owl="1">
<button type="button" class="oe_stat_button btn btn-light w-100 mb-0 py-0 border-0 border-start border-bottom rounded-0 text-start text-nowrap text-capitalize"
<button type="button" class="btn oe_stat_button btn-outline-secondary flex-grow-1 flex-lg-grow-0"
t-on-click="onClick"
t-att-aria-label="info"
t-att-title="info">