How can I return two variables in Odoo?

3364 views python

I need check two conditions and get the details print on the report. But the problem is I can't able to return the two variables. I'll submit the code and mention more below.

class TaxDetailReport(models.TransientModel): _name = ''

start_date = fields.Datetime(required=True)
end_date = fields.Datetime(required=True)
vat_oman_id = fields.Many2one('vat.oman.import', string="VAT Oman ID")

def generate_report(self):
    for file in self:
        if file.start_date and file.end_date:
            record_ids = self.env['vat.oman.import'].search([('date', '>=', self.start_date),
                                                             ('date', '<=', self.end_date),
                                                             ('account_tax_id.type_tax_use', '=', 'sale')
            purchase_ids = self.env['vat.oman.import'].search([('date', '>=', self.start_date),
                                                             ('date', '<=', self.end_date),
                                                             ('account_tax_id.type_tax_use', '=', 'purchase')
            raise UserError("Record does not exist")

        result['file'] = {'print': [(record_ids,purchase_ids)]}
    return self.env["report"].get_action(result, 'kg_oman_vat.report_tax_details')

I need to return those product_ids and record_ids . generate_report is the button which is in the wizard.

class VATOmanImport(models.Model):
    _name = 'vat.oman.import'
    _rec_name = 'partner_id'
    _description = 'Oman VAT Import'

    partner_id = fields.Many2one('res.partner', string="Name", required=True)
    invoice_desc = fields.Char(string="Description", help="Invoice Description")
    date = fields.Date(string="Date")
    account_tax_id = fields.Many2one('', string="Tax Type")
    state_id = fields.Many2one('', string="State", required=True,
                               domain="[('country_id', '=','Oman')]")
    invoice_amount = fields.Float(string="Invoice Amount", required=True)
    tax_amount = fields.Float(string="Total Tax", compute='_compute_tax_amount')
    company_id = fields.Many2one('', string='Company', index=True,
                                 default=lambda self: self.env.user.company_id)

Just mentioned above is the main class, and need to get the details from here.

Is there is any solutions ? Hope somebody will help.

answered question

1 Answer


I could not understand your question very well, but if you want return 2 parameters in one function you have 2 choice.


def function_name():
  return a,b


def function_name():
      return {a':a,'b':b}

posted this

Have an answer?


Please login first before posting an answer.