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.

28 lines
828 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Alex Comba - Agile Business Group
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import api, fields, models
  5. class PosOrder(models.Model):
  6. _inherit = 'pos.order'
  7. invoice_journal_id = fields.Many2one(
  8. related='session_id.config_id.invoice_journal_id',
  9. string='Invoice Journal',
  10. readonly=True,
  11. comodel_name='account.journal',
  12. store=True,
  13. )
  14. @api.multi
  15. def action_invoice(self):
  16. self.ensure_one()
  17. res = super(PosOrder, self).action_invoice()
  18. if 'res_id' in res and res['res_id']:
  19. invoice_id = res['res_id']
  20. self.env['account.invoice'].browse(invoice_id).write(
  21. {'journal_id': self.invoice_journal_id.id or None})
  22. return res