No, Odoo 17 Community does not support combining payslips into a single journal entry out of the box.
You must customize the hr_payroll_community module to override the accounting logic in payslip batches.
1. Custom Module Structure
- Make sure you have a custom module (e.g., hr_payroll_batch_entry), and add this in models/hr_payslip_run.py
from odoo import models, api
from collections import defaultdict
class HrPayslipRun(models.Model):
_inherit = 'hr.payslip.run'
@api.model
def _create_batch_account_move(self, payslips):
if not payslips:
return
journal = payslips[0].journal_id
move_lines_dict = defaultdict(lambda: {'debit': 0.0, 'credit': 0.0, 'name': '', 'account_id': False})
for slip in payslips:
slip_lines = slip._prepare_payslip_lines()
for line in slip_lines:
key = line['account_id']
if key:
move_line = move_lines_dict[key]
move_line['debit'] += line['debit']
move_line['credit'] += line['credit']
move_line['name'] = line['name']
move_line['account_id'] = key
line_vals = [(0, 0, vals) for vals in move_lines_dict.values()]
move = self.env['account.move'].create({
'ref': self.name,
'journal_id': journal.id,
'line_ids': line_vals,
'date': self.date_end or fields.Date.today(),
})
move.post()
for slip in payslips:
slip.write({'move_id': move.id, 'state': 'done'})
return move
def action_validate(self):
for batch in self:
payslips = batch.slip_ids.filtered(lambda p: p.state == 'draft')
payslips.compute_sheet()
# Instead of creating per payslip move, call the new combined method
self._create_batch_account_move(payslips)
return super(HrPayslipRun, self).action_validate()
Add _prepare_payslip_lines() to Slip (If Not Exists)
If it's not already defined in hr.payslip, add this helper to extract move lines from payslips:
class HrPayslip(models.Model):
_inherit = 'hr.payslip'
def _prepare_payslip_lines(self):
lines = []
for line in self.line_ids:
if not line.salary_rule_id.account_debit or not line.salary_rule_id.account_credit:
continue
if line.total > 0:
lines.append({
'name': line.name,
'account_id': line.salary_rule_id.account_credit.id,
'debit': -line.total,
'credit': 0.0,
})
return lines
Notes:
-
Make sure your salary rules have correct debit/credit accounts.
-
This will replace individual entries with a single journal entry for the entire batch.
-
You may enhance it to log the link between payslips and the batch move if needed.
Thanks & Regards,
Email :- contact@datainteger.com