TypeError:update_info()至少需要4个参数(给定2个) - Odoo v10社区

时间:2017-02-27 01:29:58

标签: python openerp

由于我将一些v7模块迁移到v10社区,我仍然面临一些错误和挑战,例如,这是一个寻找大桶的向导:

MODULE mod1
  ...
CONTAINS

  SUBROUTINE sub1(w)

    IMPLICIT NONE
    INTENT(OUT) :: w
    REAL :: x, z

    CALL sub2(x, z)

    w = z + 1

  END SUBROUTINE sub1

  SUBROUTINE sub2(x, z)

    IMPLICIT NONE      
    INTENT(IN) :: x
    INTENT(OUT) :: z

    z = x + 1

  END SUBROUTINE sub2

END MODULE mod1

PROGRAM prog

  USE mod1
  IMPLICIT NONE

  IF (...) THEN
    ...
  ELSE
    x = y
    CALL sub1(w)
    x = w + y
  END IF

END PROGRAM prog

但是每当我尝试运行这个方法时,它就会抛出这个:

from odoo import api, fields, models

class UpdateInfoPartner(models.TransientModel):
_name = 'update.info.partner'

def update_info(self, cr, uid, ids, context=None):

    context = context or {} #dict(self._context or {})
    seniat_url_obj = self.pool.get('seniat.url')
    self.env.cr.execute('''SELECT id FROM res_partner WHERE vat ilike 'VE%';''')
    record = self.env.cr.fetchall()
    pids = [item[0] for item in record]
    seniat_url_obj.connect_seniat(self.env.cr, uid, pids, context=context,
                                  all_rif=True)
    return{}

在python之前有过这种错误,但我对这种方法看不太清楚。

有什么想法吗?

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

可能这可以帮到你:

from odoo import api, fields, models

class UpdateInfoPartner(models.TransientModel):
_name = 'update.info.partner'

def update_info(self):

    context = dict(self.env.context or {})
    seniat_url_obj = self.env['seniat.url']
    self.env.cr.execute('''SELECT id FROM res_partner WHERE vat ilike 'VE%';''')
    record = self.env.cr.fetchall()
    pids = [item[0] for item in record]
    seniat_url_obj.connect_seniat(self.env.cr, self.env.uid, pids,context=self.env.context, all_rif=True)
    return{}