This question has been flagged
1 Reply
1704 Views

I´m having trouble trying to create a record from a wizard, I suspect that the problem is with one specifig model that is created with a sequence, because when I use a different model it works just fine. The model´s code is the next one:

# -*- coding: utf-8 -*-

from odoo import models, fields, api, exceptions


class SoapTransaction(models.Model):
    _name = 'soap.transaction'

    state = fields.Selection([('draft', 'Borrador'),
                              ('requested', 'Solicitado'),
                              ('answered', 'Respondido'),
                              ('registered', 'Registrado')],
                             string='Estado',
                             required=True,
                             default='draft')
    sequence_id = fields.Char(readonly=True, string='Transacción')
    transaction_type = fields.Selection([('request', 'Solicitud'),
                                         ('response', 'Respuesta')],
                                        string='Tipo de transacción',
                                        required=True,
                                        default='request')
    method_id = fields.Many2one('soap.method', string='Método')
    service_id = fields.Many2one(string='Servicio', related='method_id.service_id')
    request_line_ids = fields.One2many('soap.transaction.line', 'transaction_id', string='Líneas de transacción')

    @api.model
    def create(self, vals):
        seq = self.env['ir.sequence'].next_by_code('transaction.sequence') or '/'
        vals['sequence_id'] = seq
        return super(SoapTransaction, self).create(vals)

The wizard that is suposted to create the record is as simple as the next code:

# -*- coding: utf-8 -*-

from odoo import models, fields, api, exceptions


class SoapTransactionWizard(models.TransientModel):
    _name = 'soap.transaction.wizard'

    method_id = fields.Many2one('soap.method', string='Operación')

def create_request(self):
    transaction_record = self.env['soap.transaction']
    transaction_record.create = ({
            'state': 'draft',
            'transaction_type': 'request',
            'method_id': self.method_id,
        })
I thank you all for your time
Avatar
Discard
Best Answer
for transaction_record insted of calling create method you are assingin it

transaction_record.create = ({  ==> transaction_record.create({


Avatar
Discard
Author

I think i´m tired for a mistake like that. Thank you so much!