We're trying to create odoo function field, that renders as list.
We've following model:
class sale_wizard(orm.TransientModel):
_name = 'account.bank.statement.review.wizard'
def _orders(self, cr, uid, ids, fields, arg, context=None):
statement = self.env['account.bank.statement'].browse(self._context.get('active_id'))
partner_id = statement.partner_id.id
sale_orders = self.pool.get('sale.order').search(cr, uid, [
('partner_id', '=', partner_id),
])
print 'hiro'
print sale_orders
return [(1,2,3), (1,2,3)]
_columns = {
'order_ids': fields.function(_orders, string="Sale Orders", type="many2many"),
}
We've following view:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Wizard Form -->
<record model="ir.ui.view" id="orders_review_form">
<field name="name">Sale Orders Review</field>
<field name="model">account.bank.statement.review.wizard</field>
<field name="arch" type="xml">
<form string="Sale Orders Test">
<group col="2">
<field name="order_ids" />
</group>
</form>
</field>
</record>
</data>
</openerp>
When I'm opening form, that contains view - it renders as empty list. And lines
print 'hiro'
print sale_orders
don't execute. So function field order_ids
don't execute function orders
.
Where to dig?
UPD In other module - function field works as expected and executes on model initialization.