diff --git a/addons/delivery/models/stock_move.py b/addons/delivery/models/stock_move.py index 3b51fe7763e..a6ad6c839b7 100644 --- a/addons/delivery/models/stock_move.py +++ b/addons/delivery/models/stock_move.py @@ -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): diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index d4c1f0342fa..9c3b46844dd 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -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
Cost: %(price).2f %(currency)s", diff --git a/addons/delivery/views/delivery_view.xml b/addons/delivery/views/delivery_view.xml index 6f00f249914..21bf97e1cfd 100644 --- a/addons/delivery/views/delivery_view.xml +++ b/addons/delivery/views/delivery_view.xml @@ -385,9 +385,11 @@ + + diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 0e719020041..f284693d85c 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -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): diff --git a/addons/stock/models/stock_rule.py b/addons/stock/models/stock_rule.py index 82c36c07671..aa834158713 100644 --- a/addons/stock/models/stock_rule.py +++ b/addons/stock/models/stock_rule.py @@ -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', diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index 1f350e914f2..dbc678143fd 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -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'), diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index a875fadb88c..40a3e3a69a1 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -43,6 +43,7 @@ +