[FIX] analytic: fixed onchange of template

bzr revid: qdp-launchpad@openerp.com-20121129162558-sotcsrchh8p772xs
This commit is contained in:
Quentin (OpenERP)
2012-11-29 17:25:58 +01:00
parent dc298cd336
commit 219edfa80d
2 changed files with 7 additions and 5 deletions
@@ -154,7 +154,7 @@
<field name="inherit_id" ref="analytic.view_account_analytic_account_form"/>
<field name="arch" type="xml">
<field name="template_id" position="attributes">
<attribute name="required">True</attribute>
<attribute name="attrs">{'required': [('type','=','contract')], 'invisible': [('type','in',['view', 'normal','template'])]}</attribute>
</field>
</field>
</record>
+6 -4
View File
@@ -201,12 +201,14 @@ class account_analytic_account(osv.osv):
return {}
res = {'value':{}}
template = self.browse(cr, uid, template_id, context=context)
from_dt = datetime.strptime(template.date_start, tools.DEFAULT_SERVER_DATE_FORMAT)
to_dt = datetime.strptime(template.date, tools.DEFAULT_SERVER_DATE_FORMAT)
timedelta = to_dt - from_dt
if template.date_start and template.date:
from_dt = datetime.strptime(template.date_start, tools.DEFAULT_SERVER_DATE_FORMAT)
to_dt = datetime.strptime(template.date, tools.DEFAULT_SERVER_DATE_FORMAT)
timedelta = to_dt - from_dt
res['value']['date'] = datetime.strftime(datetime.now() + timedelta, tools.DEFAULT_SERVER_DATE_FORMAT)
res['value']['date_start'] = fields.date.today()
res['value']['date'] = datetime.strftime(datetime.now() + timedelta, tools.DEFAULT_SERVER_DATE_FORMAT)
res['value']['quantity_max'] = template.quantity_max
res['value']['parent_id'] = template.parent_id and template.parent_id.id or False
res['value']['description'] = template.description
return res