Khushboo Bhatt(openerp) has proposed merging 
lp:~openerp-dev/openerp-india/payroll-india-trunk-payment-advice-kbh into 
lp:~openerp-dev/openerp-india/payroll-india-trunk.

Requested reviews:
  OpenERP R&D Team (openerp-dev)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-india/payroll-india-trunk-payment-advice-kbh/+merge/108561

Hello,

===l10n_in_hr_payroll===

  Added objects and view of payment advice and advice lines.

Thank you,
KBH.
  

   
-- 
https://code.launchpad.net/~openerp-dev/openerp-india/payroll-india-trunk-payment-advice-kbh/+merge/108561
Your team OpenERP R&D Team is requested to review the proposed merge of 
lp:~openerp-dev/openerp-india/payroll-india-trunk-payment-advice-kbh into 
lp:~openerp-dev/openerp-india/payroll-india-trunk.
=== modified file 'l10n_in_hr_payroll/l10n_in_hr_payroll.py'
--- l10n_in_hr_payroll/l10n_in_hr_payroll.py	2012-05-24 11:24:12 +0000
+++ l10n_in_hr_payroll/l10n_in_hr_payroll.py	2012-06-04 13:06:20 +0000
@@ -20,13 +20,29 @@
 ##############################################################################
 
 import time
+from datetime import date
 from datetime import datetime
+from datetime import timedelta
+from dateutil.relativedelta import relativedelta
+
+from tools.translate import _
 from calendar import isleap
-from dateutil.relativedelta import relativedelta
 
 from osv import fields, osv
 import decimal_precision as dp
 
+def prev_bounds(cdate=False):
+    when = date.fromtimestamp(time.mktime(time.strptime(cdate,"%Y-%m-%d")))
+    this_first = date(when.year, when.month, 1)
+    month = when.month + 1
+    year = when.year
+    if month > 12:
+        month = 1
+        year += 1
+    next_month = date(year, month, 1)
+    prev_end = next_month - timedelta(days=1)
+    return this_first, prev_end
+
 class hr_contract_in(osv.osv):
     _inherit = 'hr.contract'
     _description = 'contract'
@@ -90,4 +106,101 @@
                 }
 hr_employee()
 
+class payroll_advice(osv.osv):
+    '''
+    Bank Advice Note
+    '''
+
+    _name = 'hr.payroll.advice'
+    _description = 'Bank Advice Note'
+    _columns = {
+        'name':fields.char('Name', size=2048, required=True, readonly=False),
+        'note': fields.text('Description'),
+        'date': fields.date('Date'),
+        'state':fields.selection([
+            ('draft','Draft Sheet'),
+            ('confirm','Confirm Sheet'),
+            ('cancel','Reject'),
+        ],'State', select=True, readonly=True),
+        'number':fields.char('Number', size=64, required=False, readonly=True),
+        'line_ids':fields.one2many('hr.payroll.advice.line', 'advice_id', 'Employee Salary', required=False),
+        'chaque_nos':fields.char('Chaque Nos', size=256, required=False, readonly=False),
+        'company_id':fields.many2one('res.company', 'Company', required=False),
+        'bank_id':fields.many2one('res.bank', 'Bank', required=False, help="Select the Bank Address from whcih the salary is going to be paid"),
+    }
+    _defaults = {
+        'date': lambda *a: time.strftime('%Y-%m-%d'),
+        'state': lambda *a: 'draft',
+        'company_id': lambda self, cr, uid, context: \
+                self.pool.get('res.users').browse(cr, uid, uid,
+                    context=context).company_id.id,
+    }
+
+    def compute_advice(self, cr, uid, ids, context=None):
+        payslip_pool = self.pool.get('hr.payslip')
+        advice_line_pool = self.pool.get('hr.payroll.advice.line')
+        sequence_pool = self.pool.get('ir.sequence')
+        payslip_line_pool = self.pool.get('hr.payslip.line')
+
+        for advice in self.browse(cr, uid, ids, context=context):
+            dates = prev_bounds(advice.date)
+            slip_ids = payslip_pool.search(cr, uid, [ ('date_from','<=',advice.date),('date_to','>=',advice.date),('date_from','=',dates[0]),('date_to','=',dates[1])], context=context)
+            if not slip_ids:
+                    raise osv.except_osv(_('Error !'), _('You can get only current month payslips') % (slip_ids))
+        for slip in payslip_pool.browse(cr, uid, slip_ids, context=context):
+            line_ids = payslip_line_pool.search(cr, uid, [ ('slip_id','in',slip_ids),('code','=',"NET")], context=context)
+            for line in slip.line_ids:
+                if not slip.employee_id.bank_account_id:
+                    raise osv.except_osv(_('Error !'), _('Please define bank account for the %s employee') % (slip.employee_id.name))
+                advice_line= {
+                        'advice_id':advice.id,
+                        'name':slip.employee_id.bank_account_id.acc_number,
+                        'employee_id':slip.employee_id.id,
+                        'bysal':line.total
+                        }
+            id = advice_line_pool.create(cr, uid, advice_line, context=context)
+        number = self.pool.get('ir.sequence').get(cr, uid, 'advice.line')
+        self.write(cr, uid, ids, {'state':'confirm','number':number}, context=context)
+
+    def confirm_sheet(self, cr, uid, ids, context=None):
+        self.write(cr, uid, ids, {'state':'confirm'}, context=context)
+        return True
+
+    def set_to_draft(self, cr, uid, ids, context=None):
+        self.write(cr, uid, ids, {'state':'draft'}, context=context)
+        return True
+
+    def cancel_sheet(self, cr, uid, ids, context=None):
+        self.write(cr, uid, ids, {'state':'cancel'}, context=context)
+        return True
+
+    def onchange_company_id(self, cr, uid, ids, company_id=False, context=None):
+        res = {}
+        if company_id:
+            company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
+            if company.partner_id.bank_ids:
+                res.update({'bank': company.partner_id.bank_ids[0].bank.name})
+        return {
+            'value':res
+        }
+
+payroll_advice()
+
+class payroll_advice_line(osv.osv):
+    '''
+    Bank Advice Lines
+    '''
+
+    _name = 'hr.payroll.advice.line'
+    _description = 'Bank Advice Lines'
+    _columns = {
+        'advice_id':fields.many2one('hr.payroll.advice', 'Bank Advice', required=False),
+        'name':fields.char('Bank Account A/C', size=64, required=True, readonly=False),
+        'employee_id':fields.many2one('hr.employee', 'Employee', required=True),
+        'amount': fields.float('Amount', digits_compute=dp.get_precision('Payroll')),
+        'bysal': fields.float('By Salary', digits_compute=dp.get_precision('Payroll')),
+    }
+
+payroll_advice_line()
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== modified file 'l10n_in_hr_payroll/l10n_in_hr_payroll_data.xml'
--- l10n_in_hr_payroll/l10n_in_hr_payroll_data.xml	2012-05-28 08:54:08 +0000
+++ l10n_in_hr_payroll/l10n_in_hr_payroll_data.xml	2012-06-04 13:06:20 +0000
@@ -134,7 +134,7 @@
             <field name="condition_select">none</field>
             <field name="amount_select">code</field>
              <field name="amount_python_compute">result = (contract.wage + DA) * 15 * employee.number_of_year / worked_days.WORK100.number_of_days</field>
-            <field name="sequence" eval="500"/>
+            <field name="sequence" eval="57"/>
             <field name="note">Covered under the Payment of Gratuity Act, 1971: 
 (Last drawn monthly basic salary + dearness allowance)/26 x 15 days x 
 number of years of service (date of joining – date of retirement/leaving job)</field>

=== modified file 'l10n_in_hr_payroll/l10n_in_hr_payroll_view.xml'
--- l10n_in_hr_payroll/l10n_in_hr_payroll_view.xml	2012-05-24 11:24:12 +0000
+++ l10n_in_hr_payroll/l10n_in_hr_payroll_view.xml	2012-06-04 13:06:20 +0000
@@ -48,5 +48,75 @@
             </data>
             </field>
         </record>
+
+        <record id="view_hr_bank_advice_tree" model="ir.ui.view">
+            <field name="name">hr.payroll.advice.tree</field>
+            <field name="model">hr.payroll.advice</field>
+            <field name="type">tree</field>
+            <field name="arch" type="xml">
+                <tree string="Bank Advice">
+                    <field name="number" select="1"/>
+                    <field name="name" select="1"/>
+                    <field name="date" select="1"/>
+                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
+                </tree>
+            </field>
+        </record>
+        <record id="view_hr_bank_advice_form" model="ir.ui.view">
+            <field name="name">hr.payroll.advice.form</field>
+            <field name="model">hr.payroll.advice</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Bank Advice">
+                    <group col="6" colspan="4">
+                        <field name="name" colspan="4" select="1"/>
+                        <field name="number" invisible="1" select="1"/>
+                        <field name="bank_id"/>
+                        <field name="date" select="1"/>
+                    </group>
+                    <notebook colspan="4">
+                        <page string="Paymeny Lines">
+                            <field name="line_ids" colspan="4" nolabel="1">
+                                <tree string="Payment Lines" editable="bottom">
+                                    <field name="employee_id" on_change="onchange_employee_id(parent.date, employee_id)"/>
+                                    <field name="name"/>
+                                    <field name="amount"/>
+                                    <field name="bysal"/>
+                                </tree>
+                            </field>
+                        </page>
+                        <page string="Letter Content">
+                            <group colspan="4" col="6">
+                              <field name="company_id" on_change="onchange_company_id(company_id)" groups="base.group_multi_company" widget="selection"/>
+                              <field name="chaque_nos"/>
+                            </group>
+                            <separator colspan="4" string="Letter Details"/>
+                            <field name="note" colspan="4" nolabel="1"/>
+                        </page>
+                    </notebook>
+                    <group col="6" colspan="6">
+                        <field name="state"/>
+                        <button name="compute_advice" string="Compute Advice"  states="draft" type="object"/>
+                        <button name="cancel_sheet" string="Cancel Sheet" states="draft" icon="gtk-cancel"  type="object"/>
+                        <button name="confirm_sheet"  icon="gtk-apply" string="Confirm Sheet" states="draft" type="object"/>
+                        <button name="set_to_draft" string="Set to Draft"  icon="gtk-convert"  states="cancel,confirm" type="object"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <record id="action_view_hr_bank_advice_tree" model="ir.actions.act_window">
+            <field name="name">Payment Advice</field>
+            <field name="res_model">hr.payroll.advice</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="view_id" ref="view_hr_bank_advice_tree"/>
+        </record>
+        <menuitem
+            action="action_view_hr_bank_advice_tree"
+            id="hr_menu_payment_advice"
+            parent="hr_payroll.menu_hr_root_payroll"
+        />
+
     </data>
 </openerp>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to