wiggin's Blog


  • 首页

  • 标签

  • 分类

Odoo模块创建步骤

Posted on 2019-05-15 | In Odoo

1、进入模块目录(默认为odoo/addons),使用odoo-bin脚手架命令创建模块结构

odoo-bin scaffold library_app

模块结构如下

└─library_app
    │  __init__.py  #Python模块文件
    │  __manifest__.py  #描述文件
    │
    ├─controllers   #Web控制器
    │      controllers.py
    │      __init__.py
    │
    ├─demo  #示例数据
    │      demo.xml
    │
    ├─models    #业务对象
    │      models.py
    │      __init__.py
    │
    ├─security  #访问权限
    │      ir.model.access.csv
    │
    └─views #视图
            templates.xml
            views.xml

2、创建models文件

#新建models/library_book.py,定义model类
class Book(models.Model):
...
#编辑models/__init__.py中加入引用
from . import library_book

3、添加访问规则,为自定义用户组可以指定base.group_user

#编辑security/ir.model.access.csv,加入模型对象model_library_book的访问规则
access_book_user,Book User Access,model_library_book,library_group_user,1,0,0,0
...

4、创建菜单及动作

#新建views/library_menu.xml,添加菜单及动作
#主菜单
<menuitem id="library_menu"
          name="Library" />
#菜单点击动作
<act_window id="action_library_book"
  name="Library Books"
  res_model="library.book"
  view_mode="tree,form"
/>
#子菜单
<menuitem id="menu_library_book"
          name="Book"
          action="action_library_book"
          parent="library_menu" />

5、创建视图,定义form、tree、search视图

#新建views/book_view.xml,添加form、tree、search视图
<record id="view_form_book" model="ir.ui.view">
<form>
...
<record id="view_tree_book" model="ir.ui.view">
<tree>
...
<record id="view_search_book" model="ir.ui.view">
<search>
...

6、编辑__manifest__.py,data和demo中引用数据文件csv或xml

'data': [
   'security/ir.model.access.csv',
   'views/library_menu.xml',
   'views/book_view.xml',
   ...
],
'demo': [
   'data/book_demo.xml',
],

问题:如果菜单不显示,请检查manifest.py中是否没有正常引用数据文件

使用Charles抓取请求

Posted on 2019-03-07 | In Web

Charles是一个HTTP代理服务器,当浏览器连接Charles的代理访问互联网时,可以监控浏览器发送和接收的所有数据。

运行环境

  • MacOS 10.14.3
  • Charles 4.2.7
  • 小米MIX2 Android MIUI10.2.2

1、下载并安装Charles

下载地址

工作界面和常用按钮

2、配置抓取HTTP请求

  • 配置代理,「Proxy Settings」

  • 抓取电脑端请求,菜单「Proxy」中,「macOS Proxy」打上勾,同时需要关闭开启的VPN代理

  • 抓取手机端请求,配置手机使用Charles代理
    首先手机和电脑端连接同一个wifi,在手机「设置」—「WLAN」中,进入连接的WLAN,「代理」选择手动,填写主机名、端口

3、配置抓取HTTPS请求

  • 电脑端配置SSL,「SSL Proxying Settings」

  • 电脑端信任证书

  • 手机端下载证书,将下载的证书文件扩展名pem改为crt,即可安装

安装证书后部分HTTPS请求可以正常获取,还有大部分显示<unknown>,待后续研究

Hello World

Posted on 2019-02-14 | In Hexo

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

Git-如何将未跟踪的例外文件拉到本地

Posted on 2019-02-12 | In Git

远程仓库中添加了一些未跟踪的例外文件到.gitignore中,通过git clone到本地仓库中,这些文件会缺失,通过下面步骤可以获取这些例外文件,便于搭建本地环境

1、远程仓库:新建并切换到分支allfile

git checkout -b allfile

2、远程仓库:修改.gitignore文件,移除例外文件

vim .gitignore
去除内容public/uploads

3、远程仓库:添加所有文件并提交

git add .
git commit -m "add all file"

4、本地仓库:拉取远程分支

git pull 

6、本地仓库:迁出allfile分支中的例外文件

git checkout allfile public/uploads

7、本地仓库:去除例外文件的跟踪

git rm -r --cached public/uploads

此时例外文件public/uploads将保留在本地仓库并不被跟踪

Git-部署本地代码到远程仓库

Posted on 2019-01-30 | In Git

这样部署的前提是已经配置好远程服务器 www.xxxx.net 中用户www的免密登录

  1. 本地项目代码准备完毕,代码中无.gitignore文件
  2. 初始化本地仓库,在本地执行

    #初始化仓库
    git init    
    #windows中禁用自动转换
    git config --global core.autocrlf false
    #缓存文件
    git add .
    #提交本地仓库
    git commit -m "init"
    #创建远程连接
    git remote add origin www@www.xxxx.net:/home/www/heal     
    
  3. 初始化远程仓库,在远程执行

    #创建远程仓库目录
    cd /home/www
    mkdir heal
    #进入目录
    cd heal
    #初始化仓库
    git init
    #设置允许修改当前分支
    git config receive.denyCurrentBranch ignore
    #添加钩子自动checkout
    vim .git/hooks/post-receive
    #添加以下代码
        echo "checkout to HEAD"
        git --work-tree=.. checkout -f
    #赋予权限
    chown www:www -R ../heal
    #设置用户www的bash
    usermod -s /bin/bash www
    
  4. 将本地仓库推送到远程,在本地执行

    git push -u origin master
    #此时本地代码与远程仓库代码一致
    
  5. 添加或更新例外文件.gitignore,在远程执行

    vim .gitignore
    git rm -r --cached .
    git add .
    git commit -m 'gitignore update'
    
  6. 本地更新

    #下载更新(在.gitignore中的内容不会下载到本地)
    git pull
    
1234…7

wiggin

31 posts
9 categories
7 tags
RSS
© 2025 wiggin
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4
本站访客数: