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

from odoo import fields, models, api
import logging
logger = logging.getLogger(__name__)


class AgedTrialBalanceBillwise(models.TransientModel):
    _inherit = 'account.aged.trial.balance'
    _description = 'Account Aged Trial balance Report Bill-wise'

    report_type = fields.Selection([('bill', 'Bill-wise'), ('customer', 'Customer-wise')], default='customer',
                                   string="Report Type")

    salesperson = fields.Many2one('res.users', string= 'Salesperson')

    def _print_report(self, data):
        data['form']['report_type'] = self.report_type
        data['form']['salesperson'] = self.salesperson.id if self.salesperson else False
        logger.info("-----------salesperson---salesperson---------%s" % data['form']['salesperson'])
        data['form']['salesperson_name'] = self.salesperson.name if self.salesperson else False
        logger.info("-----------salesperson_name---salesperson_name---------%s" % data['form']['salesperson_name'])
        return super(AgedTrialBalanceBillwise, self)._print_report(data)




class SalespersonInvoice(models.Model):
    _inherit = 'account.move.line'



    payment_rel = fields.Many2one('res.users', related='invoice_id.user_id', string='Sales Individual',store=True)
    #
    account_pmt_rel = fields.Many2one('res.users', related='payment_id.user_id', string='Sales Single',store=True)

    # account_pmt_rel = fields.Many2one('')




    # @api.multi
    # def check_report(self):
    #     res = super(AgedTrialBalanceBillwise, self).check_report()
    #     data
    #     sale_p_id = self._context.get("active_ids")
    #     sale_p_obj = self.env['res.users']
#
class Account_Payment(models.Model):
    _inherit = 'account.payment'

    user_id = fields.Many2one('res.users', string= 'Salesperson')


class AgedRegisterBalanceWizard(models.TransientModel):
    _inherit = 'account.register.payments'

    user_id = fields.Many2one('res.users', string= 'Salesperson')

# class HRExpenceRegisterWizard(models.TransientModel):
#     _inherit = 'hr.expense.register.payment.wizard'
#
#     user_id = fields.Many2one('res.users', string= 'Salesperson')







