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.

30 lines
931 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 Tecnativa - David Vidal
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import models
  5. class PosOrder(models.Model):
  6. _inherit = 'pos.order'
  7. def _prepare_invoice(self):
  8. res = super(PosOrder, self)._prepare_invoice()
  9. res.update({
  10. 'picking_ids': [(6, 0, self.picking_id.ids)],
  11. })
  12. return res
  13. def _action_create_invoice_line(self, line=False, invoice_id=False):
  14. invoice_line = super(
  15. PosOrder, self)._action_create_invoice_line(line, invoice_id)
  16. if not line:
  17. return invoice_line
  18. move = self.env['stock.move'].search([
  19. ('picking_id', '=', self.picking_id.id),
  20. ('name', '=', line.name)])
  21. if move:
  22. invoice_line.write({
  23. 'move_line_ids': [(6, 0, move.ids)],
  24. })
  25. return invoice_line