How to modify files and folders structure of scaffold command? - odoo

I find myself use command scaffold to generate a template for a new module.
However, as I use it a lot, I need to tediously delete some files or some codes in order to make it into a structure I like most of the time. For example, I always delete control and demo folders, change some codes in init and manifest files, and add icon.
Is there any way I can do the modification and save it into the scaffold command so that every time I call it, it will generate according to my modification?

You can use scaffold -t or scaffold --template with your original source module name.
For example, build your template module and delete folders that you don't want to generate from scaffold.
Afterwards, pass that template module name when you generate a new scaffold module.
scaffold -t template_module new_customer_module_name destination_module_path
OR
scaffold --template template_module new_customer_module_name destination_module_path

Related

How I can add new module to odoo 15

I am new to Odoo and I need to know what is the basic steps of adding a new module.
More specifically I need to know how to add custom modules to the addons-path.
In Odoo document they explain this step as this
$ ./odoo-bin --addons-path=../custom,../enterprise/,addons
but did not work for me.
For adding a new module you should do these steps:
Build your module with your written code or scaffold command.
Add the module path in your config file at addons-path = '',''
Change your URL like this: http://localhost:8091/web?debug=1
Go to apps and from up tabs
Select update app list and refresh your page.
Now you can see your module in the apps.
If you are not getting your custom module in Odoo after adding the path then you can try to add the full path of your folder into addons-path.
To get the full path of your custom folder just right-click on the folder and go to properties and find the path of your folder.
Also, you have to make sure to Apply the Update App list in your Odoo App Dashboard after restarting the server with custom addons.

Does express-generator add a view after the scaffold is done?

What I am trying to understand is: If after creation of express -v pug -c sass projectoName
is it possible to add views using the scafold Express-generator. For example, a partial for the footer, another for the navbar and so on...
In short: How to add a new page with the tool?
The express generator is a tool for the initial app creation and configuration. It creates a basic app structures, configures the view engine, the css engine... But it stops there.
Once you have made the command express -v pug -c sass projectoName, you are done with the express-generator. If you want a new view (complete or partial), you have to create a new file (a pug file in this case) in your views folder, manually.
It is not like the Ruby on Rails generator for example which can generate views, models, or scaffold a full CRUD.
There are other frameworks, like Sails.js (based on express.js) which have a command line interface and a generate command.

Why doesn't my new Odoo module show up on the module list?

I am using Odoo v12 on Windows.
I have followed the steps in HowTo to create a module Saadoodoo. My problem is that I have failed to make this new module appear on the Odoo module list.
I am using the below command
python.exe odoo-bin" -d SaadoIncLocal -i Saadoodoo --addons-path D:\PythonDev\Odoo
It seems Odoo simply ignores the commands and starts the server normally, as the module does not appear on the apps list (even when selecting developer mode).
I thought the issue may be in the addon path, so I added the module under the default Odoo path along with Odoo modules in C:\Program Files (x86)\Odoo 12.0\server\odoo\addons and did an apps update on Odoo interface but still problem persists. Starting and stopping the server does not help either.
What am I doing wrong?
After adding new module in the addons_path, you have to turn on debug/developer mode, goto Apps > Update modules list, remove Apps filter from search and search your module.
Don't forget to add __manifest__.py with proper data, which is important for odoo addons.
If still having problem, you can use scaffold option of odoo-bin to create empty module.
python.exe odoo-bin scaffold my_module
This is will create a empty module with all the necessary skeleton files in the current working directory, you can just move it to addons folder, rename the variables accordingly and files and you are good to go.
There could be 2 Reasons that you are not able to see the module :-
1. You have not updated the database
Two ways to update the database :-
1.1 from Terminal use this command to update the module and database
./odoo-bin -c debian/odoo.conf -d {NAME_OF_ODOO_DATABASE} -u {NAME_OF_THE_NEW_MODULE}
1.2. From frontend
By activating the developer mode by going to Setting --> under the developer tools option --> Activate the developer mode
Now go to app list and select the option update app list.
2. You have not configured the addons path in the debian/odoo.conf file
Make sure that you have added the addons_path of the custom-addons folder in odoo.conf file inside debian folder
why don't you simply use these commands
cd C:\Program Files (x86)\Odoo 12.0\server\odoo\addons
C:\Program Files (x86)\Odoo 12.0\python\python.exe C:\Program Files (x86)\Odoo 12.0\server\odoo-bin scaffold my_module --config C:\Program Files (x86)\Odoo 12.0\server\odoo.conf
Oh once your module is ready, go to the Odoo directory in windows, navigate to custom-addons and you will see a list of all the available modules. paste your new module in there. Now open the Odoo again, go to Apps, then update module list. Then search for your app in the app list. Make sure the developer mode is activated
Go to your odoo-version folder (ex: cd /home-path/odoo-09.0/10.0/11.0/12.0/13.0) where your odoo-bin file is placed (till odoo-10.0 the file is openerp-server but in later version the file is odoo-bin)
Run the command ./odoo-bin scaffold yourModuleName destinationDirectory (odoo_version >= 10)
Run the command ./openerp-server scaffold your_module_name destinationDirectory (odoo_version < 10)
please use configuration file to run odoo(it's quite easy without any mistake)
run this command: python3 odoo-bin --save --config odoo.cfg --stop-after-init
that will save odoo.cfg file open it up and add your custom module path in addons_path varibale which is defined in top of configuartion file
using mode debug, go to your apps, click update app list
Use this command to create module in odoo.
odoo-bin scaffold mynewmodule addons
directive command module-name modulepath
Have you click Update App List in menu Apps?
This is screenshot from Odoo 11, it should applied in Odoo 12 but may be different position.

How to pass bundle id of extension as environment variable

I need to build an Xcode project within a Today Extension by 'xcodebuild'. The bundle is of the main target is com.myapp, while the bundle id of the extension is com.myapp.todayextension.
I'd like to pass both the bundle id's as parameters of xcodebuild: I tried to replace the bundle id's in the xcode project by custom environment variables (e.g. ${MAIN_TARGET_BUNDLEID} and ${EXTENSION_BUNDLEID}) but the xcodebuild fails. Could you please help me with the correct syntax of xcodebuild command ? Thanks.
That's called PRODUCT_BUNDLE_IDENTIFIER, as per the documentation.
Better too late than never; We can't directly use an environment variable in General tab, you will need to go into Build Settings tab, then set Product Bundle Identifier to your environment-variable, for example $(PRODUCT_NAME).
See below for another approach.
How to load prefix set by parent project?
Create an .xcconfig file (with content like example).
Set up the .xcconfig file in project settings's Info tab (not target's Info tab).
In target's Build Settings tab, ensure PRODUCT_BUNDLE_IDENTIFIER is not bold (click it and press delete).
But Podfile users should see also: How to make Xcode use multiple xcconfig files?
Example
My extension.xcconfig file (which is in MyApp/MyLib/MyExtension directory), looks something like:
// Below loads `MyApp/config/mylib.xcconfig` file.
#include "../../config/mylib.xcconfig"
PRODUCT_BUNDLE_IDENTIFIER = $(MYLIB_BUNDLE_PREFIX).$(PRODUCT_NAME)
Note that:
You want to use some environment as prefix, but above I use PRODUCT_NAME as suffix (simply edit as you wish).
The mylib.xcconfig file sets MYLIB_BUNDLE_PREFIX, and is outside of my MyLib.xcodeproj file's directory (so is in parent project's config directory, I describe in MyLib's README.md that users should create it there).
So, beside showing my #include approache, I try to introduce use of environment-variable.

Generating a single definition file from a external module typescript project

Having a multi file typescript project, using external modules.
If I compile with
tsc -d init.ts -m "commonjs"
Then all the files of the project get their own .d.ts file.
But I would like to generate one single .d.ts file for the whole project.
What's the best way to go about this?
But I would like to generate one single .d.ts file for the whole project. What's the best way to go about this?
At the moment it is handled in a hacky way by : https://github.com/TypeStrong/grunt-dts-bundle
More : https://github.com/Microsoft/TypeScript/issues/1236
You can generate a single d.ts and a .ts and .js bundle using the npm package TsProject.
Have a look at "npm-dts" package. I think it does exactly what you need.
Also, there is a plugin for WebPack called "npm-dts-webpack-plugin".