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 assign value in Many2one field in odoo9

By
Apoorv Soral
on 11/23/16, 4:45 AM 65 views

_name = "confirm.auction"    

product_id = fields.Char("Product",readonly= True)

customer_auc_id = fields.Many2one("res.user","Customer", readonly = True)

date_bid = fields.Date("Bid Date", readonly = True)

amt_bid = fields.Float("Bid Amount", readonly = True)

conf_auc_id = fields.Many2one("auction","Auction")

---------------------------------------------------------------------------------------------------------

_name = "bid"

 auc_id = fields.Char("Auction Id", readonly = True)

product_id = fields.Char("Product",readonly= True)

amount_auc = fields.Float("Amount")

state= fields.Selection([('publish','Publish'), ('cancel','Cancel'), ('done','Done') ],'Status',readonly=True,copy=False,select=True,default='draft')



@api.one

def bid_confirm(self):

    date = time.strftime("%Y-%m-%d") 

    auc = self.env['auction'].search([('auction_id','=',self.auc_id)])

     res = self.env['confirm.auction'].create({

                 'conf_auc_id':auc.id,

                 'product_id':self.product_id,

                 'customer_auc_id.id':self.write_uid.id,

                 'date_bid':date,

                 'amt_bid':self.amount_auc

    })


and if i remove id [ 'customer_auc_id':self.write_uid.id,  ]  so it is assign [  _unknown ,1 ]

i want to store customer name in m2o field customer_auc_id but it's not assigning correctly.

how to solve this issue?

0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 11/24/16, 12:54 AM

Hi,

I think you've a typo in the res.users name "you writing it : res.user" without 's'.

So try:

customer_auc_id = fields.Many2one("res.users","Customer", readonly = True)

and use:

'customer_auc_id': self.write_uid.id


Hope this could helps

Hi Ahmad,

i also try this but problem is it's print value is [ _unknown ,1 ]

Apoorv Soral
on 11/24/16, 3:09 AM

did you restarted and upgrade your module, if yes could you please paste your final code ?

Ahmed M.Elmubarak
on 11/24/16, 6:32 AM

_name = "confirm.auction"

customer_auc_id = fields.Many2one("res.user","Customer", readonly = True)

_name = "bid"

@api.one

def bid_confirm(self):

date = time.strftime("%Y-%m-%d")

auc = self.env['auction'].search([('auction_id','=',self.auc_id)])

res = self.env['confirm.auction'].create({

'conf_auc_id':auc.id,

'product_id':self.product_id.id,

'customer_auc_id':self.write_uid.id,

'date_bid':date,

'amt_bid':self.amount_auc

})

Apoorv Soral
on 11/25/16, 1:07 AM

It's print

[DPP] Early payment discount _unknown,1 11/25/2016 900.00

Apoorv Soral
on 11/25/16, 1:11 AM

Man, You're still writing res.user it is res.users not res.user

Ahmed M.Elmubarak
on 11/26/16, 12:12 AM

ohk. Thanks...dear

Apoorv Soral
on 11/26/16, 4:20 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: 11/23/16, 4:45 AM
Seen: 65 times
Last updated: 11/24/16, 12:54 AM