How can I return two variables in Odoo?

3364 views python
4

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 = 'tax.detail.report'

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

@api.multi
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')
                                                             ])
        else:
            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('account.tax', string="Tax Type")
    state_id = fields.Many2one('res.country.state', 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('res.company', 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

5

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

1.

def function_name():
  a=1
  b=2
  return a,b

2.

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

posted this

Have an answer?

JD

Please login first before posting an answer.