Added auto category assigned at create from category tree view

bzr revid: fabian@tinyerp.com-20081028162302-i5z6cc06zhf08x3z
This commit is contained in:
Fabian Semal 2008-10-28 17:23:02 +01:00
parent 6851a15eca
commit b7a4dffa63
3 changed files with 13 additions and 0 deletions

View File

@ -283,6 +283,11 @@ class product_template(osv.osv):
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,
@ -298,6 +303,7 @@ class product_template(osv.osv):
'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):

View File

@ -273,6 +273,11 @@ class task(osv.osv):
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.'),
#]
@ -313,6 +318,7 @@ class task(osv.osv):
'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"

View File

@ -439,6 +439,7 @@
<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"/>