تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3288 أدوات العرض

I have created a report which is working fine (Accounting, Journal entries). What i want now is to get some data from other model (res.partner), so i need to call python function from qweb report, as i understand i need to make a custom report like in example here - https://www.odoo.com/documentation/9.0/reference/reports.html#custom-reports

So i did it all like in an example, but after installing my module with custom class im getting an error:

 "'report.l10n_lt_buh_aps_forma.report_buh_aps_forma_' object has no attribute 'line_ids'" while evaluating

'o.line_ids'

As i understand after installing module with this custom class i cant access all object attributes. Here is my code:

from openerp import api, models, fields
def some_math(txt):
return txt * 5
def get_formato(self):
return 'its working'
class buh_aps_report(models.AbstractModel):
_name = 'report.l10n_lt_buh_aps_forma.report_buh_aps_forma_lt'
#_template = 'l10n_lt_buh_aps_forma.report_buh_aps_forma_lt'
# _inherit = 'account.move'
@api.multi
def render_html(self, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('l10n_lt_buh_aps_forma.report_buh_aps_forma_lt')
docargs = {
'doc_ids': self._ids,
'doc_model': report.model,
'docs': self,
'some_math': some_math,
'get_formato': get_formato,
}
return report_obj.render('l10n_lt_buh_aps_forma.report_buh_aps_forma_lt', docargs)


Here is my template code:

<report 
id="account.report_buh_aps"
model="account.move"
string="Buhalterinės apskaitos forma (EN text)"
report_type="qweb-pdf"
attachment_use="False"
name="l10n_lt_buh_aps_forma.report_buh_aps_forma_lt"
file="l10n_lt_buh_aps_forma.report_buh_aps_forma_lt"
/>


And i have to mention, that i have found some older way to for my problem, which is actually working:

class buh_aps_report(report_sxw.rml_parse):

  def __init__(self, cr, uid, name, context):
  super(buh_aps_report, self).__init__(cr, uid, name, context=context)
 self.localcontext.update({
  'time': time,
  'get_format':self.get_format,
                 })
 
  def get_format(self):
  return 'its working'
 
 class report_saleorderqweb(models.AbstractModel):
  _name = 'report.l10n_lt_buh_aps_forma.report_buh_aps_forma_lt'
  _inherit = 'report.abstract_report'
 _template = 'l10n_lt_buh_aps_forma.report_buh_aps_forma_lt'
  _wrapped_report_class = buh_aps_report

As i understand second method is based on old API, so i would like to understand what i did wrong in first method, what is missing?

Im completely new to python and odoo, so any help will be appreciated, thank you

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أبريل 23
2864
6
مايو 24
9733
0
يناير 17
2800
1
مارس 15
4718
0
مارس 15
2653