res = cr.fetchone()
return res and res[0] or False
+ def _default_category(self, cr, uid, context={}):
+ if 'categ_id' in context and context['categ_id']:
+ return context['categ_id']
+ return False
+
_defaults = {
'type': lambda *a: 'product',
'list_price': lambda *a: 1,
'uom_po_id': _get_uom_id,
'uos_coeff' : lambda *a: 1.0,
'mes_type' : lambda *a: 'fixed',
+ 'categ_id' : _default_category,
}
def _check_uom(self, cursor, user, ids):
def onchange_planned(self, cr, uid, ids, planned, effective):
return {'value':{'remaining_hours': planned-effective}}
+ def _default_project(self, cr, uid, context={}):
+ if 'project_id' in context and context['project_id']:
+ return context['project_id']
+ return False
+
#_sql_constraints = [
# ('remaining_hours', 'CHECK (remaining_hours>=0)', 'Please increase and review remaining hours ! It can not be smaller than 0.'),
#]
'sequence': lambda *a: 10,
'active': lambda *a: True,
'date_start': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'project_id': _default_project,
}
_order = "sequence, priority, date_deadline, id"
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('project_id', 'child_of', [active_id])]</field>
+ <field name="context">{'project_id':active_id}</field>
</record>
<record id="ir_project_task_open" model="ir.values">
<field eval=" 'tree_but_open'" name="key2"/>