[IMP] delivery, stock: allow to print labels in PICK+PACK+SHIP

In this commit -
1) Added new field propagate_carrier_id in stock.rule and propgate
carrier in PICK PACK and SHIP if it is ticked.
2) Allow to print Label at any stage of PICK PACK and SHIP after
validation of picking from chatter.

Task-2363484

closes odoo/odoo#62851

Related: odoo/enterprise#15148
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit is contained in:
Pratima Gupta
2021-01-21 12:24:37 +00:00
parent a4cc5cef6e
commit 41f290ae11
8 changed files with 28 additions and 10 deletions
+2 -1
View File
@@ -19,7 +19,8 @@ class StockMove(models.Model):
def _get_new_picking_values(self):
vals = super(StockMove, self)._get_new_picking_values()
vals['carrier_id'] = self.mapped('sale_line_id.order_id.carrier_id').id
carrier_id = self.group_id.sale_id.carrier_id.id
vals['carrier_id'] = self.rule_id.propagate_carrier and carrier_id
return vals
def _key_assign_picking(self):
+5 -4
View File
@@ -89,6 +89,7 @@ class StockPicking(models.Model):
help="Total weight of packages and products not in a package. Packages with no shipping weight specified will default to their products' total weight. This is the weight used to compute the cost of the shipping.")
is_return_picking = fields.Boolean(compute='_compute_return_picking')
return_label_ids = fields.One2many('ir.attachment', compute='_compute_return_label')
destination_country_code = fields.Char(related='partner_id.country_id.code', string="Destination Country")
@api.depends('carrier_id', 'carrier_tracking_ref')
def _compute_carrier_tracking_url(self):
@@ -124,9 +125,8 @@ class StockPicking(models.Model):
def _send_confirmation_email(self):
for pick in self:
if pick.carrier_id:
if pick.carrier_id.integration_level == 'rate_and_ship' and pick.picking_type_code != 'incoming':
pick.send_to_shipper()
if pick.carrier_id and pick.carrier_id.integration_level == 'rate_and_ship' and pick.picking_type_code != 'incoming' and not pick.carrier_tracking_ref and pick.picking_type_id.print_label:
pick.send_to_shipper()
return super(StockPicking, self)._send_confirmation_email()
def _pre_put_in_pack_hook(self, move_line_ids):
@@ -172,7 +172,8 @@ class StockPicking(models.Model):
res['exact_price'] = 0.0
self.carrier_price = res['exact_price'] * (1.0 + (self.carrier_id.margin / 100.0))
if res['tracking_number']:
self.carrier_tracking_ref = res['tracking_number']
pickings = self.sale_id.picking_ids or self
pickings.carrier_tracking_ref = res['tracking_number']
order_currency = self.sale_id.currency_id or self.company_id.currency_id
msg = _(
"Shipment sent to carrier %(carrier_name)s for shipping with tracking number %(ref)s<br/>Cost: %(price).2f %(currency)s",
+2
View File
@@ -385,9 +385,11 @@
<xpath expr="//field[@name='backorder_id']" position="after">
<field name="carrier_tracking_ref" optional="hide"/>
<field name="carrier_id" optional="hide"/>
<field name="destination_country_code" optional="hide" string="Destination"/>
<field name="weight" optional="hide"/>
<field name="shipping_weight" optional="hide"/>
</xpath>
</field>
</record>
</odoo>
+12 -5
View File
@@ -58,6 +58,9 @@ class PickingType(models.Model):
use_existing_lots = fields.Boolean(
'Use Existing Lots/Serial Numbers', default=True,
help="If this is checked, you will be able to choose the Lots/Serial Numbers. You can also decide to not put lots in this operation type. This means it will create stock with no lot or not put a restriction on the lot taken. ")
print_label = fields.Boolean(
'Print Label',
help="If this checkbox is ticked, label will be print in this operation.")
show_operations = fields.Boolean(
'Show Detailed Operations', default=_default_show_operations,
help="If this checkbox is ticked, the pickings lines will represent detailed stock operations. If not, the picking lines will represent an aggregate of detailed stock operations.")
@@ -175,15 +178,19 @@ class PickingType(models.Model):
if self.code == 'incoming':
self.default_location_src_id = self.env.ref('stock.stock_location_suppliers').id
self.default_location_dest_id = stock_location.id
self.print_label = False
elif self.code == 'outgoing':
self.default_location_src_id = stock_location.id
self.default_location_dest_id = self.env.ref('stock.stock_location_customers').id
elif self.code == 'internal' and not self.user_has_groups('stock.group_stock_multi_locations'):
return {
'warning': {
'message': _('You need to activate storage locations to be able to do internal operation types.')
self.print_label = True
elif self.code == 'internal':
self.print_label = False
if not self.user_has_groups('stock.group_stock_multi_locations'):
return {
'warning': {
'message': _('You need to activate storage locations to be able to do internal operation types.')
}
}
}
@api.onchange('company_id')
def _onchange_company_id(self):
+3
View File
@@ -78,6 +78,9 @@ class StockRule(models.Model):
propagate_cancel = fields.Boolean(
'Cancel Next Move', default=False,
help="When ticked, if the move created by this rule is cancelled, the next move will be cancelled too.")
propagate_carrier = fields.Boolean(
'Propagation of carrier', default=False,
help="When ticked, carrier of shipment will be propgated.")
warehouse_id = fields.Many2one('stock.warehouse', 'Warehouse', check_company=True)
propagate_warehouse_id = fields.Many2one(
'stock.warehouse', 'Warehouse to Propagate',
+2
View File
@@ -503,6 +503,7 @@ class Warehouse(models.Model):
},
'rules_values': {
'active': True,
'propagate_carrier': True
}
},
'crossdock_route_id': {
@@ -942,6 +943,7 @@ class Warehouse(models.Model):
'default_location_dest_id': False,
'sequence': max_sequence + 5,
'sequence_code': 'OUT',
'print_label': True,
'company_id': self.company_id.id,
}, 'pack_type_id': {
'name': _('Pack'),
@@ -43,6 +43,7 @@
<field name="sequence_id" groups="base.group_no_one"/>
<field name="sequence_code"/>
<field name="warehouse_id" groups="stock.group_stock_multi_warehouses" force_save="1"/>
<field name="print_label" attrs="{'invisible': [('code', '!=', 'internal')]}"/>
<label for="reservation_method" attrs="{'invisible': [('code', '=', 'incoming')]}"/>
<div class="o_row" attrs="{'invisible': [('code', '=', 'incoming')]}">
<field name="reservation_method" widget="radio"/>
+1
View File
@@ -98,6 +98,7 @@
<field name="group_propagation_option"/>
<field name="group_id" attrs="{'invisible': [('group_propagation_option', '!=', 'fixed')], 'required': [('group_propagation_option', '=', 'fixed')]}"/>
<field name="propagate_cancel"/>
<field name="propagate_carrier" groups="base.group_no_one"/>
<field name="propagate_warehouse_id"/>
</group>
<group string="Options" attrs="{'invisible': [('action', 'not in', ['pull', 'push', 'pull_push'])]}">