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

Goodnight,

I am creating a new record, but when checking the table I see that 2 consecutive records are always created, what could be wrong?

the code that generates the error.

class WizardInvoiceLineReport(models.TransientModel):

    _name = 'wizard.comprobantes.detalle.formato'

    fecha_inicio = fields.Date("Fecha de Inicio")

    fecha_fin = fields.Date("Fecha Fin")

    report_object_ids =fields.One2many('report_comprobantes_efact.wizard.comprobantes.detalle','report_id')

    @api.one

    def imprimir(self):

        self.ensure_one()

        self._sql_get_line(self.fecha_inicio,self.fecha_fin)

        return self.env.ref('report_comprobantes_efact.linea_report_formato_pdf').report_action(self)

    @api.one

    def _sql_get_line(self,fecha_inicio,fecha_fin): 

        self.ensure_one()  

        linea_obj = self.env['wizard.comprobantes.detalle.formato']

        linea_obj.create({

                'fecha_inicio': fecha_inicio,

                'fecha_fin': fecha_fin,

                })

        return True


class WizardInvoiceDetalleReport(models.TransientModel):

    _name = 'report_comprobantes_efact.wizard.comprobantes.detalle'

    report_id=fields.Many2one('wizard.comprobantes.detalle.formato')

    number=fields.Char("Numero")

    product_id=fields.Integer("Id Producto")

    price_total=fields.Float("Precio Total Linea")

Avatar
Discard
Best Answer

Hi,

If you are saying records are getting duplicated, then it will due to execution of the function two times.Add a print statement inside the function _sql_get_line and see how much it get executed. If it is getting executed multiple times, check from where it get invoked.


Thanks

Avatar
Discard