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.

57 lines
1.8 KiB

  1. # Copyright (C) 2019-Today: GTRAP (<http://www.grap.coop/>)
  2. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, fields, models
  5. class PosMoveReason(models.Model):
  6. _name = 'pos.move.reason'
  7. _description = 'PoS - Move In / Out Reason'
  8. @api.model
  9. def _default_journal_ids(self):
  10. AccountJournal = self.env['account.journal']
  11. journals = AccountJournal.search([
  12. ('journal_user', '=', True),
  13. ('type', '=', 'cash')])
  14. return journals.ids
  15. @api.model
  16. def _default_company_id(self):
  17. return self.env.user.company_id
  18. name = fields.Char(string='Name', required=True)
  19. active = fields.Boolean(string='Active', default=True)
  20. journal_ids = fields.Many2many(
  21. comodel_name='account.journal', string='Accounting Journals',
  22. domain="[('journal_user', '=', True)]",
  23. default=_default_journal_ids)
  24. is_income_reason = fields.Boolean(
  25. string='Is Income Reason', default=True)
  26. is_expense_reason = fields.Boolean(
  27. string='Is Expense Reason', default=True)
  28. income_account_id = fields.Many2one(
  29. string='Income Account', comodel_name='account.account')
  30. expense_account_id = fields.Many2one(
  31. string='Expense Account', comodel_name='account.account')
  32. company_id = fields.Many2one(
  33. string='Company', comodel_name='res.company',
  34. default=_default_company_id, required=True)
  35. @api.onchange('is_income_reason')
  36. def _onchange_is_income_reason(self):
  37. if not self.is_income_reason:
  38. self.income_account_id = False
  39. @api.onchange('is_expense_reason')
  40. def _onchange_is_expense_reason(self):
  41. if not self.is_expense_reason:
  42. self.expense_account_id = False