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

class LabTest(models.Model):

    _name = 'lab.test'


    visitor = fileds.Many2one('res.partner)

    test = fields.Many2many('different.test')


class Request(models.Model):

    _name = request.model


    vistor = fileds.Many2one('res.partner)

    test = fields.Many2many('different.test')

    state = fields.Selection([('draft', 'Draft'), ('sent to labtest', 'Sent to Labtest')], default='draft')


    @api.multi

    def labtest_request(self):

self.state == 'draft':

            test = self.env['lab.test']

            test_data = {

                'visitor': self.patient.id,

                'test': (0, 0, [v.id for v in self.test])

            }

            test.create(test_data)

            self.state = 'sent to labtest'


When I Click the lab_test_request Button, I need to pass these values and create a record in LabTest model.

Thank You in advance,

Ramanathan Lakshmanan.

Avatar
Discard
Best Answer

hey..! 

try this

    @api.multi

    def labtest_request(self):

self.state == 'draft':

            test = self.env['lab.test']

            test_data = {

                'visitor': self.patient.id

               'test' :[[6, 0[v.id for v in self.test]]]

            }

            test.create(test_data)

            self.state = 'sent to labtest'


Avatar
Discard