Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to update one2many in customers from accounting invoice

By
Md. Tanzilul Hasan Khan
on 3/1/16, 1:17 AM 535 views
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.


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

Jo
on 3/1/16, 1:26 AM

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

Md. Tanzilul Hasan Khan
on 3/1/16, 1:31 AM

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

Md. Tanzilul Hasan Khan
on 3/1/16, 5:37 AM
0

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

0
Jo
On 3/1/16, 1:44 AM

Hi Md. Tanzilul Hasan Khan,

Just try this, I hope this will work.

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

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

Md. Tanzilul Hasan Khan
on 3/1/16, 1:47 AM

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

Jo
on 3/1/16, 1:50 AM

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

Md. Tanzilul Hasan Khan
on 3/1/16, 5:37 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/1/16, 1:17 AM
Seen: 535 times
Last updated: 3/1/16, 5:36 AM