purchase_edi_log.py 1.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# -*- coding: utf-8 -*-
# Copyright (C) 2016-2021: Druidoo (<http://www.druidoo.io/>)
# Copyright (C) 2021-Today: Cooperatic (<http://cooperatic.fr/>)
# @author: Druidoo
# @author: Cooperatic
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html


from openerp import models, api, fields


class PurchaseEdiLog(models.Model):
    _name = 'purchase.edi.log'
    _inherit = 'ir.needaction_mixin'
    _order = 'log_date desc, id desc'

    log_date = fields.Datetime(string="Log Date", required=True)
    user_id = fields.Many2one(comodel_name="res.users", string="User")
    name = fields.Char(string="Interface", required=True)

    sent = fields.Boolean(string="Successfull ?")

    # View Section
    def _needaction_count(self, cr, uid, domain=None, context=None):
        return len(self.search(cr, uid, [('sent', '=', False)], context=context))

    @api.model
    def create_log_history(self, supplier_interface, edi_system=None, sent=False):
        return self.create({'user_id': self.env.user.id,
                            'log_date': fields.datetime.now(),
                            'name': supplier_interface,
                            # 'edi_system_id': edi_system,
                            'sent': sent})