Hereda la validación de cuentas bancarias al crear la factura y pone la cuenta a False en vez de elevar un error.
En la base de datos de la ddt da un error creando una fatura de compra, asigna partner_bank_id a la cuenta de la compañia en vez de la cuenta del proveedor.
This commit is contained in:
parent
9bd253a931
commit
a1cfaeba74
3 changed files with 43 additions and 18 deletions
24
stock_picking_deposito/models/account_invoice.py
Normal file
24
stock_picking_deposito/models/account_invoice.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Copyright (C) 2021: Criptomart (<https://criptomart.net/>)
|
||||
# @author: Criptomart (<tech@criptomart.net>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError, Warning
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
@api.constrains('partner_id', 'partner_bank_id')
|
||||
def validate_partner_bank_id(self):
|
||||
for record in self:
|
||||
if record.partner_bank_id:
|
||||
if record.type in ('in_invoice', 'out_refund') and record.partner_bank_id.partner_id != record.partner_id.commercial_partner_id:
|
||||
_logger.warning(_("Commercial partner and vendor account owners must be identical."))
|
||||
record.partner_bank_id = False
|
||||
elif record.type in ('out_invoice', 'in_refund') and not record.company_id in record.partner_bank_id.partner_id.ref_company_ids:
|
||||
raise ValidationError(_("The account selected for payment does not belong to the same company as this invoice."))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue