Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Update the automatically generated payslip name

Subscriure's

Get notified when there's activity on this post

This question has been flagged
serverpaysliponchangepayrollodoo13
1 Respondre
5119 Vistes
Avatar
Wale

Hello, I have been stuck trying to update the payslip name generated when the employee is changed;

This is my code:

    def onchange_employee_id(self, date_from, date_to, employee_id=False, contract_id=False):


        # defaults

        res = {

            'value': {

                'line_ids': [],

                # delete old input lines

                'input_line_ids': [(2, x,) for x in self.input_line_ids.ids],

                # delete old worked days lines

                'worked_days_line_ids': [(2, x,) for x in self.worked_days_line_ids.ids],

                # 'details_by_salary_head':[], TODO put me back

                'name': '',

                'contract_id': False,

                'struct_id': False,

            }

        }

        if (not employee_id) or (not date_from) or (not date_to):

            return res

        ttyme = datetime.combine(fields.Date.from_string(date_from), time.max)

        employee = self.env['hr.employee'].browse(employee_id)

        locale = self.env.context.get('lang') or 'en_US'

        res['value'].update({

            'name': _('Pay Slip of %s for %s') % (

            employee.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=locale))),

            'company_id': employee.company_id.id,

        })


        if not self.env.context.get('contract'):

            # fill with the first contract of the employee

            contract_ids = self.get_contract(employee, date_from, date_to)

        else:

            if contract_id:

                # set the list of contract for which the input have to be filled

                contract_ids = [contract_id]

            else:

                # if we don't give the contract, then the input to fill should be for all current contracts of the employee

                contract_ids = self.get_contract(employee, date_from, date_to)


        if not contract_ids:

            return res

        contract = self.env['hr.contract'].browse(contract_ids[0])

        res['value'].update({

            'contract_id': contract.id

        })

        struct = contract.struct_id

        if not struct:

            return res

        res['value'].update({

            'struct_id': struct.id,

        })

        # computation of the salary input

        contracts = self.env['hr.contract'].browse(contract_ids)

        worked_days_line_ids = self.get_worked_day_lines(contracts, date_from, date_to)

        input_line_ids = self.get_inputs(contracts, date_from, date_to)

        res['value'].update({

            'worked_days_line_ids': worked_days_line_ids,

            'input_line_ids': input_line_ids,

        })

        return res

>> I changed the original payslip name and the time function but still, nothing changes

0
Avatar
Descartar
Wale
Autor

Hello Sudir, thanks for the response. Any edit on the code doesn't seem to change anything on the payslip so I am beginning to think the file I am editing is the wrong file.

This is the location of the file I am editing - /odoo/custom/addons/hr_payroll_community/models/hr_payslip.py

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

 Try the following code:

#OCA (if you are using OCA payroll module)

@api.onchange("employee_id", "date_from", "date_to")
def onchange_employee(self):
super(YourClassName, self)._onchange_employee()
if (not self.employee_id) or (not self.date_from) or (not self.date_to):
return
self.name = _('Pay Slip of %s for %s') % (employee.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=locale)))

#Enterprise (if you are using enterprise module)

@api.onchange('employee_id', 'struct_id', 'contract_id', 'date_from', 'date_to')
def _onchange_employee(self):
super(YourClassName, self)._onchange_employee()
if (not self.employee_id) or (not self.date_from) or (not self.date_to):
return
self.name = _('Pay Slip of %s for %s') % (employee.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=locale)))


4
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Calculate total Business days within a given date range on payslip - CE V13
payslip salary_rules WORK100 payrollodoo13
Avatar
Avatar
2
de jul. 20
6391
V10 Passing One2Many values into Transient Model One2Many (TypeError from onchange & DataError from default)
one2many payslip onchange passing transientmodel
Avatar
0
d’abr. 20
5835
HostNoc as My Go-To Server Provider – Sharing My Experience
server
Avatar
0
de juny 25
2
How can I get the number of days of the period in Payslip
payslip
Avatar
0
de des. 23
1893
trying to auto correct a wrong users value
onchange
Avatar
Avatar
1
d’oct. 23
2988
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now