There is some non-obvious issue with external dependency in modules,
which I want to say.
Let you need to use some python lib, which is not available in system
by default and should be installed manually.
So you just make import:
And maybe you mention required dependence in module's
description. Very simple, right? But…
The case could crash odoo completely.
This is scenario when it could happen:
User is not going to use your module with external dependency, but
your module available in Local Modules. E.g. if have a lot of
modules in your git repository and user just makes git clone and
add path to repo to addons-path.
User's system doesn't have required dependency
Your module has static/ folder, e.g. to place icon.png file.
Then right after restarting server, user would get error:
Whenever you use external dependency, put your import code in try block
and add external_dependencies to module's manifest:
It will check dependencies before installing and will not raise
ImportError if user doesn't use module.
Odoo is opensource and has module structure. So, for the question
– Is it possible to change /this/ in Odoo?
the only answer is:
– Yes, everything is possible to do in Odoo.
OK, but how to do that? Where to find an instruction of how to implement some particular feature?
Let's take an example. Imagine we need a custom link for product at
website shop. By default link is generated from Name field, but you
need to make it be generated from new Name SEO field.
i.e. instead of this link:
there should be this one:
where product has fields:
Name: iPad Mini
Name SEO: Super SEO link for iPad Mini
How to do that? Can we find the answer in documentation? I believe, it
doesn't have an answer.
So, let's try to do it ourself. We have Odoo source, so let's try to
find a solution there.
In our example we can start from seaching by /shop/product/:
These lines from addons/website_sale/controllers/main.py looks interesting:
What about <model("product.template"):product>? What is it? How it
works? There should be a way for you to find the answer in
source. Maybe you know about werkzeug library, maybe you know about
slug function, maybe you know about ir.http model. So there should
be a keyword to search. At the worst you can search by "model"
keyword OR look through whole website module.
OK, I found the answer in addons/website/models/ir_http.py. Function to_url is what we need.
where slug function is from addons/website/models/website.py
So, that is. To make a custom link, we have to inherit ModelConverter
and modify to_url function. Something like that:
Odoo has a good integration with emails. It allows to have a discussion
with a customer attached to some record (task, lead, invoice etc.).
In the main, your customer don't know about this and can send emails
(e.g. about a task) to your personal alias
(e.g. admin@yourcompany). It could not be a problem, if you work on
task alone. But if you need to share mail to colleagues, it's better
to move (attach) mail to task form. I've made module
mail_move_message to do it.
Technically, the module update fields res_id and model of
mail.message table. It also keeps original values to allow to move
If you have a lot of users and you want to control their email
signature, then signature template is what you need. With my module
res_users_signature you can create signature template and apply one
for your users.
A user can choose his signature template himself at Preference window (which
is opened via top right hand menu).
Technically the module make minimal changes at user model. It just put new
value to signature field at res.users model.
The module updates signature if there are changes at basic users
models (res.users, res.partner, hr.employee). E.g. if a user
change his phone number, then his signature would be updated. Also,
you can update all signatures manually.
You can use base64-encoded images at signature template:
I've found, that some email clients doesn't show such images. In order
to fix it, the module overwrite build_email function at
ir.mail_server model. The module make attachments from base64 images
at email body.