summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2015-06-29 11:03:17 +0200
committerNicolas Martinelli <nim@odoo.com>2015-06-29 11:52:27 +0200
commitec9702d7ffbf7e72d001b51495ab0480acefe828 (patch)
tree9e18a1a75ec0d5302bcaae449fbf642a7360c37d /addons
parente9c5da3524490d8ec2b285abcabbc7f4577255cf (diff)
[FIX] purchase: take into account origin_returned_move_id in case of in_refund invoice
When we return goods and a refund is created, we check the purchase order linked to the original move. Therefore, the appropriate currency and unit prices will be chosen. opw-643085
Diffstat (limited to 'addons')
-rw-r--r--addons/purchase/stock.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py
index b67e24fe40a..24895c2a402 100644
--- a/addons/purchase/stock.py
+++ b/addons/purchase/stock.py
@@ -93,9 +93,12 @@ class stock_move(osv.osv):
return invoice_line_id
def _get_master_data(self, cr, uid, move, company, context=None):
- if context.get('inv_type') in ('in_invoice', 'in_refund') and move.purchase_line_id:
+ if context.get('inv_type') == 'in_invoice' and move.purchase_line_id:
purchase_order = move.purchase_line_id.order_id
return purchase_order.partner_id, purchase_order.create_uid.id, purchase_order.currency_id.id
+ if context.get('inv_type') == 'in_refund' and move.origin_returned_move_id.purchase_line_id:
+ purchase_order = move.origin_returned_move_id.purchase_line_id.order_id
+ return purchase_order.partner_id, purchase_order.create_uid.id, purchase_order.currency_id.id
elif context.get('inv_type') in ('in_invoice', 'in_refund') and move.picking_id:
# In case of an extra move, it is better to use the data from the original moves
for purchase_move in move.picking_id.move_lines:
@@ -113,10 +116,14 @@ class stock_move(osv.osv):
def _get_invoice_line_vals(self, cr, uid, move, partner, inv_type, context=None):
res = super(stock_move, self)._get_invoice_line_vals(cr, uid, move, partner, inv_type, context=context)
- if inv_type in ('in_invoice', 'in_refund') and move.purchase_line_id:
+ if inv_type == 'in_invoice' and move.purchase_line_id:
purchase_line = move.purchase_line_id
res['invoice_line_tax_id'] = [(6, 0, [x.id for x in purchase_line.taxes_id])]
res['price_unit'] = purchase_line.price_unit
+ elif inv_type == 'in_refund' and move.origin_returned_move_id.purchase_line_id:
+ purchase_line = move.origin_returned_move_id.purchase_line_id
+ res['invoice_line_tax_id'] = [(6, 0, [x.id for x in purchase_line.taxes_id])]
+ res['price_unit'] = purchase_line.price_unit
return res
def _get_moves_taxes(self, cr, uid, moves, inv_type, context=None):