如何从OpenERP中调用Python脚本?

2024-04-25 00:27:26 发布

您现在位置:Python中文网/ 问答频道 /正文

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

控制代码由一系列计算和算法计算,使用发票日期、发票号和一些自定义字段。在

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

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

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

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

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


Tags: 模块脚本算法电子发票手动openerp法律
1条回答
网友
1楼 · 发布于 2024-04-25 00:27:26

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

_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/

相关问题 更多 >