ผลต่างระหว่างรุ่นของ "Openerp/getting started"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
 
(ไม่แสดง 5 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน)
แถว 6: แถว 6:
 
** เปิด Technical Features: Users/Users => Administrator => Edit => Access Rights => Technical Features
 
** เปิด Technical Features: Users/Users => Administrator => Edit => Access Rights => Technical Features
 
** Log out / log in (จะเห็นเมนูเพิ่มขึ้น)
 
** Log out / log in (จะเห็นเมนูเพิ่มขึ้น)
 +
 +
== สร้างโมดูล ==
 +
: เอกสารอ้างอิง [http://help.openerp.com/question/16336/how-i-can-create-module-openerp-7/ Help page], [https://doc.openerp.com/trunk/server/03_module_dev/], [https://www.openerp.com/files/memento/OpenERP_Technical_Memento_latest.pdf Technical Memento]
 +
 +
* สร้างไดเร็กทอรีใน openerp/addons ชื่อตามโมดูล  สมมติเราจะสร้างโมดูล easynote
 +
* สร้างไฟล์ __init__.py
 +
 +
<syntaxhighlight lang="python">
 +
import easynote
 +
</syntaxhighlight>
 +
 +
* สร้างไฟล์ __openerp__.py
 +
 +
<syntaxhighlight lang="python">
 +
{
 +
    'name': 'EasyNotes',
 +
    'version': '0.1',
 +
    'category': 'Tools',
 +
    'description': """
 +
This is a sample module
 +
=======================
 +
 +
Easy notes can be found in the 'Home' menu.
 +
""",
 +
    'author': 'Testing',
 +
    'website': 'http://openerp.com',
 +
    'summary': 'Easy notes, easy everything',
 +
    'sequence': 9,
 +
    'depends': [],
 +
    'data': [
 +
        'easynote_view.xml',
 +
    ],
 +
    'demo': [],
 +
    'test': [],
 +
    'css': [],
 +
    'images': [],
 +
    'installable': True,
 +
    'application': True,
 +
    'auto_install': False,
 +
}
 +
</syntaxhighlight>
 +
 +
* สร้างไฟล์ <tt>easynote.py</tt>
 +
 +
<syntaxhighlight lang="python">
 +
from osv import osv, fields
 +
 +
class Note(osv.Model):
 +
    _name = 'easynote.note'
 +
    _rec_name = 'title'
 +
    _columns = {
 +
        'title': fields.char('Title', size=100, required=True),
 +
        'body': fields.text('Body', required=True),
 +
    }
 +
</syntaxhighlight>
 +
 +
* สร้างไฟล์ <tt>easynote_view.xml</tt>
 +
 +
<syntaxhighlight lang="xml">
 +
<?xml version="1.0" encoding="utf-8"?>
 +
<openerp>
 +
  <data>
 +
    <!-- New note Form View -->
 +
    <record model="ir.ui.view" id="view_easynote_note_tree">
 +
      <field name="name">easynote.note.tree</field>
 +
      <field name="model">easynote.note</field>
 +
      <field name="arch" type="xml">
 +
        <tree string="Stages">
 +
          <field name="title"/>
 +
          <field name="body"/>
 +
        </tree>
 +
      </field>
 +
    </record>
 +
 +
    <!-- New note Form View -->
 +
    <record model="ir.ui.view" id="view_easynote_note_form">
 +
        <field name="name">easynote.note.form</field>
 +
        <field name="model">easynote.note</field>
 +
        <field name="arch" type="xml">
 +
          <form string="Note" version="7.0" class="oe_form_nomargin">
 +
            <field name="title" />
 +
            <field name="body" widget="html" class="oe_memo" editor_height="450px" />
 +
          </form>
 +
        </field>
 +
    </record>
 +
 +
    <record model="ir.actions.act_window" id="action_easynote_note">
 +
      <field name="name">EasyNotes</field>
 +
      <field name="res_model">easynote.note</field>
 +
      <field name="view_type">form</field>
 +
      <field name="view_mode">tree,form</field>
 +
      <field name="context">{'search_default_open_true':True}</field>
 +
      <field name="help" type="html">
 +
        <p class="oe_view_nocontent_create">
 +
          Click to add a note.
 +
        </p>
 +
        <p>
 +
          Use notes to organize personal tasks or notes.
 +
        </p>
 +
      </field>
 +
    </record>
 +
 +
    <menuitem name="Notes" id="menu_easynote_notes"
 +
              parent="" sequence="1"
 +
              action="easynote.action_easynote_note"/>
 +
 +
  </data>
 +
</openerp>
 +
 +
</syntaxhighlight>

รุ่นแก้ไขปัจจุบันเมื่อ 17:14, 12 พฤศจิกายน 2556

ขั้นตอนเริ่มต้น

  • สร้าง database ใหม่
  • เข้าใช้เป็น admin
    • ตั้ง Time zone
    • เปิด Technical Features: Users/Users => Administrator => Edit => Access Rights => Technical Features
    • Log out / log in (จะเห็นเมนูเพิ่มขึ้น)

สร้างโมดูล

เอกสารอ้างอิง Help page, [1], Technical Memento
  • สร้างไดเร็กทอรีใน openerp/addons ชื่อตามโมดูล สมมติเราจะสร้างโมดูล easynote
  • สร้างไฟล์ __init__.py
import easynote
  • สร้างไฟล์ __openerp__.py
{
    'name': 'EasyNotes',
    'version': '0.1',
    'category': 'Tools',
    'description': """
This is a sample module
=======================

Easy notes can be found in the 'Home' menu.
""",
    'author': 'Testing',
    'website': 'http://openerp.com',
    'summary': 'Easy notes, easy everything',
    'sequence': 9,
    'depends': [],
    'data': [
        'easynote_view.xml',
    ],
    'demo': [],
    'test': [],
    'css': [],
    'images': [],
    'installable': True,
    'application': True,
    'auto_install': False,
}
  • สร้างไฟล์ easynote.py
from osv import osv, fields

class Note(osv.Model):
    _name = 'easynote.note'
    _rec_name = 'title'
    _columns = {
        'title': fields.char('Title', size=100, required=True),
        'body': fields.text('Body', required=True),
    }
  • สร้างไฟล์ easynote_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <!-- New note Form View -->
    <record model="ir.ui.view" id="view_easynote_note_tree">
      <field name="name">easynote.note.tree</field>
      <field name="model">easynote.note</field>
      <field name="arch" type="xml">
        <tree string="Stages">
          <field name="title"/>
          <field name="body"/>
        </tree>
      </field>
    </record>

    <!-- New note Form View -->
    <record model="ir.ui.view" id="view_easynote_note_form">
        <field name="name">easynote.note.form</field>
        <field name="model">easynote.note</field>
        <field name="arch" type="xml">
          <form string="Note" version="7.0" class="oe_form_nomargin">
            <field name="title" />
            <field name="body" widget="html" class="oe_memo" editor_height="450px" />
          </form>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_easynote_note">
      <field name="name">EasyNotes</field>
      <field name="res_model">easynote.note</field>
      <field name="view_type">form</field>
      <field name="view_mode">tree,form</field>
      <field name="context">{'search_default_open_true':True}</field>
      <field name="help" type="html">
        <p class="oe_view_nocontent_create">
          Click to add a note.
        </p>
        <p>
          Use notes to organize personal tasks or notes. 
        </p>
      </field>
    </record>

    <menuitem name="Notes" id="menu_easynote_notes" 
              parent="" sequence="1" 
              action="easynote.action_easynote_note"/>

  </data>
</openerp>