Merge lp:~vauxoo/addons-vauxoo/7.0-amount_residual_payslip-dev_luis into lp:addons-vauxoo/7.0

Proposed by Luis Torres - http://www.vauxoo.com
Status: Merged
Merged at revision: 1073
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-amount_residual_payslip-dev_luis
Merge into: lp:addons-vauxoo/7.0
Diff against target: 198 lines (+178/-0)
4 files modified
payroll_amount_residual/__init__.py (+26/-0)
payroll_amount_residual/__openerp__.py (+48/-0)
payroll_amount_residual/hr_payslip.py (+88/-0)
payroll_amount_residual/hr_payslip_view.xml (+16/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-amount_residual_payslip-dev_luis
Reviewer Review Type Date Requested Status
Julio Serna-http://www.vauxoo.com Pending
Review via email: mp+221974@code.launchpad.net

Description of the change

Se agrego el monto restante de pago a la nomina

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'payroll_amount_residual'
2=== added file 'payroll_amount_residual/__init__.py'
3--- payroll_amount_residual/__init__.py 1970-01-01 00:00:00 +0000
4+++ payroll_amount_residual/__init__.py 2014-06-04 00:15:28 +0000
5@@ -0,0 +1,26 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com
11+# All Rights Reserved.
12+# info@vauxoo.com
13+############################################################################
14+# Coded by: Luis Torres (luis_t@vauxoo.com)
15+############################################################################
16+#
17+# This program is free software: you can redistribute it and/or modify
18+# it under the terms of the GNU Affero General Public License as
19+# published by the Free Software Foundation, either version 3 of the
20+# License, or (at your option) any later version.
21+#
22+# This program is distributed in the hope that it will be useful,
23+# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+# GNU Affero General Public License for more details.
26+#
27+# You should have received a copy of the GNU Affero General Public License
28+# along with this program. If not, see <http://www.gnu.org/licenses/>.
29+#
30+##############################################################################
31+import hr_payslip
32
33=== added file 'payroll_amount_residual/__openerp__.py'
34--- payroll_amount_residual/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ payroll_amount_residual/__openerp__.py 2014-06-04 00:15:28 +0000
36@@ -0,0 +1,48 @@
37+# -*- encoding: utf-8 -*-
38+###########################################################################
39+# Module Writen to OpenERP, Open Source Management Solution
40+#
41+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com
42+# All Rights Reserved.
43+# info@vauxoo.com
44+############################################################################
45+# Coded by: Luis Torres (luis_t@vauxoo.com)
46+############################################################################
47+#
48+# This program is free software: you can redistribute it and/or modify
49+# it under the terms of the GNU Affero General Public License as
50+# published by the Free Software Foundation, either version 3 of the
51+# License, or (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU Affero General Public License for more details.
57+#
58+# You should have received a copy of the GNU Affero General Public License
59+# along with this program. If not, see <http://www.gnu.org/licenses/>.
60+#
61+##############################################################################
62+{
63+ "name" : "Amount Residual Payslip",
64+ "version" : "1.0",
65+ "author" : "Vauxoo",
66+ "category" : "Generic",
67+ "description" : """
68+
69+ This module adda field to save the amount residual in an payslip
70+
71+ """,
72+ "website" : "http://www.vauxoo.com/",
73+ "license" : "AGPL-3",
74+ "depends" : [
75+ "hr_payroll_account",
76+ ],
77+ "demo" : [],
78+ "data" : [
79+ "hr_payslip_view.xml"
80+ ],
81+ "test": [],
82+ "installable" : True,
83+ "active" : False,
84+}
85
86=== added file 'payroll_amount_residual/hr_payslip.py'
87--- payroll_amount_residual/hr_payslip.py 1970-01-01 00:00:00 +0000
88+++ payroll_amount_residual/hr_payslip.py 2014-06-04 00:15:28 +0000
89@@ -0,0 +1,88 @@
90+# -*- encoding: utf-8 -*-
91+###########################################################################
92+# Module Writen to OpenERP, Open Source Management Solution
93+#
94+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com
95+# All Rights Reserved.
96+# info@vauxoo.com
97+############################################################################
98+# Coded by: Luis Torres (luis_t@vauxoo.com)
99+############################################################################
100+#
101+# This program is free software: you can redistribute it and/or modify
102+# it under the terms of the GNU Affero General Public License as
103+# published by the Free Software Foundation, either version 3 of the
104+# License, or (at your option) any later version.
105+#
106+# This program is distributed in the hope that it will be useful,
107+# but WITHOUT ANY WARRANTY; without even the implied warranty of
108+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109+# GNU Affero General Public License for more details.
110+#
111+# You should have received a copy of the GNU Affero General Public License
112+# along with this program. If not, see <http://www.gnu.org/licenses/>.
113+#
114+##############################################################################
115+from openerp.osv import fields, osv
116+import openerp.addons.decimal_precision as dp
117+
118+class hr_payslip(osv.osv):
119+ _inherit = 'hr.payslip'
120+
121+ def _amount_residual(self, cr, uid, ids, name, args, context=None):
122+ """Function of the field residua. It computes the residual amount (balance) for each payslip"""
123+ if context is None:
124+ context = {}
125+ ctx = context.copy()
126+ result = {}
127+ currency_obj = self.pool.get('res.currency')
128+ for payslip in self.browse(cr, uid, ids, context=context):
129+ nb_inv_in_partial_rec = max_invoice_id = 0
130+ result[payslip.id] = 0.0
131+ if payslip.move_id:
132+ for aml in payslip.move_id.line_id:
133+ if aml.account_id.type in ('receivable','payable'):
134+ if aml.currency_id and aml.currency_id.id == payslip.currency_id.id:
135+ result[payslip.id] += aml.amount_residual_currency
136+ else:
137+ ctx['date'] = aml.date
138+ result[payslip.id] += currency_obj.compute(cr, uid, aml.company_id.currency_id.id, payslip.currency_id.id, aml.amount_residual, context=ctx)
139+ #prevent the residual amount on the invoice to be less than 0
140+ result[payslip.id] = max(result[payslip.id], 0.0)
141+ return result
142+
143+ def _get_payslip_from_line(self, cr, uid, ids, context=None):
144+ move = {}
145+ for line in self.pool.get('account.move.line').browse(cr, uid, ids, context=context):
146+ if line.reconcile_partial_id:
147+ for line2 in line.reconcile_partial_id.line_partial_ids:
148+ move[line2.move_id.id] = True
149+ if line.reconcile_id:
150+ for line2 in line.reconcile_id.line_id:
151+ move[line2.move_id.id] = True
152+ payslip_ids = []
153+ if move:
154+ payslip_ids = self.pool.get('hr.payslip').search(cr, uid, [('move_id', 'in', move.keys())], context=context)
155+ return payslip_ids
156+
157+ def _get_payslip_from_reconcile(self, cr, uid, ids, context=None):
158+ move = {}
159+ for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context):
160+ for line in r.line_partial_ids:
161+ move[line.move_id.id] = True
162+ for line in r.line_id:
163+ move[line.move_id.id] = True
164+
165+ payslip_ids = []
166+ if move:
167+ payslip_ids = self.pool.get('hr.payslip').search(cr, uid, [('move_id', 'in', move.keys())], context=context)
168+ return payslip_ids
169+
170+ _columns = {
171+ 'residual': fields.function(_amount_residual, digits_compute=dp.get_precision('Account'), string='Balance',
172+ store={
173+ 'hr.payslip': (lambda self, cr, uid, ids, c={}: ids, [], 50),
174+ 'account.move.line': (_get_payslip_from_line, None, 50),
175+ 'account.move.reconcile': (_get_payslip_from_reconcile, None, 50),
176+ },),
177+ }
178
179=== added file 'payroll_amount_residual/hr_payslip_view.xml'
180--- payroll_amount_residual/hr_payslip_view.xml 1970-01-01 00:00:00 +0000
181+++ payroll_amount_residual/hr_payslip_view.xml 2014-06-04 00:15:28 +0000
182@@ -0,0 +1,16 @@
183+<?xml version="1.0" encoding="utf-8"?>
184+<openerp>
185+ <data>
186+
187+ <record model="ir.ui.view" id="l10n_mx_hr_payslip_amount_residual_view">
188+ <field name="name">l10n.mx.hr.payslip.amount.residual.view</field>
189+ <field name="model">hr.payslip</field>
190+ <field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
191+ <field name="arch" type="xml">
192+ <xpath expr="//field[@name='credit_note']" position="after">
193+ <field name="residual"/>
194+ </xpath>
195+ </field>
196+ </record>
197+ </data>
198+</openerp>