# -*- coding: utf-8 -*-

from odoo import models, fields, api


class ResPartner(models.Model):
    _inherit = 'res.partner'

    # Relación inversa con monedero
    monedero_ids = fields.One2many('skeen.monedero', 'partner_id', string='Monederos')
    wallet_points = fields.Integer(string='Puntos Monedero', compute='_compute_wallet_points', store=True)

    @api.depends('monedero_ids.points')
    def _compute_wallet_points(self):
        for partner in self:
            monedero = partner.monedero_ids[:1]
            partner.wallet_points = monedero.points if monedero else 0
