Merge lp:~vauxoo/addons-vauxoo/7.0-project_task_work-onchange_date_hours-jc into lp:addons-vauxoo/7.0

Proposed by Juan Carlos Hernandez
Status: Merged
Merged at revision: 1064
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-project_task_work-onchange_date_hours-jc
Merge into: lp:addons-vauxoo/7.0
Diff against target: 85 lines (+43/-2)
2 files modified
project_task_work/model/project_task_work.py (+18/-2)
project_task_work/view/project_view.xml (+25/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-project_task_work-onchange_date_hours-jc
Reviewer Review Type Date Requested Status
Sabrina Romero - http://www.vauxoo.com Approve
Julio Serna-http://www.vauxoo.com Approve
Juan Carlos Hernandez Needs Resubmitting
Moisés López - http://www.vauxoo.com Pending
Review via email: mp+224379@code.launchpad.net

Description of the change

se agregó validación para las horas de las tareas y para la fecha de la misma ,avisando con una advertencia, pero si pueden guardar los datos.

To post a comment you must log in.
Revision history for this message
Juan Carlos Hernandez (openerp1) wrote :

ademas se puso como requerido el campo project_id desde la vista

review: Needs Resubmitting
1061. By Juan Carlos Hernandez

[IMP][project_task_work]change message

Revision history for this message
Sabrina Romero - http://www.vauxoo.com (sabrina) wrote :

@Julio @Moi,

Me da alguno su Vo. Bo. sobre esta propuesta antes de mergear?, funcionalmente hace lo indicado.

Revision history for this message
Julio Serna-http://www.vauxoo.com (hearthebreaker) :
1062. By Juan Carlos Hernandez

[IMP][project_task_work]remove ¿ on message

Revision history for this message
Julio Serna-http://www.vauxoo.com (hearthebreaker) :
review: Approve
Revision history for this message
Sabrina Romero - http://www.vauxoo.com (sabrina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'project_task_work/model/project_task_work.py'
2--- project_task_work/model/project_task_work.py 2014-05-09 21:51:34 +0000
3+++ project_task_work/model/project_task_work.py 2014-06-25 23:19:58 +0000
4@@ -31,12 +31,12 @@
5 class project_task(osv.Model):
6 _inherit = 'project.task'
7
8+
9 def _get_issue(self, cr, uid, ids, fieldname, arg, context=None):
10 if context is None:
11 context = {}
12 res = {}
13 pi_obj = self.pool.get('project.issue')
14-
15 for id in ids:
16 pi_ids = pi_obj.search(cr, uid, [('task_id', '=', id)]) or []
17 res[id] = pi_ids and pi_ids[0] or None
18@@ -67,6 +67,22 @@
19
20 class project_task_work(osv.Model):
21 _inherit = 'project.task.work'
22+
23+ def onchange_hours(self, cr, uid, ids, hours=None, context=None):
24+ if context is None:
25+ context = {}
26+ warning = {}
27+ if hours < 0:
28+ warning = { 'title': _('Warning!'), 'message': _('Are you sure that you want to charge hours in negative?')}
29+ return { 'warning': warning}
30+
31+ def onchange_date(self, cr, uid, ids, date=None, context=None):
32+ if context is None:
33+ context = {}
34+ warning = {}
35+ if date > time.strftime('%Y-%m-%d %H:%M:%S'):
36+ warning = { 'title': _('Warning!'), 'message': _('Are you sure that you want to charge a future date?')}
37+ return { 'warning': warning}
38
39 def _get_project(self, cr, uid, ids, fieldname, arg, context=None):
40 if context is None:
41@@ -74,7 +90,7 @@
42 res = {}.fromkeys(ids,None)
43 ids = self.exists(cr, uid, ids, context=context)
44 for ptw_brw in self.browse(cr, uid, ids, context=context):
45-
46+
47 res[ptw_brw.id] = \
48 ptw_brw.task_id and \
49 (ptw_brw.task_id.issue_id and
50
51=== modified file 'project_task_work/view/project_view.xml'
52--- project_task_work/view/project_view.xml 2013-04-26 08:14:35 +0000
53+++ project_task_work/view/project_view.xml 2014-06-25 23:19:58 +0000
54@@ -1,6 +1,31 @@
55 <?xml version='1.0' encoding='UTF-8'?>
56 <openerp>
57 <data>
58+
59+ <record model="ir.ui.view" id="view_project_task_form2_inherit_0">
60+ <field name="name">view.project.task.form2.inherit0</field>
61+ <field name="model">project.task</field>
62+ <field name="inherit_id" ref="project.view_task_form2"/>
63+ <field name="arch" type="xml">
64+ <xpath expr="//field[@name='project_id']" position="replace">
65+ <field name="project_id" domain="[('state', '!=', 'close')]" on_change="onchange_project(project_id)" context="{'default_use_tasks':1}" required="1"/>
66+ </xpath>
67+ </field>
68+ </record>
69+
70+ <record model="ir.ui.view" id="view_project_task_form2_inherit_onchange">
71+ <field name="name">view.project.task.form2.inherit_onchange</field>
72+ <field name="model">project.task</field>
73+ <field name="inherit_id" ref="project.view_task_form2"/>
74+ <field name="arch" type="xml">
75+ <xpath expr="//notebook/page[@string='Description']/field[@name='work_ids']/tree[@string='Task Work']/field[@name='hours']" position="replace">
76+ <field name="hours" widget="float_time" sum="Spent Hours" on_change="onchange_hours(hours)"/>
77+ </xpath>
78+ <xpath expr="//notebook/page[@string='Description']/field[@name='work_ids']/tree[@string='Task Work']/field[@name='date']" position="replace">
79+ <field name="date" on_change="onchange_date(date)"/>
80+ </xpath>
81+ </field>
82+ </record>
83
84
85 <record id="view_project_task_work_ext_tree" model="ir.ui.view">