I have a custom report , with a print button(red) , however when i click the print button i get this error :
File "/opt/odoo/community/addons/camden-market/cm_sales_receipt/cm_sales_receipt.py", line 89, in print_receipt assert len(self) == 1, 'This option should only be used for a single id at a time.' File "/opt/odoo/odoo/openerp/models.py", line 5332, in __len__ return len(self._ids) AttributeError: 'cm.sales.receipt' object has no attribute '_ids'
Also i have another normal print button which when i click print my report but it is just an empty file.
My class :
class cm_sales_receipt(osv.osv):
_name = "cm.sales.receipt"
_description = "Camden Market Sales Receipt"
_auto = False
_columns = {
'paymentref':fields.char('PaymentRef'),
'date':fields.date('Date'),
'receipt_number':fields.char('Receipt Number'),
'customer':fields.char('Customer',size=128),
'unit':fields.char('Unit',size=128),
'company':fields.char('Name',size=128,required=True),
'invoicing_company':fields.char('Invoicing Company', size=128,required=True),
'street':fields.char('Street',size=128,required=True),
'street2':fields.char('Street2',size=128,required=True),
'zip':fields.char('Zip',size=10,required=True),
'state':fields.char('State',size=128,required=True),
'city':fields.char('City',size=128,required=True),
'email':fields.char('Email',size=128),
'fax':fields.integer('Fax'),
'phone':fields.integer('State'),
'paid_amount':fields.float('Paid_Amount'),
}
Here below is the code used to print the report (note function is indented so part of above class :
def print_receipt(self, cr, uid, ids, context=None):
"""
This function prints the Property Rental Sales receipt
"""
assert len(self) == 1, 'This option should only be used for a single id at a time.'
#self.sent = True
return self.pool['report'].get_action(cr, uid, ids, 'cm_sales_receipt.report_salesreceipt', context=context)
extract from view which has print button (note: print button displays correctly in module:
<!-- Property Rental Sales Receipt Form View -->
<record model="ir.ui.view" id="view_cm_sales_receipt_form">
<field name="name">cm.sales.receipt.form</field>
<field name="model">cm.sales.receipt</field>
<field name="arch" type="xml">
<form string=" Sales Receipt" version="8.0">
<header>
<button name="print_receipt" string="Print Receipt" type="object" class="oe_highlight" groups="base.group_user"/>
</header>
<sheet>
<group>
<group>
<field name="invoicing_company"/>
<field name="customer"/>
<field name="paymentref"/>
<field name="receipt_number"/>
<field name="company"/>
<field name="paid_amount"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
here is the report xml file :
<openerp>
<data>
<report
string="Sales Rental Receipt"
id="action_cm_report_sales_receipt"
model="cm.sales.receipt"
report_type="qweb-pdf"
name="cm_sales_receipt.report_cm_salesreceipt"
file="cm_sales_receipt.report_cm_salesreceipt"
attachment_use="True"
attachment="(object.state in ('open','paid')) and ('RCPT'+(object.number or '').replace('/','')+'.pdf')"
/>
</data>
</openerp
- module installs correctly
- ((custom)print button displays correctly but once clicked i recieve an error
- when i click the normal print button once clicked it prints an empty report.
1) it seems the _ids cannot be found in this case , is there an indication of where in the code is '_ids' is not being passed through .