Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @api.multi
- def action_invoice_open(self):
- for inv in self:
- sequence_obj = self.env['ir.sequence'].sudo()
- if inv.type == "out_invoice" and inv.journal_id.ncf_control:
- if not inv.partner_id.sale_fiscal_type:
- raise ValidationError(_(
- u"El cliente [{}]{} no tiene Tipo de comprobante, y es requerido"
- "para este tipo de factura.".format(inv.partner_id.id,
- inv.partner_id.name)))
- if inv.sale_fiscal_type in ("fiscal", "gov", "special") and not inv.partner_id.vat:
- raise UserError(_(
- u"El cliente [{}]{} no tiene RNC/Cédula, y es requerido"
- "para este tipo de factura.".format(inv.partner_id.id,
- inv.partner_id.name)))
- if inv.sale_fiscal_type == 'final' and inv.partner_id.vat:
- if len(inv.partner_id.vat) == 9:
- raise UserError(_(
- u"No debe emitir una Factura de Consumo,"
- " a un cliente con RNC."))
- if inv.amount_untaxed_signed >= 50000 and not inv.partner_id.vat:
- raise UserError(_(
- u"Si el monto es mayor a RD$50,000 el cliente debe "
- u"tener un RNC o Céd para emitir la factura"))
- elif inv.type in ("in_invoice", "in_refund"):
- if inv.journal_id.purchase_type in ('normal', 'informal') and not inv.partner_id.vat:
- raise UserError(_(
- u"¡Para este tipo de Compra el Proveedor"
- u" debe de tener un RNC/Cédula establecido!"))
- self.purchase_ncf_validate()
- if inv.type == "out_invoice":
- inv.internal_sequence = sequence_obj.next_by_code(
- 'client.invoice.number')
- if inv.type == "in_invoice":
- inv.internal_sequence = sequence_obj.next_by_code(
- 'supplier.invoice.number')
- #if inv.type == "in_refund":
- # inv.internal_sequence = sequence_obj.next_by_code(
- # 'debit.note.invoice.number')
- #if inv.type == "out_refund":
- # inv.internal_sequence = sequence_obj.next_by_code(
- # 'credit.note.invoice.number')
- return super(AccountInvoice, self).action_invoice_open()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement