Skip to content

Commit

Permalink
[IMP] To determine the invoice we put extra moves in, it is better to…
Browse files Browse the repository at this point in the history
… take the values from the sale order / purchase order if we can find it through the picking

[IMP] Add comments

[IMP] Simplify code
  • Loading branch information
jco-odoo committed Feb 25, 2015
1 parent cb6e27c commit d416492
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addons/purchase/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ def _get_master_data(self, cr, uid, move, company, context=None):
if 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
else:
elif 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:
if purchase_move.purchase_line_id:
purchase_order = purchase_move.purchase_line_id.order_id
return purchase_order.partner_id, purchase_order.create_uid.id, purchase_order.currency_id.id

partner = move.picking_id and move.picking_id.partner_id or False
code = self.get_code_from_locs(cr, uid, move, context=context)
if partner and partner.property_product_pricelist_purchase and code == 'incoming':
Expand Down
4 changes: 4 additions & 0 deletions addons/sale_stock/sale_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ def _get_master_data(self, cr, uid, move, company, context=None):
if move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id.order_policy == 'picking':
sale_order = move.procurement_id.sale_line_id.order_id
return sale_order.partner_invoice_id, sale_order.user_id.id, sale_order.pricelist_id.currency_id.id
elif move.picking_id.sale_id:
# In case of extra move, it is better to use the same data as the original moves
sale_order = move.picking_id.sale_id
return sale_order.partner_invoice_id, sale_order.user_id.id, sale_order.pricelist_id.currency_id.id
return super(stock_move, self)._get_master_data(cr, uid, move, company, context=context)

def _get_invoice_line_vals(self, cr, uid, move, partner, inv_type, context=None):
Expand Down

0 comments on commit d416492

Please sign in to comment.