Skip to Content
Menu
This question has been flagged
2357 Views


Impacted versions: odoo v11

hi , when i tring to get data from other report i got this error .can anyone help me please.

File "c:\program files (x86)\odoo 11.0\server\odoo\addons\base\ir\ir_actions_report.py", line 667, in render_qweb_html
data = report_model.get_report_values(docids, data=data)
File "c:\program files (x86)\odoo 11.0\server\odoo\addons\l10n_dz\report\t5t6.py", line 110, in get_report_values
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
File "c:\program files (x86)\odoo 11.0\server\odoo\addons\l10n_dz\report\t5t6.py", line 21, in set_context
record_id = model.search(['ref_id', 'in', report_id], ['description', '=', 'Amortissements non déductible'])
KeyError: 'form'

this is my code wizard.py
`from odoo import fields, models, api

class account_t5t6(models.TransientModel):
_name = 'account.t5t6.report'
_description = 'Account T5T6 Report'

fiscalyear_id = fields.Many2one('date.range',
                                'Exercice fiscal',
                                required=True)

fiscalyear_n1_id = fields.Many2one('date.range',
                                   'Exercice fiscal N-1',
                                   required=True)

@api.multi
def print_t5t6_report(self):
    data = {
        'ids': self.ids,
        'model': 'account.t5t6.report',
        'form': self.read(['fiscalyear_id', 'fiscalyear_n1_id'])[0]
    }
    return self.env.ref('l10n_dz.t5t6_report_action').report_action(self, data=data)

`

report.py
`import logging
from odoo import api, fields, models

_logger = logging.getLogger(name)

class T5T6(models.AbstractModel):
_name = 'report.l10n_dz.t5t6'
_inherit = "report.l10n_dz.base_report"

@api.model
def set_context(self, objects, data, ids):
    super(T5T6, self).set_context(objects, data, ids)
    self._build_context('T5T6')
    fiscalyear_id = self.env['date.range'].browse(data['form']['fiscalyear_id'][0])
    data['form']["fiscalyear"] = fiscalyear_id
    report_id = self.env['account.t9.report'].search(['fiscalyear_id', '=', self.localcontext['data']['form']['fiscalyear_id']])
    _logger.warning("report_id === %s", report_id)
    model = self.env['reintegrations']
    record_id = model.search(['ref_id', 'in', report_id], ['description', '=', 'Amortissements non déductible'])
    self._set_variable(
        'AND', model.browse(record_id[0]).amount if len(record_id) else 0.0
    )
    self.update_values()



def _update_values(self):
    pass

def update_values(self):
    self._set_variable(
        't1',
        self.localcontext['n1']['t5t6g1'] +
        self.localcontext['n1']['t5t6ii1'] +
        self.localcontext['n1']['t5t6ic1'] +
        self.localcontext['n1']['t5t6p1'] +
        self.localcontext['n1']['t5t6aafc1']
    )

    self._set_variable('t2', self.localcontext['t5t6g1c'] - self.localcontext['n1']['t5t6g1c'] +
                       self.localcontext['t5t6ii1c'] - self.localcontext['n1']['t5t6ii1c'] +
                       self.localcontext['t5t6ic1c'] - self.localcontext['n1']['t5t6ic1c'] +
                       self.localcontext['t5t6p1c'] - self.localcontext['n1']['t5t6p1c'] +
                       self.localcontext['t5t6aafc1c'] - self.localcontext['n1']['t5t6aafc1c']
                       )



    self._set_variable('t4', self.localcontext['t5t6g1'] +
                       self.localcontext['t5t6ii1'] +
                       self.localcontext['t5t6ic1'] +
                       self.localcontext['t5t6p1'] +
                       self.localcontext['t5t6aafc1']
                       )

    self._set_variable('t5', self.localcontext['t5t6g1c'] +
                       self.localcontext['t5t6ii1c'] +
                       self.localcontext['t5t6ic1c'] +
                       self.localcontext['t5t6p1c'] +
                       self.localcontext['t5t6aafc1c']
                       )


    self._set_variable('t7',
                       self.localcontext['t5t6g2d'] +
                       self.localcontext['t5t6ii2d'] +
                       self.localcontext['t5t6ic2d'] +
                       self.localcontext['t5t6p2d'] +
                       self.localcontext['t5t6aafc2d']
                       )

    self._set_variable('t8',
                       self.localcontext['t5t6g1ddf'] +
                       self.localcontext['t5t6ii1ddf'] +
                       self.localcontext['t5t6ic1ddf'] +
                       self.localcontext['t5t6p1ddf'] +
                       self.localcontext['t5t6aafc1ddf']
                       )

    self._set_variable('t9',
                       self.localcontext['t7'] -
                       self.localcontext['t8']
                       )


@api.model
def get_report_values(self, docids, data=None):
    if not data:
        data = {'form': {}}
    elif not data['form']:
        data['form'] = {}
    self.model = 'account.t5t6.report'
    docs = self.env[self.model].browse(self.env.context.get('active_id'))
    fiscalyear_id = self.env['date.range'].browse(data['form']['fiscalyear_id'][0])
    data['form']["fiscalyear"] = fiscalyear_id
    self.localcontext = {
        'doc_ids': self.ids,
        'doc_model': self.model,
        'data': data['form'],
        'docs': docs,
        "formatLang": self._formatlang,
        'date_start': fiscalyear_id.date_start,
        'date_end': fiscalyear_id.date_end,
    }
    self.set_context(docs, data, docids)
    return self.localcontext


Avatar
Discard
Related Posts Replies Views Activity
2
Jul 22
7402
1
Jun 21
1057
2
Feb 21
299
5
Sep 20
12740
4
Jun 20
48215