【问题标题】:How can I call a Python script from within OpenERP?如何从 OpenERP 中调用 Python 脚本?
【发布时间】:2013-09-30 21:51:26
【问题描述】:

在我的国家/地区,法律要求每张电子发票都包含一个名为“控制代码”的字段。

控制代码是使用发票日期、发票编号和一些自定义字段通过一系列计算和算法计算出来的。

现在我已经有了一个 Python 脚本来生成控制代码,但它是一个独立的脚本,需要你手动插入变量。

我真的很想在 OpenERP 模块中使用这个脚本。我希望脚本:

  1. 验证发票(包含所有必填字段)

  2. 使用 Python 脚本的结果填充发票上的控制代码字段。

  3. 确保发票经过验证并且字段控制代码存储在发票中。

【问题讨论】:

  • 你以前写过OpenERP模块吗?你试过什么?什么有效,什么无效?

标签: python openerp account invoice


【解决方案1】:

使用函数的字段来解决这个问题。

_inherit = 'account.invoice'

def generate_control_code(self, cr, uid, ids, field_name, arg, context=None)
# ids - Invoice ids
# filed_name - Name of the field. In this case 'control_code'
# Return result format {id'_1_': value'_1_', id'_2_': value'_2_',...}.
....
....
....
    return result


_columns = {

    'control_code': fields.function(generate_control_code, type='char', string='Control Code', method=True),

}

更多详情请查看此文档链接http://www.theopensourcerer.com/2012/12/how-to-install-openerp-7-0-on-ubuntu-12-04-lts/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-09
    • 2014-03-18
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多