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

[14.0][PORT] 120 from 13.0 #141

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion shopfloor/services/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class ShopfloorApp(Component):
def user_config(self):
profiles_comp = self.component("profile")
profiles = profiles_comp._to_json(profiles_comp._search())
return self._response(data={"profiles": profiles})
user_comp = self.component("user")
user_info = user_comp._user_info()
return self._response(data={"profiles": profiles, "user_info": user_info})


class ShopfloorAppValidator(Component):
Expand All @@ -39,6 +41,7 @@ class ShopfloorAppValidatorResponse(Component):

def user_config(self):
profile_return_validator = self.component("profile.validator.response")
user_return_validator = self.component("user.validator.response")
return self._response_schema(
{
"profiles": {
Expand All @@ -49,5 +52,10 @@ def user_config(self):
"schema": profile_return_validator._record_schema,
},
},
"user_info": {
"type": "dict",
"required": True,
"schema": user_return_validator._user_info_schema(),
},
}
)
32 changes: 32 additions & 0 deletions shopfloor/services/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2020 Camptocamp SA (http://www.camptocamp.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.addons.base_rest.components.service import to_int
from odoo.addons.component.core import Component


Expand All @@ -17,6 +18,17 @@ def menu(self):
menus = menu_comp._to_json(menu_comp._search())
return self._response(data={"menus": menus})

# TODO: this endpoint does not require profile header
def user_info(self):
return self._response(data={"user_info": self._user_info()})

def _user_info(self):
return self.env.user.jsonify(self._user_info_parser, one=True)

@property
def _user_info_parser(self):
return ["id", "name"]


class ShopfloorUserValidator(Component):
"""Validators for the User endpoints"""
Expand All @@ -28,6 +40,9 @@ class ShopfloorUserValidator(Component):
def menu(self):
return {}

def user_info(self):
return {}


class ShopfloorUserValidatorResponse(Component):
"""Validators for the User endpoints responses"""
Expand All @@ -50,3 +65,20 @@ def menu(self):
},
}
)

def user_info(self):
return self._response_schema(
{
"user_info": {
"type": "dict",
"required": True,
"schema": self._user_info_schema(),
}
}
)

def _user_info_schema(self):
return {
"id": {"coerce": to_int, "required": True, "type": "integer"},
"name": {"type": "string", "nullable": False, "required": True},
}
1 change: 1 addition & 0 deletions shopfloor/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ def test_user_config(self):
}
for profile in profiles
],
"user_info": {"id": self.env.user.id, "name": self.env.user.name},
},
)
8 changes: 8 additions & 0 deletions shopfloor/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ def test_menu_by_profile(self):
response,
data={"menus": [self._data_for_menu_item(menu)]},
)

def test_user_info(self):
"""Request /user/user_info"""
response = self.service.dispatch("user_info")
self.assert_response(
response,
data={"user_info": {"id": self.env.user.id, "name": self.env.user.name}},
)
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Vue.component("picking-select-package-content", {
<div class="qty">
<span class="label">Qty:</span> <span>{{ record.qty_done }} / {{ record.quantity }}</span>
</div>
<div class="vendor-code">
<span class="label">Vendor code:</span> <span>{{ record.product.supplier_code }}</span>
</div>
</div>
</div>
`,
Expand Down
15 changes: 15 additions & 0 deletions shopfloor_mobile/static/wms/src/components/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ Vue.component("Screen", {
<nav-items :navigation="navigation" :show_full_info="false" />
<nav-items-extra />
</v-list>
<template v-slot:append>
<v-divider></v-divider>
<v-list v-if="$root.user.id">
<v-list-item>
<v-list-item-avatar>
<v-avatar color="primary" size="36">
<v-icon dark>mdi-account-circle</v-icon>
</v-avatar>
</v-list-item-avatar>
<v-list-item-content>
<span v-text="$root.user.name" />
</v-list-item-content>
</v-list-item>
</v-list>
</template>
</v-navigation-drawer>
<v-app-bar
color="#491966"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ Vue.component("searchbar", {
data: function () {
return {
entered: "",
autofocus: {
type: Boolean,
default: true,
},
};
},
props: {
autofocus: {
type: Boolean,
default: true,
},
autocomplete: {
type: String,
default: "off",
},
input_placeholder: String,
input_data_type: String,
reset_on_submit: {
Expand Down Expand Up @@ -51,6 +55,7 @@ Vue.component("searchbar", {
required v-model="entered"
:placeholder="input_placeholder"
:autofocus="autofocus ? 'autofocus' : null"
:autocomplete="autocomplete"
/>
</v-form>
`,
Expand Down
3 changes: 3 additions & 0 deletions shopfloor_mobile/static/wms/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ const app = new Vue({
profiles: function () {
return this.appconfig ? this.appconfig.profiles || [] : [];
},
user: function() {
return this.appconfig ? this.appconfig.user_info || {} : {};
},
appmenu: {
get: function () {
if (_.isEmpty(this.profile_menu)) {
Expand Down
1 change: 1 addition & 0 deletions shopfloor_mobile/static/wms/src/scenario/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ const Checkout = {
return {
multiple: true,
initSelectAll: true,
card_klass: "loud-labels",
list_item_component: "picking-select-package-content",
list_item_options: {actions: ["action_qty_edit"]},
};
Expand Down
15 changes: 15 additions & 0 deletions shopfloor_mobile/static/wms/src/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ export var SettingsControlPanel = Vue.component("settings-control-panel", {
},
template: `
<Screen :screen_info="{title: $t('screen.settings.home.title'), klass: 'settings settings-control-panel'}">

<v-card outlined v-if="$root.user.id">
<v-list>
<v-list-item>
<v-list-item-avatar>
<v-avatar color="primary" size="36">
<v-icon dark>mdi-account-circle</v-icon>
</v-avatar>
</v-list-item-avatar>
<v-list-item-content>
<span v-text="$root.user.name" />
</v-list-item-content>
</v-list-item>
</v-list>
</v-card>
<div class="button-list button-vertical-list full">
<v-row align="center">
<v-col class="text-center" cols="12">
Expand Down