models.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class AccountInvoice(models.Model):
  4. _inherit = 'account.invoice'
  5. @api.model
  6. def getAccountInvoiceTicket(self,domain):
  7. AccountInvoice = self.env['account.invoice'].search(domain)
  8. values = []
  9. for invoice in AccountInvoice:
  10. values.append({
  11. 'id': invoice.id,
  12. 'number': invoice.number,
  13. 'date_invoice': invoice.date_invoice,
  14. 'user_id':{
  15. 'id': invoice.user_id.id,
  16. 'name': invoice.user_id.name,
  17. },
  18. 'partner_id':{
  19. 'id': invoice.partner_id.id,
  20. 'name': invoice.partner_id.name,
  21. },
  22. 'currency_id':{
  23. 'id': invoice.currency_id.id,
  24. 'name': invoice.currency_id.name,
  25. 'rate': invoice.currency_id.rate_silent,
  26. },
  27. 'company_id':{
  28. 'id': invoice.company_id.id,
  29. 'name': invoice.company_id.name,
  30. 'rml_header1': invoice.company_id.rml_header1,
  31. },
  32. 'amount_untaxed': invoice.amount_untaxed,
  33. 'amount_tax': invoice.amount_tax,
  34. 'amount_total': invoice.amount_total,
  35. })
  36. return values
  37. class AccountInvoiceLine(models.Model):
  38. _inherit = 'account.invoice.line'
  39. @api.model
  40. def getAccountInvoiceLineTicket(self,domain):
  41. AccountInvoiceLine = self.env['account.invoice.line'].search(domain)
  42. values = []
  43. for line in AccountInvoiceLine:
  44. values.append({
  45. # ID
  46. 'id': line.id,
  47. 'invoice_id': {
  48. 'id': line.invoice_id.id,
  49. 'name': line.invoice_id.name,
  50. },
  51. 'product_id':{
  52. 'id': line.product_id.id,
  53. 'name': line.product_id.display_name,
  54. },
  55. 'price_unit': line.price_unit,
  56. 'price_subtotal': line.price_subtotal,
  57. 'quantity': line.quantity,
  58. })
  59. return values
  60. class ResCurrency(models.Model):
  61. _inherit = 'res.currency'
  62. @api.model
  63. def getResCurrencyTicket(self,domain):
  64. ResCurrency = self.env['res.currency'].search(domain)
  65. values = []
  66. for currency in ResCurrency:
  67. values.append({
  68. 'id': currency.id,
  69. 'name': currency.name,
  70. 'symbol': currency.symbol,
  71. 'rate_silent': currency.rate_silent,
  72. 'base': currency.base,
  73. 'decimal_separator': currency.decimal_separator,
  74. 'decimal_places': currency.decimal_places,
  75. 'thousands_separator': currency.thousands_separator,
  76. 'symbol_position': currency.symbol_position,
  77. 'local_name': currency.local_name,
  78. })
  79. return values