Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. @api.multi
  2. def action_invoice_open(self):
  3. for inv in self:
  4. sequence_obj = self.env['ir.sequence'].sudo()
  5. if inv.type == "out_invoice" and inv.journal_id.ncf_control:
  6. if not inv.partner_id.sale_fiscal_type:
  7. raise ValidationError(_(
  8. u"El cliente [{}]{} no tiene Tipo de comprobante, y es requerido"
  9. "para este tipo de factura.".format(inv.partner_id.id,
  10. inv.partner_id.name)))
  11.  
  12. if inv.sale_fiscal_type in ("fiscal", "gov", "special") and not inv.partner_id.vat:
  13. raise UserError(_(
  14. u"El cliente [{}]{} no tiene RNC/Cédula, y es requerido"
  15. "para este tipo de factura.".format(inv.partner_id.id,
  16. inv.partner_id.name)))
  17.  
  18. if inv.sale_fiscal_type == 'final' and inv.partner_id.vat:
  19. if len(inv.partner_id.vat) == 9:
  20. raise UserError(_(
  21. u"No debe emitir una Factura de Consumo,"
  22. " a un cliente con RNC."))
  23.  
  24. if inv.amount_untaxed_signed >= 50000 and not inv.partner_id.vat:
  25. raise UserError(_(
  26. u"Si el monto es mayor a RD$50,000 el cliente debe "
  27. u"tener un RNC o Céd para emitir la factura"))
  28.  
  29. elif inv.type in ("in_invoice", "in_refund"):
  30. if inv.journal_id.purchase_type in ('normal', 'informal') and not inv.partner_id.vat:
  31. raise UserError(_(
  32. u"¡Para este tipo de Compra el Proveedor"
  33. u" debe de tener un RNC/Cédula establecido!"))
  34. self.purchase_ncf_validate()
  35.  
  36. if inv.type == "out_invoice":
  37. inv.internal_sequence = sequence_obj.next_by_code(
  38. 'client.invoice.number')
  39. if inv.type == "in_invoice":
  40. inv.internal_sequence = sequence_obj.next_by_code(
  41. 'supplier.invoice.number')
  42. #if inv.type == "in_refund":
  43. # inv.internal_sequence = sequence_obj.next_by_code(
  44. # 'debit.note.invoice.number')
  45. #if inv.type == "out_refund":
  46. # inv.internal_sequence = sequence_obj.next_by_code(
  47. # 'credit.note.invoice.number')
  48.  
  49. return super(AccountInvoice, self).action_invoice_open()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement