I'm building a custom odoo module that will be using several Javascript libraries.
I need to add references to those libraries (local references) but I don't know exactly where to place those libraries and how to refer to their location.
What I tried:
- I created the new module and placed the libraries inside the module directory but it didn't work.
- I also placed the libraries in the home directory of odoo.
As I understand, the problem would be solved if I could get the default directory of the webserver that odoo runs on.
If module is using js files, then you must put these files inside your module. And still if you cant reach these files from your module its your technical error and you have to fix it yourself, also note that odoo has its js libraries already
I found this page: how to add css and js files in Openerp 7 / Odoo module maybe can help you.
Below is the content.
Store files correctly:
CSS and JS files should be reside under 'static' directory in the module(the rest of subdirectory tree under 'static' is an optional convention):
static/src/css/your_file.css
static/src/js/your_file.js
Add files in manifest (v7.0) or in XML(v8.0)
Openerp v7.0 way is to add following entries in manifest (in openerp.py):
...
'css': ['static/src/css/your_file.css'],
'js': [static/src/js/your_file.js'],
...
Odoo v8.0 way is to add corresponding record in the XML:
Add XML to the manifest (openerp.py):
...
'data': [ 'your_file.xml'],
...
Then add following record in 'your_file.xml':
<data>
<template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/>
<script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script>
</xpath>
</template>
....
....
</data>
Related
How can I install "bootstrap_3_layout.html.twig,... for my project on 3 version Symfony?
When I copy these files to my project I get error:
'Unexpected character "&"' (Twig_Error_Syntax).
Don't copy or past these files, but instead configure the TwigBundle to use them as form templates, make this configuration in your config.yml file
twig:
form_themes:
- bootstrap_3_layout.html.twig
Make sure that bootstrap is used in your application
Use this
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
Or download it and use it in your application
Today I have read the document of Google Maps Android API v2, it said the project of android-sdk\extras\google\google_play_services\samples\maps can run,
but after I imported into eclipse and set the libraries of android-support-v4.jar and google-play-services.jar correctly, import com.example.mapdemo.R; in FeatureView.java (at line 24) can not find the file R.java.
almost all the java file in com.example.mapdemo need class "R", for example, the file BasicMapActivity.java need R in line 41 "setContentView(R.layout.basic_demo);" and line 71 mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();"
can someone tell me how to find the class "R"?
R
.java can not create automatically because the file multimap_demo.xml have some errors in
<br><br> <fragment
<br> android:id="#+id/map3"
<br> android:layout_width="match_parent"
<br> android:layout_height="match_parent"
<br> android:layout_weight="0.5"
<br> class="com.google.android.gms.maps.SupportMapFragment"
<br> map:cameraTargetLat="48.85"
<br> map:cameraTargetLng="2.35"
<br> map:cameraZoom="8"/>
<br><br>
eclipse said "cameraTargetLat", "cameraTargetLng" and "cameraZoom" can not recognized.
The error information:
Multiple annotations found at this line:
- error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.example.mapdemo'
- error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.example.mapdemo'
- error: No resource identifier found for attribute 'cameraZoom' in package 'com.example.mapdemo'
I do not know why.
If I change the code like this:
<br><br> <fragment
<br> android:id="#+id/map3"
<br> android:layout_width="match_parent"
<br> android:layout_height="match_parent"
<br> android:layout_weight="0.5"
<br> class="com.google.android.gms.maps.SupportMapFragment"/>
<br><br>
the errors disappeared, but i do not know if it can run.
Copy the maps_attr.xml file from the library project into your project's values folder.
You should also import google-play-services_lib project (/extras/google/google_play_services/libproject/google-play-services_lib) - after that cameraTargetLat and other ones are recognized and R.java is generated.
you should import /extras/google/google_play_services/libproject/google-play-services_lib as a library in your project.
Import an existing android project at /extras/google/google_play_services/libproject/google-play-services_lib, but remember COPYING IT TO WORKSPACE(important, maybe the path of its original place occurs error)
See your project's properties->Android settings and add library "google-play-services"
Remember to add android-support-v4.jar & google-play-services.jar to your External JARs
1, include both external jar to project
2, copy \extras\google\google_play_services\libproject\google-play-services_lib\res\values\maps_attrs.xml to project value folder
3, copy google-play-services_lib to workspace looks no necessary in my test.
Update:
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable in android
I solved it just adding the following meta-data to the AndroidManifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
may be this answer can help someone.
this is due to a silly mistake, both the projects ie. Sample project of Map and Google play service project must reside on the same directory otherwise it will not referenced properly
you need do copy projects into workplace for both the projects or if you don't want to copy, so don't do it for both this is the glitch. if you do it properly then you will find this
you have to include xmlns:map="http://schemas.android.com/apk/res-auto" to your layout xml for using map element.
The R file is autogenerate by Eclipse, and you can find it in gen directory. Don't edit this file ever! In some case, you will find there more than one R file, for example when you add a library to your project, like google-play-services_lib. You always can refere to this file at code like this...
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(com.your.package.R.id.map)).getMap();
If you want to configure your map, is posible to make it by XML Attributes or Programmatically.
I have a problem with path to javascript in my GWT html.
I get: WARNING: No file found for: /smartajax/libs/historyjs/history.html4.js and more like this
File exists in my war/html1 dir.
It happens only if script like this above is called not from my Html1.html, but from other script that is in public (its not declared in html by <script type="text/javascript" ...>
- public_res
- smartajax
- libs
- historyjs
- war
- html1
- smartajax
- libs
- historyjs
<script type="text/javascript" src="html1/smartajax/load.smartajax.js"></script>
How to solve this?
You should ideally place all your third party scripts in same relative folder.
1) All in public/thirdparty
2) All in war/thirdparty
Your gwt public resource folder is compiled into your module's folder, and not war base directory. It will be compiled into war/module_name/html1/smartajax/... So, instead of using relative uris, how about absolute uris?
GWT.getHostPageBaseURL() -> Base url for html page, http://x.y/
GWT.getModuleBaseURL() -> Base url for gwt module, http://x.y/module_name/
I solved the problem upto certain extent by using the following command
$applettviewer -J-Djava.security.policy=java.policy.applet MyApplet.html
it does not show any error like before.
I came to know that my Applet has to be signed even im running in my Local System.
This is my test.html
File Name : test.HTML
<html>
<applet code="*MyApplet.class*" archive="aws-java-sdk-1.2.12.jar,commons-codec-1.3.jar,commons-logging-1.1.1.jar,httpclient-4.1.1.jar,httpcore-4.1.jar,jackson-core-asl-1.4.3.jar,mail-1.4.3.jar,stax-1.2.0.jar,stax-api-1.0.1.jar" width="500" height="500"></applet>
</html>
my Folder structure is as follows:
bin/
|----------------- MyApplet.class
|----------------- AwsCredentials.properties
|----------------- mime.types
|----------------- required Jar Files
|----------------- java.policy.applet
|----------------- test.html ( HTML file to Load the Applet)
I dont know how to sign the Class file.
Please guide me.
Regards,
Ananthavel
I dont know how to sign the Class file.
See Steps for the Code Signer in the Java tutorial.
You need to build your project as jar file. Then using keytool and jarsigner located in bin folder of jdk you need to sign your applet
and change your html as
<applet code="MyApplet.class" archive="MyApplet.jar,aws-java-sdk-1.2.12.jar,commons-codec-1.3.jar,commons-logging-1.1.1.jar,httpclient-4.1.1.jar,httpcore-4.1.jar,jackson-core-asl-1.4.3.jar,mail-1.4.3.jar,stax-1.2.0.jar,stax-api-1.0.1.jar" width="500" height="500"></applet>
Let's say that I want to define a module "Pair" in com.mycompany.common such that the source is located in com.mycompany.common (and not com.mycompany.common.client). How would I do this? Alternatively, let's say that I have the flexibility of defining the module "Pair" in com.mycompany instead while still having the source in com.mycompany.common.
Thanks to a quick search on google, I found the answer myself. One can add a source path tag to the module xml file to define the source directory instead of leaving it to the default "client." For example, Pair.gwt.xml would look something like this:
<module>
...
<source path="."/>
...
</module>
... if we wanted the gwt.xml file to be in the same directory as the source.
But when compiling this module, we get a "Non-canonical source package: ./" warning. Is this ok to ignore?