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

Add config boolean to force mobile view always #1304

Open
wants to merge 1 commit into
base: 12.0
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions pos_mobile/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ def pos_web(self, debug=False, **k):
if pos_sessions and pos_sessions.config_id.auto_mobile:
session_info = request.env["ir.http"].session_info()
session_info["auto_mobile"] = True
if pos_sessions.config_id.force_mobile:
session_info["force_mobile"] = True
response.qcontext.update({"session_info": json.dumps(session_info)})
return response
5 changes: 5 additions & 0 deletions pos_mobile/models/pos_config_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ class PosConfig(models.Model):
help="Switch to Mobile view automatically depending on device",
default=True,
)
force_mobile = fields.Boolean(
"Force Mobile View",
help="Force switch to Mobile view",
default=False,
)
2 changes: 2 additions & 0 deletions pos_mobile/views/pos_mobile_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ var MobileCheck = function MobileCheck() {
var force_mobile = getUrlParameter('m');
if (force_mobile === "1") {
odoo.is_mobile = true;
} else if (odoo.session_info.force_mobile) {
odoo.is_mobile = true;
} else if (force_mobile === "0") {
odoo.is_mobile = false;
} else if (odoo.session_info.auto_mobile && MobileCheck()) {
Expand Down
11 changes: 11 additions & 0 deletions pos_mobile/views/pos_mobile_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="force_mobile" />
</div>
<div class="o_setting_right_pane">
<label for="force_mobile" />
<div class="text-muted">
Force switch to Mobile view (depends of Auto Mobile View)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What means depends of Auto Mobile View?

Copy link
Author

Choose a reason for hiding this comment

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

When is checked Auto Mobile View, this check forces Moble View always, for example if you have a desktop computer but wants to have mobile view.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could hide this option if auto_mobile is off. This way is more user friendly

</div>
</div>
</div>
</xpath>
</field>
</record>
Expand Down