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>
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
答案 0 :(得分:0)
只需确保您没有通过添加验证的布尔字段:
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
我希望这个答案对您有帮助。