-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] web_pwa_oca: Added css classes to control the visibility of vie…
…w fields
- Loading branch information
1 parent
5d77fcb
commit 7e3ad78
Showing
21 changed files
with
943 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import res_config_settings | ||
from . import base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2022 Tecnativa - Alexandre D. Díaz | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from lxml import etree | ||
|
||
from odoo import api, models | ||
|
||
|
||
class BaseModel(models.BaseModel): | ||
_inherit = "base" | ||
|
||
def _fields_view_get( | ||
self, view_id=None, view_type="form", toolbar=False, submenu=False | ||
): | ||
"""Remove unused nodes depend on the standalone mode | ||
This is necessary to avoid problems with duplicated fields | ||
""" | ||
res = super()._fields_view_get( | ||
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu | ||
) | ||
is_client_standalone = self.env.context.get("client_standalone", False) | ||
doc = etree.XML(res["arch"]) | ||
if is_client_standalone: | ||
for node in doc.xpath("//*[contains(@class, 'oe_pwa_standalone_omit')]"): | ||
node.getparent().remove(node) | ||
else: | ||
for node in doc.xpath("//*[contains(@class, 'oe_pwa_standalone_only')]"): | ||
node.getparent().remove(node) | ||
res["arch"] = etree.tostring(doc, encoding="unicode") | ||
return res | ||
|
||
@api.model | ||
def load_views(self, views, options=None): | ||
standalone = options.get("standalone", False) if options else False | ||
return super( | ||
BaseModel, self.with_context(client_standalone=standalone) | ||
).load_views(views, options=options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Copyright 2021 Tecnativa - Alexandre D. Díaz | ||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ | ||
odoo.define("web_pwa_oca.AppsMenu", function(require) { | ||
"use strict"; | ||
|
||
const AppsMenu = require("web.AppsMenu"); | ||
require("web_pwa_oca.webclient"); | ||
const WebClientObj = require("web.web_client"); | ||
|
||
// This is used to reload last action when "prefetching" is done | ||
// to ensure display updated records | ||
AppsMenu.include({ | ||
/** | ||
* @override | ||
*/ | ||
openFirstApp: function() { | ||
const is_standalone = WebClientObj.pwa_manager.isPWAStandalone(); | ||
if (is_standalone) { | ||
const _sup = this._super; | ||
WebClientObj.menu_dp | ||
.add( | ||
this._rpc({ | ||
model: "res.config.settings", | ||
method: "get_pwa_home_action", | ||
}) | ||
) | ||
.then(action_id => { | ||
if (action_id) { | ||
return this.do_action(action_id).then(() => { | ||
WebClientObj.menu.change_menu_section( | ||
WebClientObj.menu.action_id_to_primary_menu_id( | ||
action_id | ||
) | ||
); | ||
}); | ||
} | ||
return _sup.apply(this, arguments); | ||
}); | ||
} else { | ||
return this._super(this, arguments); | ||
} | ||
}, | ||
}); | ||
}); |
Oops, something went wrong.