from odoo import models, fields, api

class ResCompany(models.Model):
    _inherit = 'res.company'

    last_invoice_number = fields.Char(string="Last Invoice Number", compute="_compute_last_invoice_number")

    @api.depends()
    def _compute_last_invoice_number(self):
        for company in self:
            last_invoice = self.env['account.move'].search(
                [('move_type', '=', 'out_invoice'), ('state', '=', 'posted')],
                order="id desc", limit=1
            )
            company.last_invoice_number = last_invoice.name if last_invoice else False

    def _load_pos_data_fields(self, config_id):
        fields = super()._load_pos_data_fields(config_id)
        fields += ['last_invoice_number']
        print("fields",fields)
        return fields