[FIX] delivery: put in pack package domain

Before this commit, on a picking, when we want to put in pack, we can't
select packages created with no package carrier type as they had a
confusion between `package_carrier_type` and `delivery_type` when we
pass the value in the context (value who is reused to the package
domain, making some package unfindable).

closes odoo/odoo#46992

X-original-commit: 21f054731e8635b9e3681e673a7cbf627ad49cca
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
svs-odoo
2020-03-05 14:37:09 +00:00
committed by Pierre Masereel
parent 7032dde60a
commit 4f1fa7e24c
2 changed files with 13 additions and 6 deletions
+12 -5
View File
@@ -141,6 +141,17 @@ class StockPicking(models.Model):
"""
self.ensure_one()
view_id = self.env.ref('delivery.choose_delivery_package_view_form').id
context = dict(
self.env.context,
current_package_carrier_type=self.carrier_id.delivery_type,
default_picking_id=self.id
)
# As we pass the `delivery_type` ('fixed' by default) in a key who correspond
# to the `package_carrier_type` ('none' to default), we make a conversion.
# No need conversion for other carriers as the `delivery_type` and
#`package_carrier_type` will be the same in these cases.
if context['current_package_carrier_type'] == 'fixed':
context['current_package_carrier_type'] = 'none'
return {
'name': _('Package Details'),
'type': 'ir.actions.act_window',
@@ -149,11 +160,7 @@ class StockPicking(models.Model):
'view_id': view_id,
'views': [(view_id, 'form')],
'target': 'new',
'context': dict(
self.env.context,
current_package_carrier_type=self.carrier_id.delivery_type,
default_picking_id=self.id
),
'context': context,
}
def send_to_shipper(self):
@@ -6,7 +6,7 @@
<field name="arch" type="xml">
<form string="Package">
<group>
<field name="delivery_packaging_id" domain="[('package_carrier_type', '=', context.get('current_package_carrier_type', False))]"
<field name="delivery_packaging_id" domain="[('package_carrier_type', '=', context.get('current_package_carrier_type', 'none'))]"
context="{'form_view_ref':'delivery.product_packaging_delivery_form'}"/>
<label for="shipping_weight" attrs="{'invisible': [('delivery_packaging_id', '=', False)]}"/>
<div class="o_row" attrs="{'invisible': [('delivery_packaging_id', '=', False)]}" name="package_weight">