markdown Odoo安装功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Odoo安装功能相关的知识,希望对你有一定的参考价值。

Add the data file to your __openerp__ file
Create the data file with the `noupdate="1"` flag
This indicates the code should be run once, then never again
It will run upon installation, or if the module is already installed, then it will the next time the module is upgraded.
Define the function element in your data file to trigger the appropriate python method
You can see the documentation here for details, but the end result looks something like this:

__openerp__.py
````
{
    ...
    'data': [
        ...
        'data/data.xml',
        ...
    ],
    ...
}
````
#### /data/data.xml
````
<openerp>
    <data noupdate="1">
        <function model="res.country" name="method_name"/>
    </data>
</openerp>
````
#### /models/country.py
```
from openerp import models
import logging
_logger = logging.getLogger(__name__)

class ResCountry(models.Model):
    _inherit = 'res.country'

    @api.model
    def method_name(self):
        for country in self.search([]):
           _logger.error(country.name)
```

以上是关于markdown Odoo安装功能的主要内容,如果未能解决你的问题,请参考以下文章

markdown Odoo pycharm设置

markdown Odoo sql fetch

markdown Odoo观点

markdown Odoo orm搜索

markdown Odoo数据库管理器

markdown Odoo cheatsheat