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

# Copyright 2019 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class StockMove(models.Model):
_inherit = 'stock.move'
pos_order_line_id = fields.Many2one(
comodel_name='pos.order.line',
string='Related POS Order Line',
)
@api.model
def create(self, vals):
"""We're creating the move in pos.order context
so we search the line uid"""
if self.env.context.get('merge_pos_order_line'):
line = self.env['pos.order.line'].search([
('name', '=', vals.get('name')),
])
if line:
vals['pos_order_line_id'] = line.id
return super().create(vals)
@api.model
def _prepare_merge_moves_distinct_fields(self):
distinct_fields = super()._prepare_merge_moves_distinct_fields()
distinct_fields.append('pos_order_line_id')
return distinct_fields