Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
5186 มุมมอง

ODOO (V11) XMLRPC calling on custom model method (test) is through an error if a create method is uncommitted and client expect "self" as argument. (I am using python)

    class DataParser(models.Modle):
          _name = "data.parser"
         test_a: fields.Char()
         test_b: fields.Char()

         @api.one
         def test(self):
             obj = self.env['data.parser'].create({'test_a':"test a", 'test_b': "Test B "})
    
            return True

XMLRPC Client

   url = 'http://localhost:8069'
   db = 'test'
   username = 'admin'
   password = 'admin'

   logging.info("url {}, db {}".format(url, db))

   common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url), allow_none=True)
   print(common.version())
   val  = common.login(db, username, password)

  uid = common.authenticate(db, username, password, {})

  models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
  val = models.execute_kw(db, uid, password, "data.parser", "test", ["self"])

Error res = self._obj.execute (query, params) \ npsycopg2.ProgrammingError: column "test_b" of relation "data_parser" does not exist \ nLINE 1: INSERT INTO "data_parser" ("id", "test_b", "test_a

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi there,

Try @api.model decorator 


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 25
3630
1
ต.ค. 24
2626
1
เม.ย. 24
2772
0
ก.ย. 23
2098
9
มิ.ย. 23
13687