This section provides an overview of what odoo-8 is, and why a developer might want to use it.
It should also mention any large subjects within odoo-8, and link out to the related topics. Since the Documentation for odoo-8 is new, you may need to create initial versions of those related topics.
Developer Mode
Odoo developer mode allows you to make substantial modifications to the Odoo database such as adding fields to your documents and views. You change the default views of your actions and can even create dynamic forms based on other fields within your models.
Advantage
While Odoo is a powerful application framework the development cycle can be brutal to test changes to your application. By utilizing the developer mode you can test expressions and solve many functional problems without having to restart the server over and over to test simple changes.
Additionally the Odoo developer tool is great for looking at the architecture of forms and views to see how fields are tied to modules, their domains, contexts and other attributes. In this video we explore exactly how we put these tools to use in modifying and creating Odoo applications.
Limitations
While it can be very tempting to use developer mode to make a great deal of changes to your application there are some drawbacks. Depending on what you modify and change you can lose these changes with future module updates or when you install additional applications into Odoo. This is particularly true for changes to views.
To activate developer mode you just simply write down
for version v7
&debug=
before # sign you just add it.
http://localhost:8069/?db=test_db&debug=#
for version > v7
You may not see About Odoo menu because there might be odoo debranding module installed.
If you are not sure about which option is suitable for you, then try the first option (backend) as it is used in most cases and nearly in all cases if you have not installed the "website" module. Odoo differentiates between "backend" and "frontend" assets because the public website provided by the "website" module uses different styling and JS code than internal pages meant to be used for ERP tasks, i.e. "frontend" is associated with the public website and "backend" is associated with internal pages for ERP (meaning of "frontend" and "backend" are Odoo specific here, but they are both "frontend" in more general sense).
You can not only choose and use one of the options, but also use any combination of them (two of them or all of them) in the same module. Factor a backend, a frontend and a common JS/CSS code into separated files to better adhere to DRY and have suitable code in the public website and in the internal pages.
Do not forget to add "web" (when using option 1) or "website" (when using option 2) to the dependency list in the __openerp__.py
manifest.
Create method: Create new record with specified value. Takes a number of field values, and returns a recordset containing the record created
def create(self,vals):
return super(class_name, self).create(vals)
Write Method: Update records with given ids with the given field values.Takes a number of field values, writes them to all the records in its recordset. Does not return anything
def write(self,vals):
return super(class_name, self).write(vals)
Search method: Search for records based on a search domain.Takes a search domain, returns a recordset of matching records. Can return a subset of matching records (offset and limit parameters) and be ordered (order parameter)
self.search([('customer','=',True)])
self.env['res.partner'].search(['partner','=',True])
Browse method: Fetch records as objects allowing to use dot notation to browse fields and relations.Takes a database id or a list of ids and returns a recordset, useful when record ids are obtained from outside Odoo (e.g. round-trip through external system) or when calling methods in the old API.
self.browse([7,8,9])
self.env['res.partner'].browse([7,8,9])
Exists methods: Returns a new recordset containing only the records which exist in the database. Can be used to check whether a record (e.g. obtained externally) still exists.
records = records.exists()
ref method: Environment method returning the record matching a provided external id
self.env.ref('base.group_public')
ensure_one method: checks that the recordset is a singleton (only contains a single record), raises an error otherwise
records.ensure_one()
'depends': ['web',....]
If you are considering to add new methods in Python to use them in RPC from JavaScript, then consider the following options of method decorators: if you've to deal with ids/recordsets then for python method definition choose decorator:
Or if it's simple function that does not have to deal with records/ids then for python method choose decorator:
[ ]
(empty array) as first argument in javascript...
References: Odoo RPC documentation, Odoo 8 API method decorators
Odoo and ORM: Odoo uses ORM(Object Relational Mapping) technique to interact with database. ORM will help to create a virtual object database that can be used within from the Python. In ORM technique each model is represented by a class that subclasses Models.model.
Models.model is the main super class for regular database persisted Odoo models. Odoo models are created by inheriting from this class.
Example:
class Employee(Models.model):
_name = 'module.employee'
#Rest of the code goes here
Here _name is a structural attribute, which tells the system about the name of the database table to be created.
Each model has a number of class variables, each of which represents a database field in the model. Each field is represented by an instance of a openerp.fields.Field class. Fields in Odoo are listed below..
1 Boolean Field
ex: flag = fields.Boolean()
2 Char Field
ex: flag = fields.Char()
3 Text
ex: flag = fields.Text()
4 Html
ex: flag = fields.Html()
5 Integer
ex: flag = fields.Integer()
6 Float
ex: flag = fields.Float()
7 Date
ex: flag = fields.Date()
8 Datetime
ex: flag = fields.Datetime()
9 Selection
ex: flag = fields.Selection()
10 Many2one
ex: flag = fields.Many2one()
11 One2many
ex: flag = fields.One2many()
12 Many2many
ex: flag = fields.Many2many()