Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

insertion line in hr.payslip.input

By
jihene
on 10/1/13, 12:01 PM 2,519 views

welcome every body, I need help in add some line to my database i have a problem in my function

def button_pointage(self, cr, uid, ids, context=None):

        for line in self.pool.get('hr.pointagedet').browse(cr, uid, ids):
            if( line['hsup75'] != 0):
                id = self.pool.get('hr.payslip.input.line').create(cr, uid, {
                    'amount': hsup75,
                    'code': 'HS75',
                    'name': 'Heures supp75',
                    'contract_id': line.contract_id.employee_id,
                    'payslip_id': line.payslip_id.employee_id})

            elif (line.hsup100 != 0.0):
                    id = self.pool.get('hr.payslip.input.line').create(cr, uid, {
                    'amount': hsup100,
                    'code': 'HS100',
                    'name': 'Heures supp100',
                    'contract_id': line.contract_id.employee_id,
                    'payslip_id': line.payslip_id.employee_id})

            elif (line.conge_paye != 0.0):
                    id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                    'number_of_days': conge_paye,
                    'number_of_hours': conge_paye,
                    'code': 'CONG',
                    'name': 'Conge paye',
                    'contract_id': line.contract_id.employee_id,
                    'payslip_id': line.payslip_id.employee_id})

            elif (line.nb_jours != 0.0):
                    id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                    'number_of_days': line.nb_jours,
                    'code': 'WORK100',
                    'name': 'work days',
                    'contract_id': line.contract_id.employee_id,
                    'payslip_id': line.payslip_id.employee_id})

            elif (line.nb_heures != 0.0):
                    id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                    'number_of_hours': nb_heures,
                    'code': 'WORK100',
                    'name': 'work hours',
                    'contract_id': line.contract_id.employee_id,
                    'payslip_id': line.payslip_id.employee_id})

            elif (line.nb_presence != 0.0):
                    id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                    'number_of_days': nb_jours,
                    'code': 'WORK100',
                    'name': 'work days',
                    'contract_id': line.contract_id.employee_id,
                    'payslip_id': line.payslip_id.employee_id})

        return 0

the bug : File "C:\Program Files\OpenERP 7\Server\server\openerp\addons\hr_payroll_tn_tn\hr_tn_payroll.py", line 67, in button_pointage File "C:\Program Files\OpenERP 7\Server\server.\openerp\osv\orm.py", line 492, in __iter__ NotImplementedError: Iteration is not allowed on browse_record(hr.pointagedet, 1)

line bug : File "C:\Program Files\OpenERP 7\Server\server\openerp\addons\hr_payroll_tn_tn\hr_tn_payroll.py", line 68, in button_pointage File "C:\Program Files\OpenERP 7\Server\server.\openerp\osv\orm.py", line 419, in __getitem__ KeyError: 'Field hsup75 not found in browse_record(hr.pointagedet, 1)'

jihene
on 10/1/13, 12:05 PM
0
jihene
On 10/2/13, 6:14 AM

Hi, this is my class hr.pointagedet

class hr_pointage(osv.osv): _name = 'hr.pointage' _description = "Pointage" def button_pointage(self, cr, uid, ids, context=None):

    for line in self.pool.get('hr.pointagedet').browse(cr, uid, ids):
        if( line['hsup75'] != 0):
            id = self.pool.get('hr.payslip.input.line').create(cr, uid, {
                'amount': hsup75,
                'code': 'HS75',
                'name': 'Heures supp75',
                'contract_id': line.contract_id.employee_id,
                'payslip_id': line.payslip_id.employee_id})

        elif (line.hsup100 != 0.0):
                id = self.pool.get('hr.payslip.input.line').create(cr, uid, {
                'amount': hsup100,
                'code': 'HS100',
                'name': 'Heures supp100',
                'contract_id': line.contract_id.employee_id,
                'payslip_id': line.payslip_id.employee_id})

        elif (line.conge_paye != 0.0):
                id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                'number_of_days': conge_paye,
                'number_of_hours': conge_paye,
                'code': 'CONG',
                'name': 'Conge paye',
                'contract_id': line.contract_id.employee_id,
                'payslip_id': line.payslip_id.employee_id})

        elif (line.nb_jours != 0.0):
                id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                'number_of_days': line.nb_jours,
                'code': 'WORK100',
                'name': 'work days',
                'contract_id': line.contract_id.employee_id,
                'payslip_id': line.payslip_id.employee_id})

        elif (line.nb_heures != 0.0):
                id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                'number_of_hours': nb_heures,
                'code': 'WORK100',
                'name': 'work hours',
                'contract_id': line.contract_id.employee_id,
                'payslip_id': line.payslip_id.employee_id})

        elif (line.nb_presence != 0.0):
                id = self.pool.get('hr_payslip_worked_days.line').create(cr, uid, {
                'number_of_days': nb_jours,
                'code': 'WORK100',
                'name': 'work days',
                'contract_id': line.contract_id.employee_id,
                'payslip_id': line.payslip_id.employee_id})

    return 0

_columns = {
    'annee':fields.integer('Annee'),
    'mois':fields.integer('Mois'),
    'det':fields.one2many('hr.pointagedet','ind', 'pointage'),

}
hr_pointage()
class hr_pointagedet(osv.osv):
    _name = 'hr.pointagedet'
    _description = "Pointagedet"
    _columns = {
        'employer':fields.many2one('hr.employee', 'Employer'),
        'ind':fields.integer('Ind'),
        'nb_jours':fields.float('Nombre jours'),
        'nb_heures':fields.float('Nombre Heures'),
        'nb_presence':fields.float('Nombre presence'),
        'hsup75':fields.float('Heures sup 75%'),
        'hsup100':fields.float('Heures sup 100%'),
        'hferier':fields.float('Heures Ferier'),
        'conge_paye':fields.float('Conge paye'),
    }
    _defaults = {
        'ind': 1,
    }
hr_pointagedet()

I modified my answer . now must it works!!

Borni DHIFI
on 10/2/13, 8:22 AM

no and the same error !!

jihene
on 10/2/13, 12:03 PM

I have create a new data base and i have another error: AttributeError: "Field 'contract_id' does not exist in object 'browse_record(hr.pointagedet, 1)'"

jihene
on 10/2/13, 12:29 PM

Jihene , It is very clear your model don't contain a field named contract_id, it contain a field employer .so replace line.contract_id.employee_id by line.employer . (not line.employer )

Borni DHIFI
on 10/2/13, 8:02 PM
0

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 10/2/13, 5:11 AM

Hi,

your code seems correct ,

Field hsup75 not found in browse_record(hr.pointagedet, 1) :

model hr.pointagedet does not contain a field hsup75 .so verify the model hr.pointagedet or post your code here.


-- 'amount': hsup75, 
++ 'amount': line.hsup75

-- 'amount': hsup100,
++ 'amount':  line.hsup75
.... replace all values  of amount

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 10/1/13, 12:01 PM
Seen: 2519 times
Last updated: 3/16/15, 8:10 AM