使自定义odoo 9模块中的已开发功能在odoo 11中工作

时间:2018-08-29 10:31:54

标签: python-3.5 odoo-11

我正在使用odoo 11,我想创建一个自定义模块以在每张发票中自动添加印花税。我已经在odoo 9中开发了这种模块,但是安装后在oodo 11中却无法使用。这是python(v2.7)文件的代码:

from openerp import tools
from openerp.osv import fields, osv

class res_partner(osv.osv):
_name = "res.company"
_inherit = "res.company"
_columns = {
    "default_stamp_tax_account": fields.many2one('account.account', "stamp tax account"),
    "default_stamp_tax_value": fields.float('stamp tax value'),
}


class account_invoice(osv.osv):
_name = "account.invoice"
_inherit = "account.invoice"

 def create(self, cr, uid, values, context=None):
     invoice_id = super(account_invoice, self).create(cr, uid, values, context)

     res_company = self.pool.get('res.company')

     stamp_account = res_company.browse(cr, uid, values.get('company_id')).default_stamp_tax_account.id
     tax_value = res_company.browse(cr, uid, values.get('company_id')).default_stamp_tax_value

     if stamp_account:
         account_invoice_tax = self.pool.get('account.invoice.tax')

         tax_line_values = {'base': 0,
                            'amount': tax_value,
                            'name': 'Timbre',
                            'account_id': stamp_account,
                            'invoice_id': invoice_id
                            }

         account_invoice_tax.create(cr, uid, tax_line_values)

     return invoice_id

任何帮助,请!!!

0 个答案:

没有答案