[FIX] Drop shipping invoice correction

When invoicing from dropshipping picking, choose the correct partner.
Also, change the partner on the picking to be the partner of the purchase.
Change the picking report to include the destination partner or the warehouse address on the right.

[IMP] Only put partner_id on move from purchase when really necessary

[FIX] Default value of partner on stock move should be False
This commit is contained in:
Josse Colpaert 2014-12-22 17:28:51 +01:00
parent ba37ae3cf3
commit 6ea0cc41b9
4 changed files with 40 additions and 26 deletions

View File

@ -725,7 +725,7 @@ class purchase_order(osv.osv):
'location_id': order.partner_id.property_stock_supplier.id,
'location_dest_id': order.location_id.id,
'picking_id': picking_id,
'partner_id': order.dest_address_id.id or order.partner_id.id,
'partner_id': order.dest_address_id.id,
'move_dest_id': False,
'state': 'draft',
'purchase_line_id': order_line.id,
@ -831,7 +831,7 @@ class purchase_order(osv.osv):
for order in self.browse(cr, uid, ids):
picking_vals = {
'picking_type_id': order.picking_type_id.id,
'partner_id': order.dest_address_id.id or order.partner_id.id,
'partner_id': order.partner_id.id,
'date': max([l.date_planned for l in order.order_line]),
'origin': order.name
}

View File

@ -371,7 +371,7 @@ class stock_move(osv.osv):
return invoice_line_id
def _get_master_data(self, cr, uid, move, company, context=None):
if move.procurement_id and move.procurement_id.sale_line_id:
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
return super(stock_move, self)._get_master_data(cr, uid, move, company, context=context)
@ -411,7 +411,7 @@ class stock_picking(osv.osv):
"""
saleorder_ids = self.pool['sale.order'].search(cr, uid, [('procurement_group_id' ,'=', picking.group_id.id)], context=context)
saleorders = self.pool['sale.order'].browse(cr, uid, saleorder_ids, context=context)
if saleorders and saleorders[0]:
if saleorders and saleorders[0] and saleorders[0].order_policy == 'picking':
saleorder = saleorders[0]
return saleorder.partner_invoice_id.id
return super(stock_picking, self)._get_partner_to_invoice(cr, uid, picking, context=context)

View File

@ -1789,8 +1789,7 @@ class stock_move(osv.osv):
return False
def _default_destination_address(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.company_id.partner_id.id
return False
_defaults = {
'location_id': _default_location_source,

View File

@ -9,26 +9,41 @@
<div class="row"><div class="col-xs-4 pull-right">
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 600, 100)" style="width:300px;height:50px;"/>
</div></div>
<div t-if="o.picking_type_id.code=='incoming' and o.partner_id">
<span><strong>Supplier Address:</strong></span>
</div>
<div t-if="o.picking_type_id.code=='internal' and o.partner_id">
<span><strong>Warehouse Address:</strong></span>
</div>
<div t-if="o.picking_type_id.code=='outgoing' and o.partner_id">
<span><strong>Customer Address:</strong></span>
</div>
<div t-if="o.partner_id" name="partner_header">
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
<p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>
</div>
<h2>
<span t-field="o.picking_type_id"/>:
<span t-field="o.name"/>
</h2>
<table class="table table-condensed">
<div class="row">
<div class="col-xs-6">
<div t-if="o.picking_type_id.code=='incoming' and o.partner_id">
<span><strong>Supplier Address:</strong></span>
</div>
<div t-if="o.picking_type_id.code=='internal' and o.partner_id">
<span><strong>Warehouse Address:</strong></span>
</div>
<div t-if="o.picking_type_id.code=='outgoing' and o.partner_id">
<span><strong>Customer Address:</strong></span>
</div>
<div t-if="o.partner_id" name="partner_header">
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
<p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>
</div>
</div>
<div class="col-xs-5 col-xs-offset-1">
<div t-if="o.move_lines[0].partner_id and o.move_lines[0].partner_id.id != o.partner_id.id">
<span><strong>Delivery Address:</strong></span>
<div t-field="o.move_lines[0].partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
</div>
<div t-if="o.picking_type_id.code != 'internal' and (not o.move_lines[0].partner_id) and o.picking_type_id.warehouse_id.partner_id">
<span><strong>Warehouse Address:</strong></span>
<div t-field="o.picking_type_id.warehouse_id.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
</div>
</div>
</div>
<h2>
<span t-field="o.picking_type_id"/>:
<span t-field="o.name"/>
</h2>
<table class="table table-condensed">
<thead>
<tr>
<th><strong>Order (Origin)</strong></th>