models.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class ResPartner(models.Model):
  4. _inherit = 'res.partner'
  5. @api.model
  6. def getResPartnerMedic(self,domain):
  7. ResPartner = self.env['res.partner'].search(domain)
  8. values = []
  9. for partner in ResPartner:
  10. values.append({
  11. 'id': partner.id,
  12. 'name': partner.name,
  13. 'ruc': partner.ruc,
  14. 'street': partner.street,
  15. 'city': partner.city,
  16. 'state_id': {
  17. 'id':partner.state_id.id,
  18. 'name':partner.state_id.name,
  19. 'complete_name':partner.state_id.complete_name,
  20. },
  21. 'phone': partner.phone,
  22. 'mobile': partner.mobile,
  23. 'email': partner.email,
  24. 'property_product_pricelist': partner.property_product_pricelist.name,
  25. 'property_product_pricelist_purchase': partner.property_product_pricelist_purchase.name,
  26. 'credit': partner.credit,
  27. 'debit': partner.debit,
  28. 'supplier': partner.supplier,
  29. 'is_medic': partner.is_medic,
  30. 'medic': [
  31. partner.medic.id,
  32. partner.medic.name,
  33. ],
  34. })
  35. return values
  36. class AccountInvoice(models.Model):
  37. _inherit = 'account.invoice'
  38. @api.model
  39. def getAccountInvoiceOdontoimagen(self,domain):
  40. AccountInvoice = self.env['account.invoice'].search(domain)
  41. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  42. values = []
  43. for invoice in AccountInvoice:
  44. values.append({
  45. 'id': invoice.id,
  46. 'number': invoice.number,
  47. 'date_invoice': invoice.date_invoice,
  48. 'journal_id':{
  49. 'id': invoice.journal_id.id,
  50. 'name': invoice.journal_id.name,
  51. },
  52. 'partner_id':{
  53. 'id':invoice.partner_id.id,
  54. 'name':invoice.partner_id.name,
  55. 'ruc':invoice.partner_id.ruc,
  56. },
  57. 'amount_currency': round(invoice.amount_total * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),decimal_precision),
  58. })
  59. return values
  60. @api.model
  61. def getPosOrderOdontoimagen(self,domain):
  62. PosOrder = self.env['pos.order'].search(domain)
  63. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  64. values = []
  65. for order in PosOrder:
  66. values.append({
  67. 'id': order.id,
  68. 'number': order.name,
  69. 'date_order': order.date_order,
  70. 'sale_journal':{
  71. 'id': order.sale_journal.id,
  72. 'name': order.sale_journal.name,
  73. },
  74. 'partner_id':{
  75. 'id': order.partner_id.id,
  76. 'name': order.partner_id.name,
  77. 'ruc': order.partner_id.ruc,
  78. },
  79. 'amount_currency': round(order.amount_total * (order.company_id.currency_id.rate / order.pricelist_id.currency_id.rate),decimal_precision),
  80. })
  81. return values
  82. class ResCountryState(models.Model):
  83. _inherit = 'res.country.state'
  84. @api.model
  85. def getResCountryState(self,domain):
  86. ResCountryState = self.env['res.country.state'].search(domain)
  87. values = []
  88. for state in ResCountryState:
  89. values.append({
  90. 'id': state.id,
  91. 'name': state.name,
  92. 'complete_name':state.complete_name,
  93. 'parent_id':{
  94. 'id': state.parent_id.id,
  95. 'name': state.parent_id.name,
  96. },
  97. })
  98. return values