0
Error: AttributeError: 'bool' object has no attribute 'split'

Error to render compiling AST
AttributeError: 'bool' object has no attribute 'split'
Template: 549
Path: /templates/t/t/div/table/tr/td[1]/t
Node: <t t-foreach="get_container_number(doc)" t-as="cotainer_no">
                <span style="text-transform:uppercase; font-family:'Times New Roman'; font-size:10px;" t-esc="cotainer_no"/><br data-oe-id="549" data-oe-model="ir.ui.view" data-oe-field="arch" data-oe-xpath="/t[1]/t[1]/div[1]/table[1]/tr[1]/td[1]/t[1]/br[1]"/>
            </t>

Code in python:

class bl_report(models.AbstractModel):
_name = 'report.export_document.bl_report'

@api.multi
def render_html(self,docids, data=None):
    report_obj = self.env['report']
    report = report_obj._get_report_from_name('export_document.bl_report')
    docargs = {
               'doc_ids': self.ids,
               'doc_model': report.model,
               'docs': self.env['document.export'].browse(data.get('doc_ids')),
               'data' : data,
               'get_container_number':self._get_container_number,
               'get_shipping_unit':self._get_shipping_unit,
               }

    print "=============docard",docargs
    return report_obj.render('export_document.bl_report', docargs)

def _get_container_number(self,doc):
    result1 = doc.no_of_container.split(',')
    return result1

def _get_shipping_unit(self,doc):
    result1 = doc.qty_packed.split(',')
    return result1
KbiR
  • 4,047
  • 6
  • 37
  • 103

1 Answers1

0

Just be sure you are not passing a bool field adding a validation:

def _get_container_number(self,doc):
    if doc.no_of_container:
        result1 = doc.no_of_container.split(',')
        return result1
    return False

def _get_shipping_unit(self,doc):
    if doc.qty_packed:
        result1 = doc.qty_packed.split(',')
        return result1
    return False

I hope this answer can be helpful for you.

Juan Salcedo
  • 1,598
  • 1
  • 16
  • 28
  • It didn't work . actually this module works completely on other single laptop when ever i copied this module on my system for template customization this will show error . i just changed the template from times new roman to Tahoma – muhammad zain Jul 12 '18 at 10:47