Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # Generar lineas de IVA no grabado a Comprobantes de Compras
  2. subcompania_id = 1
  3. facturas = self.env['account.invoice'].search([('subcompania_id', '=', subcompania_id), ('state', 'not in', ['draft', 'cancel']), ('tax_line', '=', False), ('amount_tax', '=', 0), ('type','in', ['in_invoice', 'in_refund'])])
  4. iva = self.env['account.tax'].search([('tipo', '=', 'iva'), ('type_tax_use', '=', 'purchase'), ('type', '=', 'none')])
  5. if len(iva) > 1:
  6.     raise Warning("Se encontro mas de un iva no grabado")
  7. for fc in facturas:
  8.     self.env['account.invoice.tax'].create({
  9.         'account_id': iva.account_collected_id.id,
  10.         'invoice_id': fc.id,
  11.         'tax_code_id': iva.tax_code_id.id,
  12.         'base': fc.amount_untaxed,
  13.         'base_amount': fc.amount_untaxed * fc.cotizacion,
  14.         'tax_amount': 0,
  15.         'amount': 0,
  16.         'name': iva.name,
  17.         'impuesto_id': iva.id,
  18.     })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement