Developing a module for an enterprise package
Adding to an enterprise package without touching its standard, using Odoo as the example: a module's anatomy, dependencies, extending a model and a screen, computed fields, access rights and surviving a version upgrade.
- 23 cards
- 5 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- Scenarios
- Understand
A few cards from the deck
Package module: what is it?
Show the answer
A self-contained folder that groups a manifest, models, views, rights and data, and that is installed or removed without touching the rest of the application.
All of Odoo is made of modules, sales and invoicing included. Adding a feature means writing one more module, stacked on top of the others.
What does this code do?
```python
class SaleOrder(models.Model):
_inherit = 'sale.order'
return_date = fields.Date()`- It adds
return_dateto the existingsale.ordermodel, in its table - It creates a separate new model, a copy of
sale.order, with its own table - It replaces the
sale.ordermodel with a class that only has this field - It edits the
salemodule's file to write the added field into it
Show the answer
It adds
return_dateto the existingsale.ordermodel, in its tableWith
_inheritalone, you complete the existing model. Adding a different_namewould give a copy in a new table. Thesalefile is never touched.- It adds
In the manifest, the … key lists the modules to install before ours, and the … key lists the view, rights and data files loaded at installation.
Show the answer
In the manifest, the depends key lists the modules to install before ours, and the data key lists the view, rights and data files loaded at installation.
Odoo installs the dependencies first, then loads the
datafiles in list order: rights and groups before the views that use them.Module manifest: what is it?
Show the answer
The
__manifest__.pyfile that describes the module: its name, its version, the modules it depends on and the list of data and view files to load.Without it, Odoo ignores the folder. A file that refers to another module's model or view is only sure to find them if that module is listed in
depends: otherwise, installation can fail.The loan module is installed, but salespeople get "Access denied" on the new loan model, while the technical administrator can open it. What do you do?
- Put all the salespeople in the technical administrators' group so that they can get in
- Make the borrower field required in the loan model, then update the module
- Add
'sale'to the manifest'sdependslist, then fully reinstall the module - Add a line in
ir.model.access.csvthat gives the salespeople's group its rights on the model
Show the answer
Add a line in
ir.model.access.csvthat gives the salespeople's group its rights on the modelA new model is only open to the groups that a line of that file names: here, only administrators have one. Making salespeople administrators would open far more than loans: grant only what is needed.