Permalink
Browse files

[FIX] sale, purchase: do not merge sale order and purchase order lines

  • Loading branch information...
wtaferner authored and sle-odoo committed Oct 17, 2017
1 parent ef592ff commit faff276e9292d9f7534bbfddd6d2c4b726164645
Showing with 27 additions and 1 deletion.
  1. +14 −1 addons/purchase/models/stock.py
  2. +13 −0 addons/sale_stock/models/stock.py
@@ -31,6 +31,19 @@ class StockMove(models.Model):
created_purchase_line_id = fields.Many2one('purchase.order.line',
'Created Purchase Order Line', ondelete='set null', readonly=True, copy=False)
@api.model
def _prepare_merge_moves_distinct_fields(self):
distinct_fields = super(StockMove, self)._prepare_merge_moves_distinct_fields()
distinct_fields.append('purchase_line_id')
return distinct_fields
@api.model
def _prepare_merge_move_sort_method(self, move):
move.ensure_one()
keys_sorted = super(StockMove, self)._prepare_merge_move_sort_method(move)
keys_sorted.append(move.purchase_line_id.id)
return keys_sorted
@api.multi
def _get_price_unit(self):
""" Returns the unit price for the move"""
@@ -148,4 +161,4 @@ def _quantity_in_progress(self):
res = super(Orderpoint, self)._quantity_in_progress()
for poline in self.env['purchase.order.line'].search([('state','in',('draft','sent','to approve')),('orderpoint_id','in',self.ids)]):
res[poline.orderpoint_id.id] += poline.product_uom._compute_quantity(poline.product_qty, poline.orderpoint_id.product_uom, round=False)
return res
return res
@@ -13,6 +13,19 @@ class StockMove(models.Model):
_inherit = "stock.move"
sale_line_id = fields.Many2one('sale.order.line', 'Sale Line')
@api.model
def _prepare_merge_moves_distinct_fields(self):
distinct_fields = super(StockMove, self)._prepare_merge_moves_distinct_fields()
distinct_fields.append('sale_line_id')
return distinct_fields
@api.model
def _prepare_merge_move_sort_method(self, move):
move.ensure_one()
keys_sorted = super(StockMove, self)._prepare_merge_move_sort_method(move)
keys_sorted.append(move.sale_line_id.id)
return keys_sorted
def _action_done(self):
result = super(StockMove, self)._action_done()
for line in self.mapped('sale_line_id'):

0 comments on commit faff276

Please sign in to comment.