FAQ

1. PDF打印不了

缺少wkhtmltopdf插件
参考笔者[博客](http://mixoo.cn/2019/06/19/odoo-wkhtmltopdf-install/ )或者直接使用如下命令:

```sh
wget -O - https://raw.githubusercontent.com/jellyhappy/tools/master/wkhtml.sh|bash
```

2. 报表中文字体乱码

参考笔者[博客](http://mixoo.cn/2019/06/24/odoo-report-chinese/) 安装字体以解决乱码问题

3. 报表PDF打印不了条码

按如下步骤排查:

1. 检查系统wkhtmltopdf版本,要求>= 0.12.4
2. 报表切换到HTML格式 看能否正常输出条码
3. 检查条码依赖是否已安装,使用下面命令安装

    ```sh
    apt-get install python3-reportlab 
    pip install -U reportlib
    ```

4. 检查系统参数中的report.url参数是否跟域名一致
5. (ubuntu18.04) 安装libssl1.0-dev库

     ```sh
    apt-get install libssl1.0-dev
    ```

4. 混合内容问题

通常的报错内容:

   Mixed Content: The page at 'https://' was loaded over HTTPS, but requested an insecure resource 'http://'. This request has been blocked; the content must be served over HTTPS.

原因在于使用https协议访问了http协议的内容。

这通常是使用反向代理软件的配置问题,以常见的Nginx为例,我们需要将服务器的响应内容由Http更改为Https:

   proxy_redirect http://yourdomainhere/ https://yourdomainhere/

5. 如何修改data.xml中的no_update属性?

使用如下代码:

```xml
<function name="write" model="ir.model.data">
    <function name="search" model="ir.model.data">
        <value eval="[('module', '=', 'sale'), ('name', 'in', ('sale_order_personal_rule','sale_order_see_all'))]"/>
    </function>
    <value eval="{'noupdate': False}"/>
</function>
```

module为模块名,name为需要修改的record的xmlid中的name。

6. 为何有时候compute的方法不生效?

首先,需要判断字段类型是否是store=True的,如果是,那么检查响应的依赖字段是否更新,因为存储的计算字段只有当依赖字段发生改变时才会更新。

其次,如果是不存储的compute字段,那么检查当前record的值是否为空,为空的record不会触发compute指定的方法,而是会直接返回False

7. 由于记录规则引发的异常

由于权限设置或者编码不规范导致的异常,通常如下所示:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 684, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 360, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 348, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 913, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 532, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1389, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1381, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 396, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 383, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 1740, in name_get
    result.append((record.id, convert(record[name], record)))
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5662, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 998, in __get__
    record._fetch_field(self)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 3065, in _fetch_field
    self._read(fnames)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 3176, in _read
    raise self.env['ir.rule']._make_access_error('read', forbidden)
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 640, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 316, in _handle_exception
    raise exception.with_traceback(None) from new_cause
odoo.exceptions.AccessError: 由于安全限制,不允许您访问'线索/商机' (crm.lead)记录。

记录: 5.03线索-订单不同状态下创建活动001 (id=16234)
用户:徐乐 (id=3089)

这个限制基于下列规则:
- Personal Leads
- Leads with assigned activities

如有必要,请与管理员联系以请求访问权限。
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 684, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 360, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 348, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 913, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 532, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1389, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1381, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 396, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 383, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 1740, in name_get
    result.append((record.id, convert(record[name], record)))
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5662, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 998, in __get__
    record._fetch_field(self)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 3065, in _fetch_field
    self._read(fnames)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 3176, in _read
    raise self.env['ir.rule']._make_access_error('read', forbidden)
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 640, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 316, in _handle_exception
    raise exception.with_traceback(None) from new_cause
odoo.exceptions.AccessError: 由于安全限制,不允许您访问'线索/商机' (crm.lead)记录。

记录: 5.03线索-订单不同状态下创建活动001 (id=16234)
用户:徐乐 (id=3089)

这个限制基于下列规则:
- Personal Leads
- Leads with assigned activities

如有必要,请与管理员联系以请求访问权限。

如果不想设置权限,那么可以根据报错信息,定位到触发权限校验的方法名,本例中我们看到的是name_get方法,因此,我们只需要将该对象(crm.lead)的name_get方法进行提权就可以了。

def name_get(self):
    """"""
    return super(crm_lead,self.sudo()).name_get()

8. 创建/还原数据库失败

Database creation error: template database "template006c933e1826a5f1b3090e6192388eefa9f87f480" does not exist

配置文件中的db_template设置为template0即可解决此问题

9. 不明显的记录规则错误

一般情况下,记录规则的报错都会指出是哪个记录规则引起的报错,此类错误的排查根据提示的记录规则处理即可,但是有一类特殊的异常并没有指明它的记录规则,也就是说记录规则是空的,此类的错误的典型报错示例如下:

Records: test1 (id=63)
User: test1 (id=63)

This restriction is due to the following rules:


Contact your administrator to request access if necessary.

Implicitly accessed through 'Users' (res.users). - - -

如果按照提示去找Users对象的记录规则,是无法解决此问题的,该问题出现的原因在于与Users关联的Partner对象的记录规则有问题。通常是因为无权访问该用户的关联合作伙伴,导致用户甚至无法正常登陆。因此我们在给res.partner模型设置权限的时候一定要多注意。

10. Inherited Qweb view cannot have 'Groups' define on the record. Use 'groups' attributes inside the view definition

这个字面意思是Qweb继承视图不能设置Groups,实际上指的是Qweb的继承视图上不能设置组权限。

11. 没有依赖项的计算字段如何在每次读取的时候跳过缓存?

有时候我们定义的计算字段不依赖于本模型的任何一个字段, 而是依赖于其他模型的字段, 这个时候,我们就没有办法在有弹窗的情况下进行重新获取. 关闭弹窗后, 由于缓存的原因,获取到的值依旧是第三方模型更新前的记录.

这种情况下,可以使用另外一种神秘的辅助手段来解决:

  1. 查看本模型中是否存在带有inverse字段的计算字段
  2. 给上面的字段赋一个有效的值

以上两步以后, 当我们在更新弹窗内的关联模型的记录值,然后关闭弹窗以后, 新值就会显示在当前页面中了.

results matching ""

    No results matching ""