The delivery slip of an outgoing picking prints the warehouse address instead of the delivery address (which should be displayed as it may be different from the customer address) Steps to reproduce: 1. Install Contacts and Inventory 2. Open Contacts and add a delivery address named "delivery" to contact Azure Interior 3. Go to Inventory > Operations > Transfers 4. Create a new transfer with: - Contact: Azure Interior, delivery - Operation Type: San Fransisco: Delivery Orders - Product: Large Cabinet 5. Save the transfer and print the Delivery Slip 6. The warehouse address is displayed and there is no info about the delivery address Solution: Add a method to know if we should print the delivery address. We should print it if the picking has a delivery address and it is of type outgoing (or if it's a dropship) Problem: Printing the delivery address when the package partner is different from the picking partner is wrong because the delivery address might be different from the customer address opw-3064203 closes odoo/odoo#107355 X-original-commit: ec929f787f629940cd38a4ed25e5012335e2483d Signed-off-by: Tiffany Chang <tic@odoo.com> Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models, fields
|
|
|
|
|
|
class StockRule(models.Model):
|
|
_inherit = 'stock.rule'
|
|
|
|
@api.model
|
|
def _get_procurements_to_merge_groupby(self, procurement):
|
|
""" Do not group purchase order line if they are linked to different
|
|
sale order line. The purpose is to compute the delivered quantities.
|
|
"""
|
|
return procurement.values.get('sale_line_id'), super(StockRule, self)._get_procurements_to_merge_groupby(procurement)
|
|
|
|
|
|
class ProcurementGroup(models.Model):
|
|
_inherit = "procurement.group"
|
|
|
|
@api.model
|
|
def _get_rule_domain(self, location, values):
|
|
if 'sale_line_id' in values and values.get('company_id'):
|
|
return [('location_dest_id', '=', location.id), ('action', '!=', 'push'), ('company_id', '=', values['company_id'].id)]
|
|
else:
|
|
return super(ProcurementGroup, self)._get_rule_domain(location, values)
|
|
|
|
class StockPicking(models.Model):
|
|
_inherit = 'stock.picking'
|
|
|
|
is_dropship = fields.Boolean("Is a Dropship", compute='_compute_is_dropship')
|
|
|
|
@api.depends('location_dest_id.usage', 'location_id.usage')
|
|
def _compute_is_dropship(self):
|
|
for picking in self:
|
|
picking.is_dropship = picking.location_dest_id.usage == 'customer' and picking.location_id.usage == 'supplier'
|
|
|
|
def _is_to_external_location(self):
|
|
self.ensure_one()
|
|
return super()._is_to_external_location() or self.is_dropship
|
|
|
|
class StockPickingType(models.Model):
|
|
_inherit = 'stock.picking.type'
|
|
|
|
@api.depends('default_location_src_id', 'default_location_dest_id')
|
|
def _compute_warehouse_id(self):
|
|
super()._compute_warehouse_id()
|
|
if self.default_location_src_id.usage == 'supplier' and self.default_location_dest_id.usage == 'customer':
|
|
self.warehouse_id = False
|