Skip to Content
Menu
This question has been flagged
1 Reply
1462 Views

hello everyone 

this is my code:-

class bookingschedual(models.model):

_name = 'booking.schedule'


partner_id = fields.Many2one(res.partner, string=customer)


sale_ids = fields.Many2many("sale.order", 'sale_order_rel', "booking_id", "sale_id", string="sale order")


sale_orders = fields.Many2many("sale.order", "booking_sale_rel","booking_id_rec","sale_id_rec",string="sale ids")


in this code when i select one res.partner in partner_id field i got this res.partner's sale order in sale_ids field .


now i want the same value in sale_orders field on click after save button .


how can i do this 


thanks in advance


if any question msg me on skype:- kg songra



Avatar
Discard
Best Answer

Hello Ra_one_1_11,

To get the value in many2many field after saving the record, you can update the value of sale_orders by overriding the create and write methods , as shown below.

Please find code in comment. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari 

Avatar
Discard

api.model
def create(self, vals):
your code..
order_per_users=self.env['sale.order'].search([('partner_id','=',vals.get('partner_id'))])
self.sale_orders = [(6, 0, orders_per_users.ids)]
your code..

def write(self, vals):
your code..
order_per_users=self.env['sale.order'].search([('partner_id','=',vals.get('partner_id'))])
self.sale_orders = [(6, 0, order_per_users.ids)]
your code..

Related Posts Replies Views Activity
1
Dec 23
1002
2
Aug 23
934
1
Dec 23
2076
1
Jul 23
1522
0
May 23
1285