Permalink
Browse files

[IMP] To determine the invoice we put extra moves in, it is better to…

… 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 18, 2015
1 parent cb6e27c commit d416492259f08cff03004e8679bf63afde260ab2
Showing with 11 additions and 1 deletion.
  1. +7 −1 addons/purchase/stock.py
  2. +4 −0 addons/sale_stock/sale_stock.py
View
@@ -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':
@@ -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):

1 comment on commit d416492

@dhongu

This comment has been minimized.

Show comment
Hide comment
@dhongu

dhongu Mar 2, 2015

It is not good for the purchase process when using the rule: buy and make to order. Purchase invoice will have the client as a partner.

dhongu commented on d416492 Mar 2, 2015

It is not good for the purchase process when using the rule: buy and make to order. Purchase invoice will have the client as a partner.

Please sign in to comment.