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
985 B

  1. # Copyright 2019 Tecnativa - David Vidal
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, fields, models
  4. class StockMove(models.Model):
  5. _inherit = 'stock.move'
  6. pos_order_line_id = fields.Many2one(
  7. comodel_name='pos.order.line',
  8. string='Related POS Order Line',
  9. )
  10. @api.model
  11. def create(self, vals):
  12. """We're creating the move in pos.order context
  13. so we search the line uid"""
  14. if self.env.context.get('merge_pos_order_line'):
  15. line = self.env['pos.order.line'].search([
  16. ('name', '=', vals.get('name')),
  17. ])
  18. if line:
  19. vals['pos_order_line_id'] = line.id
  20. return super().create(vals)
  21. @api.model
  22. def _prepare_merge_moves_distinct_fields(self):
  23. distinct_fields = super()._prepare_merge_moves_distinct_fields()
  24. distinct_fields.append('pos_order_line_id')
  25. return distinct_fields