コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
9336 ビュー

Hi everybody,

I recently started to develop with odoo8 and I've met a problem.

My problem is that I have two classes : 'helpdesk' and 'res_partner' and I don't know why my code stuck indefinitely when I commit the new record to 'res_partner' but when I comment this block of codes (below) my code works great.

'helpdesk' class has several fields and methods to get informations and computes them from the user inputs. Once the informations computed, I create my record which is a new partner.

To try to solve my problem, I:

  • Launched odoo in shell mode with '--debug' option and a pdb where the code is stuck (it's stuck at the commit line)

  • Read some threads and documentations about my problem, but most are in v7

  • Checked every values that I sent to create my new record

  • Saw available records with phpPgAdmin

  • Changed the decorator


This is how I create new partner record from 'helpdesk' to 'res_partner' :

#method in heldesk class
@api.one
def addPartnerInDB(self):
    #other lines of codes above...
    self.env['res.partner'].create(
        {
            'name': nameFmt,
'firstname': self.firstNameOfUser.strip().lower().title(),
'lastname': self.lastNameOfUser.strip().upper(),
'birthdate': dateObj.strftime("%d/%m/%Y"),
'birth_place': self.pBirthOfUser,
'is_company': False
}
)
self.env.cr.commit()

P.S: in another class method, I exactly did the same 'create' but not for a partner and Odoo warns me that I "compared apples and oranges". It's probably the same problem here but worse.


Thanks in advance for your help.

アバター
破棄
著作者 最善の回答

If you would like to know where was my problem and how I solved it see the link below :

https://stackoverflow.com/questions/44021741/odoov8-why-does-it-take-so-long-to-create-a-record-in-res-partner-in-my-case

アバター
破棄
最善の回答

Why this line

self.env.cr.commit()

You have no operations with the cursor in your code yet and why you need a cr.commit?

アバター
破棄
関連投稿 返信 ビュー 活動
1
1月 19
11421
1
10月 17
3293
1
3月 15
10526
2
12月 22
3693
2
2月 22
17019