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.

36 lines
1.1 KiB

  1. # Copyright 2018-19 Tecnativa - David Vidal
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import fields, models
  4. class PosOrder(models.Model):
  5. _inherit = 'pos.order'
  6. def create_picking(self):
  7. self_ctx = self.with_context(merge_pos_order_line=True)
  8. return super(PosOrder, self_ctx).create_picking()
  9. def _prepare_invoice(self):
  10. res = super(PosOrder, self)._prepare_invoice()
  11. res.update({
  12. 'picking_ids': [(6, 0, self.picking_id.ids)],
  13. })
  14. return res
  15. def _action_create_invoice_line(self, line=False, invoice_id=False):
  16. invoice_line = super(
  17. PosOrder, self)._action_create_invoice_line(line, invoice_id)
  18. if not line:
  19. return invoice_line
  20. invoice_line.move_line_ids |= line.stock_move_ids
  21. return invoice_line
  22. class PosOrderLine(models.Model):
  23. _inherit = 'pos.order.line'
  24. stock_move_ids = fields.One2many(
  25. comodel_name='stock.move',
  26. inverse_name='pos_order_line_id',
  27. string='Related Stock Moves',
  28. )