You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.4 KiB

  1. # Copyright 2019 Tecnativa - Vicent Cubells
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import fields, models, api
  4. class AccountBankStatementImportPaypalMap(models.Model):
  5. _name = 'account.bank.statement.import.paypal.map'
  6. name = fields.Char(
  7. required=True,
  8. )
  9. map_line_ids = fields.One2many(
  10. comodel_name='account.bank.statement.import.paypal.map.line',
  11. inverse_name='map_parent_id',
  12. string="Map lines",
  13. required=True,
  14. copy=True,
  15. )
  16. float_thousands_sep = fields.Selection(
  17. [('dot', 'dot (.)'),
  18. ('comma', 'comma (,)'),
  19. ('none', 'none'),
  20. ],
  21. string='Thousands separator',
  22. # forward compatibility: this was the value assumed
  23. # before the field was added.
  24. default='dot',
  25. required=True
  26. )
  27. float_decimal_sep = fields.Selection(
  28. [('dot', 'dot (.)'),
  29. ('comma', 'comma (,)'),
  30. ('none', 'none'),
  31. ],
  32. string='Decimals separator',
  33. # forward compatibility: this was the value assumed
  34. # before the field was added.
  35. default='comma',
  36. required=True
  37. )
  38. @api.onchange('float_thousands_sep')
  39. def onchange_thousands_separator(self):
  40. if 'dot' == self.float_thousands_sep == self.float_decimal_sep:
  41. self.float_decimal_sep = 'comma'
  42. elif 'comma' == self.float_thousands_sep == self.float_decimal_sep:
  43. self.float_decimal_sep = 'dot'
  44. @api.onchange('float_decimal_sep')
  45. def onchange_decimal_separator(self):
  46. if 'dot' == self.float_thousands_sep == self.float_decimal_sep:
  47. self.float_thousands_sep = 'comma'
  48. elif 'comma' == self.float_thousands_sep == self.float_decimal_sep:
  49. self.float_thousands_sep = 'dot'
  50. def _get_separators(self):
  51. separators = {'dot': '.',
  52. 'comma': ',',
  53. 'none': '',
  54. }
  55. return (separators[self.float_thousands_sep],
  56. separators[self.float_decimal_sep])
  57. class AccountBankStatementImportPaypalMapLIne(models.Model):
  58. _name = 'account.bank.statement.import.paypal.map.line'
  59. _order = "sequence asc, id asc"
  60. sequence = fields.Integer(
  61. string="Field number",
  62. required=True,
  63. )
  64. name = fields.Char(
  65. string="Header Name",
  66. required=True,
  67. )
  68. map_parent_id = fields.Many2one(
  69. comodel_name='account.bank.statement.import.paypal.map',
  70. required=True,
  71. ondelete='cascade',
  72. )
  73. field_to_assign = fields.Selection(
  74. selection=[
  75. ('date', 'Date'),
  76. ('time', 'Time'),
  77. ('description', 'Description'),
  78. ('currency', 'Currency'),
  79. ('amount', 'Gross'),
  80. ('commission', 'Fee'),
  81. ('balance', 'Balance'),
  82. ('transaction_id', 'Transaction ID'),
  83. ('email', 'From Email Address'),
  84. ('partner_name', 'Name'),
  85. ('bank_name', 'Bank Name'),
  86. ('bank_account', 'Bank Account'),
  87. ('invoice_number', 'Invoice ID'),
  88. ('origin_transaction_id', 'Origin Transaction ID'),
  89. ],
  90. string="Statement Field to Assign",
  91. )
  92. date_format = fields.Selection(
  93. selection=[
  94. ('%d/%m/%Y', 'i.e. 15/12/2019'),
  95. ('%m/%d/%Y', 'i.e. 12/15/2019'),
  96. ],
  97. string="Date Format",
  98. )