0

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

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

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

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

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

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

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

4

1 回答 1

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/

于 2013-10-07T19:18:58.887 回答