odoo-8 - rip tutorial

28
odoo-8 #odoo-8

Upload: khangminh22

Post on 10-May-2023

1 views

Category:

Documents


0 download

TRANSCRIPT

odoo-8

#odoo-8

1

1: odoo-8 2

2

2

Examples 2

2

: 2

Odoo ? 5

2: Odoo 8 7

7

7

7

Examples 9

Odoo 8 9

3: Odoo v8 API RPC (JavaScript Python ) 10

10

Examples 10

Odoo 10

Odoo RPC 10

4: Odoo CSS Javascript 12

12

12

12

Examples 12

Odoo CSS JS . 12

1 : [BACKEND] CSS Javascript 12

2 : [FRONTEND] CSS Javascript 13

3 : [] ( ) CSS Javascript 13

5: OpenERP 14

14

Examples 14

14

Odoo 8 15

Odoo 10 15

6: ORM ? 17

17

Examples 17

ORM 17

7: 19

19

Examples 19

xml . 19

Python 19

8: - Odoo Office 365 20

Examples 20

20

9: 23

23

Examples 23

TreeView 23

25

You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: odoo-8

It is an unofficial and free odoo-8 ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official odoo-8.

The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners.

Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected]

https://riptutorial.com/ko/home 1

1: odoo-8 odoo-8 , .

odoo-8 . odoo-8 .

8.0 GNU AGPL 2014-09-18

9.0 GNU AGPL V3 2015-10-01

Examples

Odoo .

( )1. ( , )2. docker.com 3.

odoo.com .

Windows

.

: Windows 8 "Windows PC " . . UAC . Odoo .

:

% PROGRAMFILES % \ Odoo 8.0-id \ server \ openerp-server.conf . (id )

PostgreSQL dbfilter . Services ‣ odoo Odoo .

Odoo 8.0 root :

# wget -O - https://nightly.odoo.com/odoo.key | apt-key add - # echo "deb http://nightly.odoo.com/8.0/nightly/deb/ ./" >> /etc/apt/sources.list # apt-get update && apt-get install odoo

Odoo .

PDF wkhtmltopdf . debian wkhtmltopdf . 0.12.1 wkhtmltopdf . Jessie http://nightly.odoo.com/extra/ . wkhtmltopdf .

# wget https://bitbucket.org/wkhtmltopdf/wkhtmltopdf/downloads/{path to correct distro and system architecture} # sudo dpkg -i {.deb package}

https://riptutorial.com/ko/home 2

# sudo cp /usr/local/bin/wkhtmlto* /usr/bin/

/etc/odoo/openerp-server.conf .

Odoo .

$ sudo service odoo restart odoo : ok

RPM

RHEL (RHEL, CentOS, Scientific Linux) Odoo EPEL . CentOS :

$ sudo yum install -y epel-release

RHEL EPEL .

.

$ sudo yum install -y postgresql-server $ sudo postgresql-setup initdb $ sudo systemctl enable postgresql $ sudo systemctl start postgresql $ sudo yum-config-manager --add-repo=https://nightly.odoo.com/8.0/nightly/rpm/odoo.repo $ sudo yum install -y odoo $ sudo systemctl enable odoo $ sudo systemctl start odoo

PDF wkhtmltopdf . Fedora / CentOS wkhtmltopdf . wkhtmltopdf . debian

wget https://bitbucket.org/wkhtmltopdf/wkhtmltopdf/downloads/{path to correct distro and system architecture} sudo rpm -i {.rpm package} sudo cp /usr/local/bin/wkhtmlto* /usr/bin/

/etc/odoo/openerp-server.conf .

Systemd Odoo .

$ sudo systemctl restart odoo

Odoo zip https://nightly.odoo.com/8.0/nightly/src/odoo_8.0.latest.zip . zip .

Git Odoo . . git Odoo .

git https://github.com/odoo/odoo.git.

.

$ git clone https://github.com/odoo/odoo.git

.

https://riptutorial.com/ko/home 3

2.7. Linux OS X

Windows Python 2.7.9 .

2.7.9, 3.x .

PostgreSQL

postgres . postgres, Odoo .

Linux postgres .

$ sudo su - postgres -c "createuser -s $USER"

. OS X postgres.app , Linux postgres .

Windows PostgreSQL Windows PostgreSQL bin ( : C : \ Program Files \ PostgreSQL \ 9.4 \ bin) PATH

pg admin gui : open pgAdminIII postgres , , ‣ ‣ , ( : odoo) ( : odoo) .

-w -r Odoo

requirements.txt Python .

Linux python pip .

(Pillow, lxml, greenlet, gevent, psycopg2, ldap) , pip . Python, Postgres, libxml2, libxslt, libevent, libsasl2 libldap2 -dev -devel . :

$ pip install -r requirements.txt

OS X (xcode-select --install) (homebrew, macports) . pip Linux Python .

$ pip install -r requirements.txt

Windows requirements.txt pip .

Install psycopg using the installer here http://www.stickpeople.com/projects/python/win-psycopg/

requirements.txt . psycopg2 . python-ldap, gevent psutil . pypiwin32 .

pip cmd.exe (\ YourOdooPath Odoo ).

C:\> cd \YourOdooPath C:\YourOdooPath> C:\Python27\Scripts\pip.exe install -r requirements.txt

nodejs CSS

https://riptutorial.com/ko/home 4

Linux nodejs npm .

debian wheezy Ubuntu 13.10 nodejs :

$ wget -qO- https://deb.nodesource.com/setup | bash - $ apt-get install -y nodejs

(> jessie) (> 14.04) npm symlink debian nodej

$ apt-get install -y npm $ sudo ln -s /usr/bin/nodejs /usr/bin/node Once npm is installed, use it to install less and less-plugin-clean-css: $ sudo npm install -g less less-plugin-clean-css on OS X, install nodejs via your preferred package manager (homebrew, macports) then install less and less-plugin-clean-css: $ sudo npm install -g less less-plugin-clean-css

Windows nodejs (PATH ) less less-plugin-clean-css :

C:\> npm install -g less less-plugin-clean-css

Odoo

odooo.py Odoo .

.

.

PostgreSQL host, port, user and password.

Odoo psycopg2 . 5432 UNIX . Linux OS X UNIX Windows . addons

Windows odoo .

C:\YourOdooPath> python odoo.py -w odoo -r odoo --addons-path=addons,../mymodules --db-filter=mydb$

odoo, odoo postgresql , ../mymodules addons , mydb localhost : 8069 db.

* nix odoo .

$ ./odoo.py --addons-path=addons,../mymodules --db-filter=mydb$Packaged installers

Odoo ?

Odoo ( OpenERP TinyERP) . / , . . Odoo . Odoo (1 ) (300,000 )

https://riptutorial.com/ko/home 5

2,000,000 .

OpenObject ERP (Enterprise Resource Planning) Odoo SA . , 500 . Odoo OpenObject , 30 ( ) 3000

Odoo . OpenERP .

(Odoo) .

(Odoo) (Trends Gazelle) (BOSSIE) 3 .

Python PostgreSQL . 240 . GitHub .

2013 Odoo Odoo SA Odoo . 150 .

odoo-8 : https://riptutorial.com/ko/odoo-8/topic/2151/odoo-8-

https://riptutorial.com/ko/home 6

2: Odoo 8 Odoo 8 .

= ""

compute = "_ compute_name_custom" .

store = True .

= True

readonly = True .

inverse = "_ write_name"

= True

= True

= 'blabla'

comodel_name = "model.name"

inverse_name = "field_name"

= 'many2many_table_name' many2many

columns1 = 'left_column_name'

column2 = 'right_column_name'

Odoo ORM : Odoo ORM (Object Relational Mapping) . ORM Python . ORM Models.model .

Models.model Odoo . Odoo .

:

class Employee(Models.model): _name = 'module.employee' #Rest of the code goes here

_name .

, . openerp.fields.Field . Odoo ..

https://riptutorial.com/ko/home 7

1

ex: flag = fields.Boolean()

2 Char Field

ex: flag = fields.Char()

3

ex: flag = fields.Text()

4 Html

ex: flag = fields.Html()

5

ex: flag = fields.Integer()

6

ex: flag = fields.Float()

7

ex: flag = fields.Date()

8 /

ex: flag = fields.Datetime()

9

ex: flag = fields.Selection()

10 Many2one

ex: flag = fields.Many2one()

11 One2many

ex: flag = fields.One2many()

12 Many2many

https://riptutorial.com/ko/home 8

ex: flag = fields.Many2many()

Examples

Odoo 8

Odoo ORM (Object Relational Mapping) . ORM Python . ORM Models.model . Models.model Odoo . Odoo .

name = fields.Char(string='New Value') flag = fields.Boolean(string='Flag',default=False) amount = fields.Float(string='Amount',digits=(32, 32)) code = fields.Selection(string='Code',selection=[('a', 'A'),('b','B')]) customer = fields.Many2one(comodel_name='res.users') sale_order_line = fields.One2many(comodel_name='res.users', inverse_name='rel_id') tags = fields.Many2many(comodel_name='res.users', relation='table_name', column1='col_name', column2='other_col_name')

Odoo 8 : https://riptutorial.com/ko/odoo-8/topic/8152/odoo-8--

https://riptutorial.com/ko/home 9

3: Odoo v8 API RPC (JavaScript Python )JavaScript RPC . ids / .

@ api.multi - •@ api.one - browse_records @ api.multi @api.one ID ( @ @ api.one api.multi).•

/ ID python .

@ api.model - API .•@ api.multi - . [ ] ( ) .•

: Odoo RPC , Odoo 8 API

Examples

Odoo

class my_model(models.Model): _name = "my.model" name = fields.Char('Name') @api.multi def foo_manipulate_records_1(self): """ function returns list of tuples (id,name) """ return [(i.id,i.name) for i in self] @api.multi def foo_manipulate_records_2(self, arg1, arg2) #here you can take advantage of "self" recordset and same time use aditional arguments "arg1", "arg2" pass @api.model def bar_no_deal_with_ids(self, arg1, arg2): """ concatenate arg1 and arg2 """ return unicode(arg1) + unicode(arg2)

Odoo RPC

Odoo 8 JavaScript Python . my_model . "list_of_ids" "my.model" ID () .

@ api.multi foo_manipulate_records_1 :•

new instance.web.Model("my.model") .call( "foo_manipulate_records_1", [list_of_ids]) .then(function (result) { // do something with result });

https://riptutorial.com/ko/home 10

@ api.multi foo_manipulate_records_2 :•

new instance.web.Model("my.model") .call( "foo_manipulate_records_2", [list_of_ids, arg1, arg2]) .then(function (result) { // do something with result });

@ api.model bar_no_deal_with_ids :•

new instance.web.Model("my.model") .call( "bar_no_deal_with_ids", [arg1, arg2]) .then(function (result) { // do something with result });

, id @ api.multi ( ID ).

new instance.web.Model("my.model") .call( "foo_manipulate_records_2", [[], arg1, arg2]) .then(function (result) { // do something with result });

v8.0 API @ api.multi (api.multi ) .

( ) RPC . ( ). ( ) . RPC ( )

var self = this; new instance.web.Model("my.model") .call("foo_manipulate_records_2", [[], arg1, arg2], {'context':self.session.user_context}) .then(function (result) { // do something with result });

.

Odoo v8 API RPC (JavaScript Python ) : https://riptutorial.com/ko/odoo-8/topic/6613/odoo-v8-api--rpc--javascript-python---

https://riptutorial.com/ko/home 11

4: Odoo CSS Javascript XML : XML HTML . <link rel = 'stylesheet'href = "..." > link .

<link rel = 'stylesheet'href = "..." / >○

inherit_id

web.assets_backend .

website.assets_frontend ( " " ).

web.assets_common .

" " () . Odoo " " ERP JS "" " " . , " " "" ERP ( " " "" Odoo " ").

. , JS / CSS DRY .

__openerp__.py ""( 1 ) " "( 2 ) .

Examples

Odoo CSS JS .

CSS JS '' ( '' ).

static / src / css / your_file.css•static / src / js / your_file.js•

.

1 : [BACKEND] CSS Javascript

Odoo v8.0 XML .

XML ( : __openerp__.py ).

... 'data': [ 'your_file.xml'], ...

'your_file.xml' .•

<openerp> <data> <template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend"> <xpath expr="." position="inside">

https://riptutorial.com/ko/home 12

<link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/> <script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script> </xpath> </template> .... .... </data> </openerp>

2 : [FRONTEND] CSS Javascript

: " " .

'your_file.xml' :•

<openerp> <data> <template id="assets_frontend" name="your_module_name assets" inherit_id="website.assets_frontend"> <xpath expr="link[last()]" position="after"> <link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/> </xpath> <xpath expr="script[last()]" position="after"> <script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script> </xpath> </template> </data> </openerp>

3 : [] ( ) CSS Javascript

'your_file.xml' :•

<openerp> <data> <template id="assets_common" name="your_module_name assets" inherit_id="web.assets_common"> <xpath expr="." position="inside"> <link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/> <script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script> </xpath> </template> </data> </openerp>

Odoo CSS Javascript : https://riptutorial.com/ko/odoo-8/topic/3401/odoo--css--javascript--

https://riptutorial.com/ko/home 13

5: OpenERP Odoo Odoo . .

Odoo . .

Odoo , , . Odoo .

. Odoo . .

v7

& debug =

# .

http : // localhost : 8069 /? db = test_db & debug = #

> v7

http : // localhost : 8069 / web? debug =

odoo debranding Odoo .

Examples

:

ODOO .1. .2. '' .3. ' ' .4.

https://riptutorial.com/ko/home 14

Odoo 8

Odoo . . . Odoo.com . . . .

. . http : // localhost : 8069 / web? debug = # id = 23 & view_type = form & model = res.partner

Odoo 10

:

odoo .1. odoo . .2.

https://riptutorial.com/ko/home 15

' ' .1. .2.

OpenERP : https://riptutorial.com/ko/odoo-8/topic/3311/openerp----

https://riptutorial.com/ko/home 16

6: ORM ?: . .

def create(self,vals): return super(class_name, self).create(vals)

Write : ID . . .

def write(self,vals): return super(class_name, self).write(vals)

: . . ( ) ( ).

self.search([('customer','=',True)]) self.env['res.partner'].search(['partner','=',True])

: . ID ID . ID ID ( : ) API .

self.browse([7,8,9]) self.env['res.partner'].browse([7,8,9])

: . ( : ) .

records = records.exists()

ref : ID

self.env.ref('base.group_public')

ensure_one : ( ) , .

records.ensure_one()

Examples

ORM

()1. ()2. ()3. ()4. ()5. ref ()6. ensure_one ()7.

https://riptutorial.com/ko/home 17

ORM ? : https://riptutorial.com/ko/odoo-8/topic/6150/orm------

https://riptutorial.com/ko/home 18

7: . Sale .

.

Examples

xml .

<?xml version="1.0"?> <openerp> <data noupdate="1"> <function model="*model_name*" name="_configure_sales"/> </data> </openerp>

xml model_name _configure_sales .

: XML data . Odoo xml .

Python

class *model_name*(models.Model): _name = *model_name* @api.model def _configure_sales(self): # Do the configuration here

.

: xml noupdate .

: https://riptutorial.com/ko/odoo-8/topic/10633/----

https://riptutorial.com/ko/home 19

8: - Odoo Office 365

Examples

- .

Odoo -> .•

https://riptutorial.com/ko/home 20

" " " " .•

https://riptutorial.com/ko/home 21

- Odoo Office 365 : https://riptutorial.com/ko/odoo-8/topic/6648/----odoo-office-365

https://riptutorial.com/ko/home 22

9: javascript .•__openerp__.py 'web' .•

'depends': ['web',....]

Examples

TreeView

TreeView . . .

custom_widget_name your_module_name ( )

Uunder / src / js / ( / src / js / custom_widget .js) :

openerp.your_module_name = function (instance) { instance.web.list.columns.add('field.custom_widget_name', 'instance.your_module_name.custom_widget_name'); instance.your_module_name.custom_widget_name = instance.web.list.Column.extend({ _format: function (row_data, options) { res = this._super.apply(this, arguments); var amount = parseFloat(res); if (amount < 0){ return "<font color='#ff0000'>"+(-amount)+"</font>"; } return res } }); // //here you can add more widgets if you need, as above... // };

float .

:.○

( '-') "".○

.•

Odoo . .

. . . <tree > . . . <field name="some_field" widget="my_widget" /> . . .

https://riptutorial.com/ko/home 23