跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

F

fxiao

@fxiao
关于
帖子
8
主题
5
群组
0
粉丝
0
关注
0

帖子

最新 最佳 有争议的

  • Xmlrpc,php 操作 OE 的方法 --- 搜索、读取、创建、更新
    F fxiao

    为什么还要直接执行 SQL 语句。。知道 ORM 的概念吗?了解一些 ORM 的操作模式(就是面向对象),你的问题也就不是问题了


  • Openerp 与 httplib2 冲突
    F fxiao

    操作系统:debian 6.0.7
    oe:openerp_7.0-20121227-075624-1 到 openerp_8.0dev-20130328-000101-1

    用 /etc/init.d/openerp start 启动。进程一闪而过,/var/log/openerp-server.log 没有墨迹。

    直接用命令:

    <br />start-stop-daemon --start --quiet --pidfile /var/run/openerp-server.pid --chuid openerp --make-pidfile --exec /usr/bin/openerp-server -- --config=/etc/openerp/openerp-server.conf<br />
    



    报错:

    <br />IOError: [Errno 13] Permission denied: &#039;/usr/local/lib/python2.6/dist-packages/httplib2-0.8-py2.6.egg/EGG-INFO/top_level.txt&#039;<br />
    



    解决:easy_install -m httplib2

    P.S. 没有进一步追踪了。很奇怪,oe 关 httplib2 鸟事。期望有人有空追踪一下。


  • Xmlrpc,php 操作 OE 的方法 --- 搜索、读取、创建、更新
    F fxiao

    php 操作 OE 的方法

    phpxmlrpc 版本:v2.2.2( http://phpxmlrpc.sourceforge.net/ )
    openerp 版本:v7.0-20130103-002220-1
    LNMP 版本:v0.9

    * 搜索
    * 读取
    * 创建
    * 更新。

    如果报 "Call to a member function scalarval() on a non-object" 错,请看看是不是 fsockopen 函数被禁用。
    * vi /usr/local/php/etc/php.ini
    * 搜索 disable_functions, 删除里面的 fsockopen

    还有个问题,创建和更新的方法,不能用 $GLOBALS['xmlrpc_internalencoding']='UTF-8'; 必须要用 ISO-8859-1,否则就会报错。

     <br />&lt;?php<br />require(&quot;./xmlrpc/lib/xmlrpc.inc&quot;);<br />// 这里就是解决商品名称中有中文时的乱码问题<br />//$GLOBALS&#91;&#039;xmlrpc_internalencoding&#039;]=&#039;UTF-8&#039;; // 如果从里定义的话,那么 create、write 方法就会出现 500 错误。<br />class XmlrpcOe{<br />&nbsp; &nbsp; public $user = &#039;admin&#039;;<br />&nbsp; &nbsp; public $password = &#039;admin&#039;;<br />&nbsp; &nbsp; public $user_id = -1;<br />&nbsp; &nbsp; public $dbname = &#039;test&#039;;<br />&nbsp; &nbsp; public $server_url = &#039;http://127.0.0.1:8069/xmlrpc/&#039;;<br />&nbsp; &nbsp; public function __construct() {<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;sock_common();<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;sock_object();<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;connect();<br />&nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; public function sock_common() {<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;sock_com = new xmlrpc_client($this-&gt;server_url.&#039;common&#039;);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; public function sock_object() {<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;sock_obj = new xmlrpc_client($this-&gt;server_url.&#039;object&#039;);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; /**<br />&nbsp; &nbsp;  * 登录,获取 user_id<br />&nbsp; &nbsp;  */<br />&nbsp; &nbsp; public function connect() {<br />&nbsp; &nbsp; &nbsp; &nbsp; /*<br />&nbsp; &nbsp; &nbsp; &nbsp; if(isset($_COOKIE[&quot;user_id&quot;]) == true)&nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($_COOKIE[&quot;user_id&quot;]&gt;0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $_COOKIE[&quot;user_id&quot;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp;  */<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg = new xmlrpcmsg(&#039;login&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;dbname, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;user, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;password, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $resp =&nbsp; $this-&gt;sock_com-&gt;send($msg);<br />&nbsp; &nbsp; &nbsp; &nbsp; $val = $resp-&gt;value();<br />&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;user_id = $val-&gt;scalarval();<br />&nbsp; &nbsp; &nbsp; &nbsp; setcookie(&quot;user_id&quot;,$this-&gt;user_id,time()+3600);<br />&nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; /**<br />&nbsp; &nbsp;  * 搜索-单条件<br />&nbsp; &nbsp;  * $relation: 搜索的对象,如:product.category<br />&nbsp; &nbsp;  * $attribute: 属性,如:name<br />&nbsp; &nbsp;  * $operator: 条件,如:&gt;、=、!=、like<br />&nbsp; &nbsp;  * $keys: 值,如:p<br />&nbsp; &nbsp;  */<br />&nbsp; &nbsp; public function search($relation, $attribute, $operator, $keys) {<br />&nbsp; &nbsp; &nbsp; &nbsp; $GLOBALS&#91;&#039;xmlrpc_internalencoding&#039;]=&#039;UTF-8&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; $key = array(new xmlrpcval(array(new xmlrpcval($attribute , &quot;string&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new xmlrpcval($operator,&quot;string&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new xmlrpcval($keys,&quot;string&quot;)),&quot;array&quot;),);<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg = new xmlrpcmsg(&#039;execute&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;dbname, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;user_id, &quot;int&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;password, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($relation, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval(&quot;search&quot;, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($key, &quot;array&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $resp = $this-&gt;sock_obj-&gt;send($msg);<br />&nbsp; &nbsp; &nbsp; &nbsp; $val = $resp-&gt;value();<br />&nbsp; &nbsp; &nbsp; &nbsp; $ids_rpc_array = $val-&gt;scalarval();<br />&nbsp; &nbsp; &nbsp; &nbsp; $ids = array();<br />&nbsp; &nbsp; &nbsp; &nbsp; foreach($ids_rpc_array as $id_obj) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ids&#91;] = $id_obj-&gt;me[&quot;int&quot;];<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; return $ids_rpc_array;<br />&nbsp; &nbsp; &nbsp; &nbsp; //return $ids;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; /**<br />&nbsp; &nbsp;  * 读数据,通过 id 读取相关数据<br />&nbsp; &nbsp;  * $relation: 数据对象,如:product.product<br />&nbsp; &nbsp;  * $ids: id 的数组,如:array(new xmlrpcval(4, &quot;int&quot;));<br />&nbsp; &nbsp;  * $field_array: 字段数组<br />&nbsp; &nbsp;  */<br />&nbsp; &nbsp; public function read($relation, $ids, $field_array) {<br />&nbsp; &nbsp; &nbsp; &nbsp; $GLOBALS&#91;&#039;xmlrpc_internalencoding&#039;]=&#039;UTF-8&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; $msg = new xmlrpcmsg(&#039;execute&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;dbname, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;user_id, &quot;int&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;password, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($relation, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval(&quot;read&quot;, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($ids, &quot;array&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($field_array, &quot;array&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $resp = $this-&gt;sock_obj-&gt;send($msg);<br />&nbsp; &nbsp; &nbsp; &nbsp; $val = $resp-&gt;value();<br />&nbsp; &nbsp; &nbsp; &nbsp; return $val-&gt;scalarval();<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; public function create($relation, $partner_data) {<br />&nbsp; &nbsp; &nbsp; &nbsp; $GLOBALS&#91;&#039;xmlrpc_internalencoding&#039;]=&#039;ISO-8859-1&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg = new xmlrpcmsg(&#039;execute&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;dbname, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;user_id, &quot;int&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;password, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($relation, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval(&quot;create&quot;, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($partner_data, &quot;struct&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $resp = $this-&gt;sock_obj-&gt;send($msg);<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($resp-&gt;faultCode())<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &#039;Error: &#039;.$resp-&gt;faultString();<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &#039;Partner &#039;.$resp-&gt;value()-&gt;scalarval().&#039; created !&#039;;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; public function write($relation, $data, $ids) {<br />&nbsp; &nbsp; &nbsp; &nbsp; $GLOBALS&#91;&#039;xmlrpc_internalencoding&#039;]=&#039;ISO-8859-1&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg = new xmlrpcmsg(&#039;execute&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;dbname, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;user_id, &quot;int&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($this-&gt;password, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($relation, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval(&quot;write&quot;, &quot;string&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($ids, &quot;array&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $msg-&gt;addParam(new xmlrpcval($data, &quot;struct&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; $resp = $this-&gt;sock_obj-&gt;send($msg);<br />&nbsp; &nbsp; &nbsp; &nbsp; $val = $resp-&gt;value();<br />&nbsp; &nbsp; &nbsp; &nbsp; return $val-&gt;scalarval();<br />&nbsp; &nbsp; }<br />}<br />$xmlrpc_oe = new XmlrpcOe();<br /># 搜索<br />echo &quot;search:&lt;br /&gt;&quot;;<br />$ids = $xmlrpc_oe-&gt;search(&quot;product.product&quot;, &quot;id&quot;, &quot;&gt;&quot;, &quot;1&quot;);<br />print_r($ids);<br />echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;<br /><br />$id_array = array();<br />foreach($ids as $id_obj) {<br />&nbsp; &nbsp; $id_array&#91;] = $id_obj-&gt;me[&quot;int&quot;];<br />}<br />print_r($id_array);<br />echo &quot;&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------&lt;br /&gt;&quot;;<br /> <br /># 读数据<br />echo &quot;read:&lt;br /&gt;&quot;;<br />$field_array = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; new xmlrpcval(&quot;id&quot;, &quot;int&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; new xmlrpcval(&quot;name&quot;, &quot;string&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; new xmlrpcval(&quot;list_price&quot;, &quot;string&quot;),<br />&nbsp; &nbsp; );<br />$ret_array = $xmlrpc_oe-&gt;read(&quot;product.product&quot;, $ids, $field_array);<br />print_r($ret_array);<br />echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;<br />$out_array = array();<br />foreach($ret_array as $k =&gt; $v) {<br />&nbsp; &nbsp; $tmp_id = $v-&gt;me&#91;&#039;struct&#039;]&#91;&#039;id&#039;]-&gt;me[&quot;int&quot;];<br />&nbsp; &nbsp; $tmp_name = $v-&gt;me&#91;&#039;struct&#039;]&#91;&#039;name&#039;]-&gt;me[&quot;string&quot;];<br />&nbsp; &nbsp; $tmp_price = $v-&gt;me&#91;&#039;struct&#039;]&#91;&#039;list_price&#039;]-&gt;me[&quot;double&quot;];<br />&nbsp; &nbsp; $out_array&#91;] = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;id&quot; =&gt; $tmp_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot; =&gt; $tmp_name,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;list_price&quot; =&gt; $tmp_price,<br />&nbsp; &nbsp; &nbsp; &nbsp; );<br />}<br />print_r($out_array);<br />echo &quot;&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------&lt;br /&gt;&quot;;<br /><br /># 添加<br />echo &quot;create:&lt;br /&gt;&quot;;<br />$partner_data = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot; =&gt; new xmlrpcval(&quot;魅族 MX2 32GB&quot;, &quot;string&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;list_price&quot; =&gt; new xmlrpcval(2999.00, &quot;double&quot;),<br />&nbsp; &nbsp; );<br />//$xmlrpc_oe-&gt;create(&quot;product.product&quot;, $partner_data);<br />echo &quot;&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------&lt;br /&gt;&quot;;<br /><br /># 修改<br />echo &quot;write:&lt;br /&gt;&quot;;<br />$ids = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; new xmlrpcval(7, &quot;int&quot;),<br />&nbsp; &nbsp; );<br />$data = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot; =&gt; new xmlrpcval(&quot;魅族 MX2 64GB&quot;, &quot;string&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;list_price&quot; =&gt; new xmlrpcval(3999.00, &quot;double&quot;),<br />&nbsp; &nbsp; );<br />$xmlrpc_oe-&gt;write(&quot;product.product&quot;, $data, $ids);<br />$ret_array = $xmlrpc_oe-&gt;read(&quot;product.product&quot;, $ids, $field_array);<br />$out_array = array();<br />foreach($ret_array as $k =&gt; $v) {<br />&nbsp; &nbsp; $tmp_id = $v-&gt;me&#91;&#039;struct&#039;]&#91;&#039;id&#039;]-&gt;me[&quot;int&quot;];<br />&nbsp; &nbsp; $tmp_name = $v-&gt;me&#91;&#039;struct&#039;]&#91;&#039;name&#039;]-&gt;me[&quot;string&quot;];<br />&nbsp; &nbsp; $tmp_price = $v-&gt;me&#91;&#039;struct&#039;]&#91;&#039;list_price&#039;]-&gt;me[&quot;double&quot;];<br />&nbsp; &nbsp; $out_array&#91;] = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;id&quot; =&gt; $tmp_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot; =&gt; $tmp_name,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;list_price&quot; =&gt; $tmp_price,<br />&nbsp; &nbsp; &nbsp; &nbsp; );<br />}<br />print_r($out_array);<br /><br />
    



    参考:
    [检测到链接无效,已移除]
    http://doc.openerp.com/v6.0/developer/6_22_XML-RPC_web_services/index.html


  • Oe6.1.1 安装模块 product_links(6.0版),抛出no attribute 'external_osv' 解决方案
    F fxiao

    [size=18pt]抛出错误[/size]
    AttributeError: 'module' object has no attribute 'external_osv'

    [size=18pt]原因[/size]
    product_links 继承了 base_external_referentials模块的 external_osv类。
    base_external_referentials模块6.0版,有一个external_osv类

    <br />class external_osv(osv.osv):<br />&nbsp; &nbsp; pass #FIXME remove! only here for compatibility purpose for now<br />
    


    但安装是6.1版,已经去掉了这个类

    [size=18pt]解决方案[/size]
    修改product_links.py文件。
    原代码(部分)

    <br />from osv import fields, osv<br />from base_external_referentials import external_osv<br /><br />class product_link(external_osv.external_osv):<br />&nbsp; &nbsp; _name = &#039;product.link&#039;<br />&nbsp; &nbsp; _rec_name = &#039;linked_product_id&#039;<br />
    



    修改成

    <br />from osv import fields, osv<br />#from base_external_referentials import external_osv<br /><br />#class product_link(external_osv.external_osv):<br />class product_link(osv.osv):<br />&nbsp; &nbsp; _name = &#039;product.link&#039;<br />&nbsp; &nbsp; _rec_name = &#039;linked_product_id&#039;<br />
    

  • 基于 openerp-6.2dev-20121014-230101 进行翻译修补更新
    F fxiao

    基于 openerp-6.2dev-20121014-230101 已有的翻译基础上,进行修补更新,
    每个模块一个文件zh_CN.po文件,附件解压后格式 --- 模块名-zh_CN.po。

    先更新:
    web
    web_graph

    明天预算:
    l10n_ch
    sale


  • 求:如何在产品列表tree添加图片字段(显示缩略图)
    F fxiao

    在视图product.product.tree上添加
    <field name="product_image" widget="image" img_width="300" img_height="300"></field>
    显示是图片的大小。

    应该如何定义这个字段才可以显示图片和控制这个图片大小?
    求教!!谢谢


  • OpenERP基础篇-新手入门-环境搭建- Ubuntu&amp;OpenERPV6
    F fxiao

    基本原因是 web client 没有启动成功。查看 openerp-server.log 找问题


  • FreeBSD安装OpenERP 6.1
    F fxiao

    谢谢!参考一下,看看在LION安装如何,还有CENTOS5.8

  • 登录

  • 没有帐号? 注册

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组