Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
6 Răspunsuri
4744 Vizualizări
I have created an one2many to customer form. So, when I am validating (button validate) an invoice I am trying to pass some values in that one2many. I have tried many ways and followed odoo forums, but I am having trouble to do that. Using following code:
My one2many field is 'customer_status' in 'res.partner' :

@api.multi

@api.model

def invoice_validate(self):

customer_obj=self.env['res.partner']

customer_id=customer_obj.search([('id','=',self.partner_id.id)])

customer_line=customer_obj.browse(customer_id)

dd = {'policy_number': self.policy_no,}

customer_stat_add = customer_obj.write([customer_line.id],{

'customer_status': [(0, 0, dd)]

})

state_change = self.write({'state': 'open'})

return state_change, customer_stat_add

Thanks.


Imagine profil
Abandonează

@Md. Tanzilul Hasan Khan@ Can you show here? that error(trouble)...! This will help us to give a correct suggestion...

Autor

@Jo, the error is following: ValueError: "write() got multiple values for keyword argument 'context'" while evaluating u'invoice_validate()'

Autor

Value was right, browse was problem. I have posted below. Thanks :)

Autor Cel mai bun răspuns

I solved the problem, was browsing in a wrong way:


@api.multi

def invoice_validate(self):

customer_obj=self.env['res.partner']

customer_id=customer_obj.search([('id','=',self.partner_id.id)])

customer_line=customer_obj.browse([customer_id.id])

dd = {

'policy_number': self.policy_no,

}

customer_stat_add = customer_line.write({'customer_status': [(0, 0, dd)]})

state_change = self.write({'state': 'open'})

return state_change, customer_stat_add

Imagine profil
Abandonează
Cel mai bun răspuns

Hi Md. Tanzilul Hasan Khan,

Just try this, I hope this will work.

customer_line.write({'customer_status': [(0, 0, dd)]})

Imagine profil
Abandonează
Autor

I already tried that, it gives another error: ValueError: "can't adapt type 'res.partner'" while evaluating u'invoice_validate()'

Omg, Please check with your values, which i thought in your "self.policy_no"...!

Autor

Value was right, browse was problem. I have posted below. Thanks :)

Related Posts Răspunsuri Vizualizări Activitate
6
aug. 19
63792
1
feb. 19
9692
1
mar. 21
2365
4
iul. 25
850
0
oct. 24
189