星期四, 4月 06, 2017

Windows 的 Odoo10 開發環境安裝

預計安裝內容

  • python 的運行環境
  • postgreSQL資料庫
  • 安裝 pgadmin
  • Git 及 Tor
  • 安裝JDK及Pycharm

一.、python 的運行環境,安裝python-2.7.12

下載路徑,https://www.python.org/downloads/windows/

clip_image001

點擊"next"

clip_image002

路徑不變,繼續下一步。

clip_image003

選擇自動加入PATH,run完之後點擊"finish",並重新開機。

打開cmd.exe 輸入python,若有出現版本訊息則代表安完成,若無檢查PATH

image

二、安裝 postgreSQL資料庫 postgresql-9.6

下載路徑,https://www.enterprisedb.com/downloads/postgres-postgresql-downloads#windows

clip_image001[5]

  • 設定路徑
  • 輸入密碼: 兩個欄位都輸入"odoo"

clip_image002[5]

然後一路 "next" 到底!

三、安裝 pgadmin

下載路徑, https://www.pgadmin.org/download/pgadmin-4-windows/

安裝過程: 下一步 → 選擇"I accept….",下一步 → 選擇安裝路徑 → install → 完成。

  • 設置權限

安裝成功後開啟檔案, 並點選server→PostgreSQL,輸入密碼:odoo新增 使用者 odoo 密碼 odoo 並設定權限

clip_image002[7]

新增使用者

clip_image003[7]

在"general"中輸入odoo。

clip_image004[5]

在"privileges",全部都開"yes",完成之後按下"save"。

clip_image005[5]

四、安裝Git及TortoiseGit輔助

下載路徑,https://git-scm.com/download/win

https://tortoisegit.org/download/

安裝 Git-2.12,一直Next就可

image

安裝TortoiseGit,,一直Next就可,可以不要跑 Run First start wizard

image

安裝 TortoiseGit-LanguagePack,一直Next就可

image

五、安裝JDK及Pycharm

JDK下載路徑,http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Pycharm下載路徑,https://www.jetbrains.com/pycharm/download/#section=windows

1.安裝JDK,並配置JAVA_HOME (C:\Program Files\Java\jdk1.8.0_121),配置完重開機

image

2.安裝Pycharm,一直下一步即可

image

六、下載odoo及設定

  1. https://pip.pypa.io/en/stable/installing/ 下載 get-pip.py 因為windows執行PIP會有點問題
  2. 下載後執行
  3. python get-pip.py
  1. 到odoo的gitHub下載odoo10 https://github.com/odoo/odoo
  1. 用notepad開啟requirements.txt檔,然後在最後面加上pypiwin32
  1. 開啟cmd,進入odoo 10 soruce 所屬的位置,例 D:\Odoo\odoo10_SourceLimit\odoo10
  2. 依序打上以下指令。

pip.exe install -r requirements.txt

python -m pip install --upgrade pip

  1. 將下方檔案放入在你所下載的odoo資料檔裡(odoo.conf),並且用notepad開啟更改路徑。

<<odoo.conf>>

clip_image005[7]

      
  1. 安裝node.js

clip_image006

並重新開啟cmd內打上安裝odoo套件指令:

npm install -g less less-plugin-clean-css

  1. 安裝wkhtmltox

clip_image007

並設定路徑,Odoo就安裝OK!

七、以pycharm開啟odoo

  1. 開啟pycharm

http://www.360kb.com/kb/17_24.html 取的註冊碼 並貼在如下框格中,並點選"ok"。

clip_image008

  1. 用pycharm打開odoo

clip_image009

  1. 設定環境變數與路徑

clip_image010

clip_image011

clip_image012

script請輸入您安裝odoo的路徑。

星期一, 9月 05, 2016

UBUNTU 16.04 中文輸入法設定

Ubuntu 16.04 的輸入法 預設 fcitx

預設用繁體中文安裝,直接點左欄的齒輪,進入「語言支援」

image

進入「語言支援」後,會提示套件補齊

補齊後,先「登出」讓系統讀入中文語系輸入法

image

我是使用倉頡,就安裝倉頡3代

sudo apt-get install fcitx-table-cangjie3

重新啓動

其他輸入法,打指令找

sudo apt-cache search fcfitx

安裝完後,點選右上角的鍵盤圖示,在下拉的選單中選擇ConfigureFcitx

image

出現,輸入法設定,點選左下角的+號,選擇剛才安裝的倉頡輸入法

image

Ctrl + 空白鍵,即可進行輸入法交換

 

如果是IBUS,上述方法一致

喜歡使用第三代倉頡輸入法,要安裝,首先可以輸入

sudo apt-get install ibus-table-cangjie3 #這是安樣第三代倉頡輸入法


其他輸入法安裝語句:

sudo apt-get install ibus-table-cangjie-big #倉頡輸入法
sudo apt-get install ibus-table-wubi #五筆輸入法 sudo apt-get install ibus-table-cantonese #廣東話輸入法 sudo apt-get install ibus-table-emoji #表情符號輸入法 sudo apt-get install ibus-table-quick #速成輸入法 sudo apt-get install ibus-table-stroke5 #筆劃輸入法 sudo apt-get install ibus-zhuyin #注音輸入法 sudo apt-get install ibus-pinyin #拼音輸入法

ibus restart

讓剛剛安裝的輸入法可以被載入。

在 System Settings 中,開啟 Text Entry

按「+」號增加輸入法

選擇你想增加的輸入法,我喜歡使用第三代倉頡,就選擇 Chinese (CangJie3) (IBus),你可以選擇你喜歡的輸入法。

星期三, 8月 03, 2016

Odoo 9 建立模組(四) 從Python開始學習 到 odoo 請假模組製作

Python 基礎

  • 主要學習網頁為
  • 可以將裡面的習題全部做完就差不多能夠了解Python的程式語言

http://old.sebug.net/paper/books/LearnPythonTheHardWay/

  • 裡面看不懂的語法可以到這裡查

http://pydoing.blogspot.tw/2012/10/python-tutorial.html

Odoo9 請假模型

  • 自動更新模組
    • 在configuration內的addons-path的尾端加上要自動更新的目錄ex: (--addons-path addons,my-modules -d academy -u academy)
  • 簡易請假模型製作
    • 目錄像這樣

    image

    • main_model

image

    • views

<openerp>
<data>
<!--
打开请假单动作
-->
<act_window id="action_qingjia_qingjd"
name=" 请假单"
res_model="qingjia.qingjd"
view_mode="tree,form" />
<!--
表单视图
-->
<record id="qingjia_qingjd_form" model="ir.ui.view">
<field name="name">qing jia dan form</field>
<field name="model">qingjia.qingjd</field>
<field name="arch" type="xml">
<form>
<sheet>
<group name="group_top" string= "请假单">
<field name="name"/>
<field name="days"/>
<field name="startdate"/>
<field name="reason"/>
</group>
</sheet>
</form>
</field>
</record>
<!--
tree 视图
-->
<record id="qingjia_qingjd_tree" model="ir.ui.view">
<field name="name">qing jia dan tree</field>
<field name="model">qingjia.qingjd</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="startdate"/>
<field name="days"/>
</tree>
</field>
</record>
<!--
加入菜单
-->
<menuitem id="menu_qingjia" name=" 请假" sequence="0"></menuitem>
<menuitem id="menu_qingjia_qingjiadan" name=" 请假单" parent="menu_qingjia"></menuitem>
<menuitem id="menu_qingjia_qingjiadan_qingjiadan" parent="menu_qingjia_qingjiadan" action="action_qingjia_qingjd"></menuitem>
</data>
</openerp>

參考網站:http://www.3e3c.com/erp/odoo/220.html

    • __openerp__

{
    'name': "qingjia",
    'version': '1.0',
    'depends': [],
    'author': "peng",
    'category': '',
    'description': """

    """,
    'depends': ['base'],
    'data': [
             "views/views.xml"
            ],
    'demo': [],
    'application':True,
}

 

 

 

 

  • 參考資料

http://cdwanze.github.io/%E7%94%B5%E8%84%91/python/Odoo/%E7%B2%BE%E9%80%9AOdoo.html#orgheadline93

星期二, 7月 26, 2016

Odoo 9 建立模組 (三) 自行建立模組

一、建立資料夾,檔案

  • 想要自行建立一個模組裡面必須要有下列幾個必要元素
  • 先在addons目錄下新增一個python package  檔名為test

image

  • 在test下新增以下檔案
  • test (python package)
  • __init__.py   (python file 會自行產生 )
  • __openerp__.py     (python file"__"為雙底線)
    • models    ( ython package)
      • __init__.py(python file 會自行產生)
    • views (Directory 檔案夾)
      • test_student_view.xml  (file)

image

  • 完成後

image

二、import 資料夾和檔案

    • __openerp__.py

      • 可以參考上節所建立的openacademy內的openerp建立,主要是宣告模組名稱,版本,作者.......

{
    'name': "test1",
    'version': '1.0',
    'depends': [],
    'author': "supojen(kulius@msn.com)",
    'category': '',
    'description': """

    """,
    'data': ["views/test1_student_view.xml"],
    'demo': [],
}

  • __init__.py

    • import有使用到的models,和python檔

image

      # -*- coding: utf-8 -*-
      import models

image

from . import test_student

三、資料關聯建立

  • models內的檔案是負責關聯資料表

image

 

  • 建立一個"name"的欄位

from openerp import models, fields, api

class TestStudent(models.Model):
    _name="test.student"
    name=fields.Char()

image

四、畫面設定

  • odoo畫面相關的code會放在剛剛建立views資料夾裡的XML檔,此XML檔需在openerp內的DATA進行宣告

image

 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="test_student_view_form" model="ir.ui.view">
            <field name="name">test.student.view.form</field>
            <field name="model">test.student</field>
            <field name="arch" type="xml">
                <form string="">
                    <sheet>
                        <group>
                            <field name="name"/>


                        </group>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="test_student_view_tree" model="ir.ui.view">
            <field name="name">test.student.view.tree</field>
            <field name="model">test.student</field>
            <field name="arch" type="xml">
                <tree string="">
                    <field name="name"/>
                </tree>
            </field>
        </record>

        <record id="test_student_action" model="ir.actions.act_window">
            <field name="name">test student</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">test.student</field>
            <field name="view_mode">tree,form</field>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                <!-- Add Text Here -->
              </p><p>
                <!-- More details about what a user can do with this object will be OK -->
              </p>
            </field>
        </record>


        <menuitem id="test_menu_root" name="test" sequence="1"/>
        <menuitem id="test_select_menu_category" name="select" parent="test_menu_root" sequence="1"/>
        <menuitem id="test_course_menu_action_list" name="set student" parent="test_select_menu_category" action="test_student_action" sequence=""/>


    </data>
</openerp>

四、簡易模組完成

image

 

image

星期三, 6月 15, 2016

Odoo 9 建立模組 (二) 使用 scaffold 建立模組

  • 參考 Building a Module

  • 進入 odoo 的source 目錄

  • 建立模組語法 $ odoo.py scaffold <module name> <where to put it> python odoo.py scaffold openacademy addons
  • 完成後便會在 addon的資料匣中建立 openacademy的模組

image

  • 資料匣內容可參考 精通 Odoo 這本書,第5章節 创建自己的模块

image

  • openacademy 模組中各資料匣的含義如下
    1. data 文件夹,放着 demo 和 data xml
    2. models 文件夹,放着模型定义
    3. controllers 文件夹,http 路径控制
    4. views 文件夹,网页视图和模板
    5. static 文件夹,网页的一些资源,里面还有子文件夹:css,js,img,lib 等等
  • 啓動odoo.py,打開瀏灠器進入系統 http://127.0.0.1:8069/web

image

  • 進入系統,點選右上角的administrator中的about的選項

image

  • 在點選 activate the developer mode 進入開發者模式

image

  • 進入Apps 點選 Update Apps List,更新模組列表

imageimage

  • 點選Apps 並把蒐尋的預設條件點X按掉

image

  • 輸入 openacademy 便可找到剛才新增的模組

image