Skip to main content

Assessments

Chapter 1

  1. What are the relevant layers to consider when designing an Odoo application?
First focus on the Data layer, structuring the data model, the models needed and their relations. Entity-relationship diagrams (ERDs) can be a useful tool for this.
Then think about the Presentation layer—how the user interface will be organized to fit the use cases to be supported.
Finally, think about the Logic layer, supporting the required business rules. These can be validations, automation, or helper features.
  1. How is Developer mode enabled?
Developer Mode, making available the Settings | Technical menu and the Debug contextual menu, can be enabled in the main Settings screen, using a link in the bottom-right. This has been so since Odoo 10.0; in Odoo 9.0 and before, it is enabled from the About dialog, accessed from the user menu in the top-right. It can also be enabled directly on the page URL, by changing the .../web?#... URL to  .../web?debug#....
  1. Where do you create a new Data model?
Data Models can be created and modified in the Settings app, in the Technical | Database Structure | Models menu option. To have the Technical menu available, you must have Developer Mode enabled. New models must have an x_ prefix, and new fields must also have this same  x_ prefix.
  1. How do you make a new data model available for the end users to create and edit records?
You should create a menu item for this, and in most cases, you will also want to design proper List and Form Views. You also need to add the ACLs to a group the user belongs to, or they won't be able to see the menu and views.


  1. How do you add a field to an existing form?
You first edit the model to add the new field, then find the base View for the form (for example, using the Debugmenu). Then create an extension view for that base view, adding the new field.
  1. What is a Domain, and when can it be used?
It is a filter to apply when querying records from the database.
  1. How can you set default values on the form you're navigating to?
You do this by setting a context key with the default_ prefix, for example, {'default_x_name': '<Type description>'}. This context key can be set on Window Actions, used in Menu items, and for relational fields can be set on the View's field definition.
  1. How do you give a user access to a Model?
You first assign the ACL, for create, read, update, and delete, to a Group, and then make sure that the user belongs to that Group, directly or indirectly (indirectly belonging to another Group that inherits that one, such as Manager groups, which usually inherit from user groups).
  1. How can you add a Category field to the To-do items, with possible values selectable from an options list? (The options list is editable and can be expanded by users.)
Create a new Model called x_todo_category. No additional fields needed.
Edit the x_todo_item Model and add a x_category_id field, of the many-to-one type, with a related x_todo_category Model.
Edit the To-do item form view to add the new field: <field name="x_category_id" />.
Add the ACL to the To-do User group.


  1. How can you extend the To-do Category model so that the list of Categories is specific for each user?
It is enough to create a record rule on the To-do category for the To-do User Group. The domain to use is [('create_uid', '=', user.id)].
You could also reorganize the To-do menu to have two child menu items, Items and Categories.
The To-do top menu item should have no action defined, the Items menu item should reuse the existing Action to open the to-do list, and a new Action should be used on the Categories menu item, opening the To-do Category list.

Chapter 3

  1. Is library-app a valid module name?
It is a technically valid name, so it could be used, but it does not comply with the code conventions for Odoo, so it shouldn't be used.
  1. Should a module define access control (ACL) for all Models defined in it?
Yes, as a general rule it should. Leaving a Model with no ACLs makes it inaccessible for the end users.
  1. Can we permit some users to only access a subset of the records in a Model?
Yes, Record Rules allow us to define a Domain filter, and assign it to security Groups. Users in those Groups will only be able to access the records matching the Domain filter.
  1. What is the difference between a relational field and other field types?
Relational fields store links to other records, not actual values like the other field types.
  1. What are the main view components used in an Odoo app?
The backend view layer includes menu items, window actions, and views. All these are defined using XML data files. Menu items are usually defined with <menuitem> data elements, <action> defines Window Actions, and <record model="ir.ui.view"> defines views.
  1. How are backend views defined?
A backend view is defined with an XML architecture declaring the structure of the elements it is composed of.
  1. Where should business logic be implemented in an Odoo app?
A module business logic should be implemented in the Model methods, using Python code.
  1. What is the web page templating engine used by Odoo?
For the website/frontend views, Odoo uses the QWeb, an XML-based template engine. It allows templates to be extended by other modules, just like what can be done with the backend views.

Chapter 4

  1. How do we extend an existing Model to add a mixin, such as mail.thread?
Both in-place classic extension and mixin prototype inheritance use the same _inherit Model attribute. For example, to extend x and add the y mixin, we should have the _name='x' model attribute and the _inherit = ['x', 'y'] Model attribute.
  1. What changes are needed to also have the phone field available in the member form view?
No model changes are needed, since a phone field exists in partners, and delegation inheritance makes all partner fields also available on the member Model. We only need to add the field to the form view, for example, next to the email field: <field name=phone" />.
  1. What happens if you create a Model class with name attribute different form the inherit attribute (for example, _name='y' and _inherit='x')?
A new ymodel will be created, copying all the features (data structure and methods) from Model x. If x is a database-stored Model, we will have two database tables with the same fields, but independent data records, which is not a good design practice. That's why this is usually used with abstract mixin classes that don't have an actual database representation.


  1. Can XPath be used to modify data record from other modules?
No. XPath is used only for views, to find the element in the view structure where the extension should be done. This extension is performed at runtime, and no actual change is made to the record being extended.
  1. When inheriting a Model to extend it, can we extend a method and not use super() to call original code being inherited?
We can, and sometimes we may have to, but we should avoid it. When not using super() we are completely replacing the original code, our re-implementation will have different behavior form the original one, and it may have unanticipated side-effects. Also, extensions implemented in other modules may not work as expected. If the parent method is hard to extend, it's best to propose changes to it, so that it includes extension points we can use (separating part of the logic into their own methods will make extension simpler).
  1. How can we extend the book catalog web page to add the ISBN field at the end of the line without referencing any particular field name?
We can insert the ISBN field inside the row div element: <xpath expr="//div[class='row']"><span t-field="book.isbn"/></xpath>

Chapter 5

  1. What is the difference between an XML ID and an external ID?
None. Both terms refer to the same thing: external identifiers.
  1. What type of data files can be used, add-on modules?
Odoo add-on modules can use XML and CSV data files.
  1. What is wrong in this XML fragment:<field name="user_id">[(4, 0, [ref(base.user_demo)])]</field>?
Three things are wrong: the tag content should instead be in an eval attribute; the 4 command expects the record references in the second element, not the third; and a single record reference is expected, not a list. The correct syntax is: <field name="user_id" eval="[(4, ref(base.user_demo), 0)] />


  1. Can a data file in one add-on module overwrite a record create in another module?
Yes, in an XML file we can have a <record> element using the complete External ID of the record to replace (module.identifier).
  1. When an add-on module is upgraded, are all its data records rewritten to the module's default values?
In most cases, yes, but there can be records loaded in a noupdate="1" data section that won't be rewritten on a module upgrade.

Comments

Popular posts from this blog

The message and activity features

The message and activity features Odoo has available global  messaging  and activity planning features, provided by the  Discuss  application, with technical name mail. The mail module provides the  mail.thread  abstract class that makes it simple to add the messaging features to any model, and the  mail.activity.mixin  that adds planned activity features. This was done in  Chapter 4 ,  Extending Modules , to explain how to inherit features from mixin abstract classes. To add these features, we need to add the mail dependency to the add-on module,  library_checkout , and then have the library checkout model class inherit from the abstract classes providing the following features. Edit the  'depends'  key in the  library_checkout/__manifest__.py   file, to add the mail module, shown as follows: Copy 'depends': ['library_member' , 'mail' ], And edit the  library_checkout/m...

Setting up an nginx reverse proxy

Setting up an nginx reverse proxy While Odoo itself can serve web pages, it's strongly recommended that there is a  reverse  proxy positioned in front of it. A reverse proxy acts as an intermediary that manages the traffic between clients sending requests and the Odoo servers responding to them. Using a reverse proxy has several benefits. On the security side, it can do the following: Handle (and enforce) HTTPS protocols to encrypt traffic Hide the internal network characteristics Act as an application firewall, limiting the URLs accepted for processing Also, on the performance side, it can provide the following significant improvements: Cached static content, hence reducing the load on the Odoo servers Compressed content to speed up loading time Act as a load balancer, distributing load between several servers Apache is a popular choice when considering a reverse proxy, although  nginx  is a recent alternative with good technical argumen...

The QWeb template language

The QWeb template language The  QWeb  parser looks for special directives in the templates and replaces them with dynamically generated HTML. These directives are XML element attributes and can be used in any valid tag or element, such as  <div> ,  <span> , or  <field> . Sometimes, we may want to use a QWeb directive but we don't want to place it in any of the XML elements in our template. For those cases, we have a  <t>  special element that can have QWeb directives, such as  t-if  or  t-foreach , but is silent and won't have any output on the final XML/HTML produced. The QWeb directives will frequently make use of evaluated expressions to produce different results, depending on the current record values. There are two different QWeb implementations: client-side JavaScript and server-side Python. The reports and website pages use the server-side Python implementation of QWeb. Kanban views us...