Skip to content

Commit

Permalink
Merge PR #674 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by gurneyalex
  • Loading branch information
OCA-git-bot committed Sep 9, 2024
2 parents d296c03 + 8e09b12 commit 2361c60
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions delivery_postlogistics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models
from . import postlogistics
from . import wizard
12 changes: 12 additions & 0 deletions delivery_postlogistics/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,15 @@ def verify_credentials(self):
},
}
return message

def _compute_can_generate_return(self):
res = super(DeliveryCarrier, self)._compute_can_generate_return()
for carrier in self:
if carrier.delivery_type == "postlogistics":
carrier.can_generate_return = True
return res

def postlogistics_get_return_label(
self, picking, tracking_number=None, origin_date=None
):
return self.postlogistics_send_shipping(picking)
6 changes: 6 additions & 0 deletions delivery_postlogistics/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,9 @@ def generate_postlogistics_shipping_labels(self, package_ids=None):
"""Add label generation for PostLogistics"""
self.ensure_one()
return self._generate_postlogistics_label(package_ids=package_ids)

def action_generate_carrier_label(self):
self.ensure_one()
if not self.carrier_id:
raise exceptions.UserError(_("Please, set a carrier."))
self.env["delivery.carrier"].postlogistics_send_shipping(self)
16 changes: 16 additions & 0 deletions delivery_postlogistics/views/stock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
<field name="model">stock.picking</field>
<field name="inherit_id" ref="delivery.view_picking_withcarrier_out_form" />
<field name="arch" type="xml">
<field name="state" position="before">
<button
name="action_generate_carrier_label"
help="Create Shipping Label 🚚"
attrs="{'invisible': ['|', '|', ('state', '!=', 'done'), ('delivery_type', '!=', 'postlogistics'), ('picking_type_code', '=', 'incoming')]}"
string="Create Shipping Label 🚚"
type="object"
/>
</field>

<button name="print_return_label" position="attributes">
<attribute
name="attrs"
>{'invisible':['|', ('is_return_picking', '=', False),('picking_type_code', '!=', 'incoming')]}</attribute>
</button>

<xpath expr="//page//group[@name='carrier_data']/.." position="after">
<separator
string="Delivery instructions"
Expand Down
1 change: 1 addition & 0 deletions delivery_postlogistics/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_picking_return
12 changes: 12 additions & 0 deletions delivery_postlogistics/wizard/stock_picking_return.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import models


class ReturnPicking(models.TransientModel):
_inherit = "stock.return.picking"

def _create_returns(self):
new_picking, pick_type_id = super(ReturnPicking, self)._create_returns()
if self.picking_id.delivery_type == "postlogistics":
picking = self.env["stock.picking"].browse(new_picking)
picking.write({"carrier_id": self.picking_id.carrier_id.id})
return new_picking, pick_type_id

0 comments on commit 2361c60

Please sign in to comment.