changes
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
payslip_ids = fields.One2many(
|
||||
comodel_name='hr.payslip',
|
||||
inverse_name='move_id',
|
||||
string='Payslips',
|
||||
readonly=True,
|
||||
copy=False,
|
||||
)
|
||||
payslip_count = fields.Integer(
|
||||
string='# of Payslips',
|
||||
compute='_compute_payslip_count',
|
||||
compute_sudo=True,
|
||||
)
|
||||
|
||||
def _compute_payslip_count(self):
|
||||
for move in self:
|
||||
move.payslip_count = len(move.payslip_ids)
|
||||
|
||||
def action_open_payslip(self):
|
||||
self.ensure_one()
|
||||
action = {
|
||||
'name': _('Payslips'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'hr.payslip',
|
||||
}
|
||||
if self.payslip_count == 1:
|
||||
action.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': self.payslip_ids.id,
|
||||
})
|
||||
else:
|
||||
action.update({
|
||||
'view_mode': 'list,form',
|
||||
'domain': [('id', 'in', self.payslip_ids.ids)],
|
||||
})
|
||||
return action
|
||||
Reference in New Issue
Block a user