<commit_before># -*- coding: utf-8 -*-
# © <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import _, api, fields, models
from openerp.exceptions import ValidationError


class AccountInvoice(models.Model):
    _inherit = 'account.invoice'

    @api.multi
    def invoice_validate(self):
        for invoice in self:
            if invoice.account_analytic_id.warehouse_id:
                warehouse = invoice.account_analytic_id.warehouse_id
                employee = self.env['hr.employee'].search(
                    [('user_id', '=', self._uid)])
                if warehouse not in employee.warehouse_ids:
                    raise ValidationError(_("You do not have privileges to validate \
                                          in this warehouse."))
        return super(AccountInvoice, self).invoice_validate()<commit_msg>[FIX] add validation for line = 0 and requiered reference vendor<commit_after># -*- coding: utf-8 -*-
# © <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import _, api, fields, models
from openerp.exceptions import ValidationError


class AccountInvoice(models.Model):
    _inherit = 'account.invoice'

    @api.multi
    def invoice_validate(self):
        for invoice in self:
            if invoice.account_analytic_id.warehouse_id:
                warehouse = invoice.account_analytic_id.warehouse_id
                employee = self.env['hr.employee'].search(
                    [('user_id', '=', self._uid)])
                if warehouse not in employee.warehouse_ids:
                    raise ValidationError(_("You do not have privileges to validate \
                                          in this warehouse."))
            for line in invoice.invoice_line_ids:
                    if line.quantity == 0:
                        raise ValidationError(_('Al menos una de las lineas de la \
                                                Factura tiene Cantidad cero!'
                                                '\n Por favor asegurese \
                                                que todas las lineas tengan capturada la Cantidad.'))
            if invoice.type == 'in_invoice' and not invoice.reference:
                raise ValidationError(_("Usted no puede validar esta Factura sin \
                                          el número de Referencia del Proveedor."))
        return super(AccountInvoice, self).invoice_validate()
{'fraction_non_alphanumeric': 0.09305111821086262, 'fraction_numerical': 0.003194888178913738, 'mean_word_length': 1.8020134228187918, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1057', 'n_tokens_mistral': 668, 'n_tokens_neox': 615, 'n_words': 178}