Merge lp:~gs.clearcorp/openerp-ccorp-addons/hr_contract_extended into lp:openerp-ccorp-addons/7.0

Proposed by Glen Sojo
Status: Merged
Merged at revision: 759
Proposed branch: lp:~gs.clearcorp/openerp-ccorp-addons/hr_contract_extended
Merge into: lp:openerp-ccorp-addons/7.0
Diff against target: 164 lines (+86/-3)
3 files modified
hr_contract_extended/hr_contract_extended.py (+36/-1)
hr_contract_extended/hr_contract_extended_view.xml (+12/-0)
hr_contract_extended/i18n/es_CR.po (+38/-2)
To merge this branch: bzr merge lp:~gs.clearcorp/openerp-ccorp-addons/hr_contract_extended
Reviewer Review Type Date Requested Status
ClearCorp drivers Pending
Review via email: mp+185574@code.launchpad.net

Description of the change

[ADD] Calculations of time worked in years, months and days

To post a comment you must log in.
760. By Glen Sojo

[ADD] New es_CR translation

761. By Glen Sojo

[Fix] Changed view. Switched normal text for label tags.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr_contract_extended/hr_contract_extended.py'
--- hr_contract_extended/hr_contract_extended.py 2013-08-27 17:42:04 +0000
+++ hr_contract_extended/hr_contract_extended.py 2013-09-13 19:58:54 +0000
@@ -19,7 +19,10 @@
19# along with this program. If not, see <http://www.gnu.org/licenses/>.19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#20#
21##############################################################################21##############################################################################
22from osv import fields, osv22from openerp.osv import fields, osv
23from dateutil.relativedelta import relativedelta
24from datetime import datetime
25
2326
24class HrContractAcademicAchievement(osv.osv):27class HrContractAcademicAchievement(osv.osv):
25 _name = 'hr.contract.academic.achievement'28 _name = 'hr.contract.academic.achievement'
@@ -64,11 +67,43 @@
64 return res67 return res
6568
66class HrContract(osv.osv):69class HrContract(osv.osv):
70
71 def _days_between(self, start_date, end_date):
72 start_date = datetime.strptime(start_date, "%Y-%m-%d")
73 end_date = datetime.strptime(end_date, "%Y-%m-%d")
74 return relativedelta(end_date, start_date).days
75
76 def _months_between(self, start_date, end_date):
77 start_date = datetime.strptime(start_date, "%Y-%m-%d")
78 end_date = datetime.strptime(end_date, "%Y-%m-%d")
79 return relativedelta(end_date, start_date).months
80
81 def _years_between(self, start_date, end_date):
82 start_date = datetime.strptime(start_date, "%Y-%m-%d")
83 end_date = datetime.strptime(end_date, "%Y-%m-%d")
84 return relativedelta(end_date, start_date).years
85
86
87 def _compute_duration(self, cr, uid, ids, field_name, arg, context={}):
88 res = {}
89 contracts = self.browse(cr, uid, ids, context=context)
90 for contract in contracts:
91
92 res[contract.id] = {
93 'duration_years': self._years_between(contract.date_start, contract.date_end),
94 'duration_months': self._months_between(contract.date_start, contract.date_end),
95 'duration_days': self._days_between(contract.date_start, contract.date_end),
96 }
97 return res
98
67 _inherit = 'hr.contract'99 _inherit = 'hr.contract'
68 100
69 _columns = {101 _columns = {
70 'hr_salary_rule_ids':fields.one2many('hr.salary.rule', 'contract_id', 'Salary Rules'),102 'hr_salary_rule_ids':fields.one2many('hr.salary.rule', 'contract_id', 'Salary Rules'),
71 'academic_achievement':fields.one2many('hr.contract.academic.achievement', 'contract_academic_achievement', 'Academic Achievements'),103 'academic_achievement':fields.one2many('hr.contract.academic.achievement', 'contract_academic_achievement', 'Academic Achievements'),
104 'duration_years': fields.function(_compute_duration, type="integer", string="Years", multi="sums"),
105 'duration_months': fields.function(_compute_duration, type="integer", string="Months", multi="sums"),
106 'duration_days': fields.function(_compute_duration, type="integer", string="Days", multi="sums"),
72 }107 }
73 108
74 def unlink(self, cr, uid, ids, context=None):109 def unlink(self, cr, uid, ids, context=None):
75110
=== modified file 'hr_contract_extended/hr_contract_extended_view.xml'
--- hr_contract_extended/hr_contract_extended_view.xml 2013-08-27 17:42:04 +0000
+++ hr_contract_extended/hr_contract_extended_view.xml 2013-09-13 19:58:54 +0000
@@ -5,9 +5,21 @@
5 <record id="hr_contract_salary_rule_form" model="ir.ui.view">5 <record id="hr_contract_salary_rule_form" model="ir.ui.view">
6 <field name="name">hr.contract.salary.rule.form</field>6 <field name="name">hr.contract.salary.rule.form</field>
7 <field name="model">hr.contract</field>7 <field name="model">hr.contract</field>
8 <field name="priority" eval="16"/>
8 <field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>9 <field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
9 <field name="arch" type="xml">10 <field name="arch" type="xml">
10 <data>11 <data>
12 <xpath expr="//field[@name='working_hours']" position="before">
13 <label for="duration_years" string="Time Worked"/>
14 <div>
15 <field name="duration_years" class="oe_inline" nolabel="1"/>
16 <label string="year(s) - "/>
17 <field name="duration_months" class="oe_inline" nolabel="1"/>
18 <label string="month(s) - "/>
19 <field name="duration_days" class="oe_inline" nolabel="1"/>
20 <label string="day(s)"/>
21 </div>
22 </xpath>
11 <xpath expr="//page[@string='Information']" position="after">23 <xpath expr="//page[@string='Information']" position="after">
12 <page string="Salary Rules">24 <page string="Salary Rules">
13 <field name="hr_salary_rule_ids"/>25 <field name="hr_salary_rule_ids"/>
1426
=== modified file 'hr_contract_extended/i18n/es_CR.po'
--- hr_contract_extended/i18n/es_CR.po 2013-08-27 17:38:35 +0000
+++ hr_contract_extended/i18n/es_CR.po 2013-09-13 19:58:54 +0000
@@ -6,8 +6,8 @@
6msgstr ""6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-08-27 17:31+0000\n"9"POT-Creation-Date: 2013-09-13 19:54+0000\n"
10"PO-Revision-Date: 2013-08-27 17:31+0000\n"10"PO-Revision-Date: 2013-09-13 19:54+0000\n"
11"Last-Translator: <>\n"11"Last-Translator: <>\n"
12"Language-Team: \n"12"Language-Team: \n"
13"MIME-Version: 1.0\n"13"MIME-Version: 1.0\n"
@@ -16,16 +16,36 @@
16"Plural-Forms: \n"16"Plural-Forms: \n"
1717
18#. module: hr_contract_extended18#. module: hr_contract_extended
19#: view:hr.contract:0
20msgid "day(s)"
21msgstr "día(s)"
22
23#. module: hr_contract_extended
19#: model:ir.model,name:hr_contract_extended.model_hr_contract_academic_achievement24#: model:ir.model,name:hr_contract_extended.model_hr_contract_academic_achievement
20msgid "Hr Contract Academic Achievement"25msgid "Hr Contract Academic Achievement"
21msgstr "Hr Contrat Logros Académicos"26msgstr "Hr Contrat Logros Académicos"
2227
23#. module: hr_contract_extended28#. module: hr_contract_extended
29#: view:hr.contract:0
30msgid "Time Worked"
31msgstr "Tiempo Laborado"
32
33#. module: hr_contract_extended
24#: field:hr.contract.academic.achievement,degree_obtained:034#: field:hr.contract.academic.achievement,degree_obtained:0
25msgid "Degree Obtained"35msgid "Degree Obtained"
26msgstr "Título Obtenido"36msgstr "Título Obtenido"
2737
28#. module: hr_contract_extended38#. module: hr_contract_extended
39#: field:hr.contract,duration_months:0
40msgid "Months"
41msgstr "Meses"
42
43#. module: hr_contract_extended
44#: field:hr.contract,duration_days:0
45msgid "Days"
46msgstr "Días"
47
48#. module: hr_contract_extended
29#: field:hr.salary.rule,contract_id:049#: field:hr.salary.rule,contract_id:0
30#: model:ir.model,name:hr_contract_extended.model_hr_contract50#: model:ir.model,name:hr_contract_extended.model_hr_contract
31msgid "Contract"51msgid "Contract"
@@ -53,6 +73,11 @@
53msgstr "Logros Académicos"73msgstr "Logros Académicos"
5474
55#. module: hr_contract_extended75#. module: hr_contract_extended
76#: view:hr.contract:0
77msgid "year(s) - "
78msgstr "año(s) - "
79
80#. module: hr_contract_extended
56#: field:hr.contract.academic.achievement,date_obtained:081#: field:hr.contract.academic.achievement,date_obtained:0
57msgid "Date Obtained"82msgid "Date Obtained"
58msgstr "Fecha de Obtención"83msgstr "Fecha de Obtención"
@@ -67,3 +92,14 @@
67#: field:hr.contract.academic.achievement,institution:092#: field:hr.contract.academic.achievement,institution:0
68msgid "Institution"93msgid "Institution"
69msgstr "Institución"94msgstr "Institución"
95
96#. module: hr_contract_extended
97#: view:hr.contract:0
98msgid "month(s) - "
99msgstr "mes(es) - "
100
101#. module: hr_contract_extended
102#: field:hr.contract,duration_years:0
103msgid "Years"
104msgstr "Años"
105

Subscribers

People subscribed via source and target branches