@ -0,0 +1,48 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-OPL--1-red.svg |
||||
|
:target: https://www.odoo.com/documentation/17.0/legal/licenses.html#odoo-apps |
||||
|
:alt: License: OPL-1 |
||||
|
|
||||
|
Batch Delivery Tracking |
||||
|
======================= |
||||
|
This module helps to track multiple delivery orders in batch transfer, |
||||
|
and get them same tracking orders. |
||||
|
|
||||
|
Configuration |
||||
|
============ |
||||
|
No additional configurations needed |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Odoo Proprietary License v1.0 (OPL-1). |
||||
|
(https://www.odoo.com/documentation/17.0/legal/licenses.html#odoo-apps) |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
Developer: (V17) Ayana KP, |
||||
|
(V18) Anzil K A |
||||
|
Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Anzil K A(odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import models |
@ -0,0 +1,39 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Anzil K A(odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
{ |
||||
|
'name': 'Batch Delivery Tracking', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Inventory', |
||||
|
'summary': """It Helps to Track Multiple Delivery Orders in a Batch Transfer""", |
||||
|
'description': """ This module helps to track multiple delivery orders in |
||||
|
batch transfer, and get them same tracking orders. """, |
||||
|
'author': 'Cybrosys Techno solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['stock_delivery', 'stock_picking_batch', 'delivery_fedex'], |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'OPL-1', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <batch_delivery_tracking> |
||||
|
|
||||
|
#### 29.03.2025 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
#### ADD |
||||
|
- Initial Commit for Batch Delivery Tracking |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Anzil K A(odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import delivery_carrier |
||||
|
from . import stock_picking |
@ -0,0 +1,209 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Anzil K A(odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
import logging |
||||
|
from markupsafe import Markup |
||||
|
from zeep.helpers import serialize_object |
||||
|
from odoo import models, _ |
||||
|
from odoo.exceptions import UserError |
||||
|
from odoo.tools import pdf |
||||
|
from odoo.addons.delivery_fedex.models.fedex_request import ( |
||||
|
FedexRequest, _convert_curr_iso_fdx) |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
class DeliveryCarrier(models.Model): |
||||
|
"""This class inherits from the base delivery carrier model and |
||||
|
allows for additional customization and functionality to be added |
||||
|
to delivery carriers. """ |
||||
|
_inherit = "delivery.carrier" |
||||
|
|
||||
|
def fedex_send_shipping(self, picking): |
||||
|
"""Overriding default fedex integration function to |
||||
|
check with our condition""" |
||||
|
if picking.batch_id and not picking.carrier_tracking_ref: |
||||
|
partner_id = picking.partner_id.id |
||||
|
carrier_id = picking.carrier_id.id |
||||
|
filtered_picking_ids = picking.batch_id.picking_ids.filtered( |
||||
|
lambda |
||||
|
x: x.partner_id.id == partner_id and x.carrier_id.id == carrier_id) |
||||
|
# Now you have filtered_picking_ids with the desired records |
||||
|
if len(filtered_picking_ids) > 1: |
||||
|
response = self._batch_fedex_send_shipping(picking, |
||||
|
filtered_picking_ids) |
||||
|
return response |
||||
|
else: |
||||
|
res = super().fedex_send_shipping(picking) |
||||
|
return res |
||||
|
else: |
||||
|
res = super().fedex_send_shipping(picking) |
||||
|
return res |
||||
|
|
||||
|
def _batch_fedex_send_shipping(self, picking, filtered_picking_ids): |
||||
|
""" Function for batch transfers picking to connect fedex and return |
||||
|
same tracking numbers for all picking with same |
||||
|
carrier id and customer. """ |
||||
|
res = [] |
||||
|
order_currency = picking.sale_id.currency_id or picking.company_id.currency_id |
||||
|
srm = FedexRequest(self.log_xml, request_type="shipping", |
||||
|
prod_environment=self.prod_environment) |
||||
|
superself = self.sudo() |
||||
|
srm.web_authentication_detail(superself.fedex_developer_key, |
||||
|
superself.fedex_developer_password) |
||||
|
srm.client_detail(superself.fedex_account_number, |
||||
|
superself.fedex_meter_number) |
||||
|
srm.transaction_detail(picking.id) |
||||
|
package_type = self.fedex_default_package_type_id.shipper_package_code |
||||
|
srm.shipment_request(self.fedex_droppoff_type, self.fedex_service_type, |
||||
|
package_type, self.fedex_weight_unit, |
||||
|
self.fedex_saturday_delivery) |
||||
|
srm.set_currency(_convert_curr_iso_fdx(order_currency.name)) |
||||
|
srm.set_shipper(picking.company_id.partner_id, |
||||
|
picking.picking_type_id.warehouse_id.partner_id) |
||||
|
srm.set_recipient(picking.partner_id) |
||||
|
srm.shipping_charges_payment(superself.fedex_account_number) |
||||
|
srm.shipment_label('COMMON2D', self.fedex_label_file_type, |
||||
|
self.fedex_label_stock_type, |
||||
|
'TOP_EDGE_OF_TEXT_FIRST', 'SHIPPING_LABEL_FIRST') |
||||
|
order = picking.sale_id |
||||
|
net_weight = 0.0 |
||||
|
if 'INTERNATIONAL' in self.fedex_service_type or self.fedex_service_type == 'FEDEX_REGIONAL_ECONOMY' or ( |
||||
|
picking.partner_id.country_id.code == 'IN' and picking.picking_type_id.warehouse_id.partner_id.country_id.code == 'IN'): |
||||
|
commodities = self._get_commodities_from_stock_move_lines( |
||||
|
picking.move_line_ids) |
||||
|
for commodity in commodities: |
||||
|
srm.commodities(self, commodity, |
||||
|
_convert_curr_iso_fdx(order_currency.name)) |
||||
|
|
||||
|
total_commodities_amount = sum( |
||||
|
c.monetary_value * c.qty for c in commodities) |
||||
|
srm.customs_value(_convert_curr_iso_fdx(order_currency.name), |
||||
|
total_commodities_amount, "NON_DOCUMENTS") |
||||
|
srm.duties_payment(order.warehouse_id.partner_id, |
||||
|
superself.fedex_account_number, |
||||
|
superself.fedex_duty_payment) |
||||
|
send_etd = superself.env['ir.config_parameter'].get_param( |
||||
|
"delivery_fedex.send_etd") |
||||
|
srm.commercial_invoice(self.fedex_document_stock_type, send_etd) |
||||
|
packages = [] |
||||
|
package_ids = [] |
||||
|
for pick in filtered_picking_ids: |
||||
|
# When the delivery packages are not in package_ids, then |
||||
|
# sent the delivery to _get_packages_from_picking() |
||||
|
if pick.move_line_ids.result_package_id not in package_ids: |
||||
|
package_ids.append(pick.move_line_ids.result_package_id) |
||||
|
converted_weight = self._fedex_convert_weight( |
||||
|
pick.shipping_weight, self.fedex_weight_unit) |
||||
|
package = self._get_packages_from_picking( |
||||
|
pick, self.fedex_default_package_type_id) |
||||
|
packages.append(package) |
||||
|
if isinstance(converted_weight, (int, float)): |
||||
|
net_weight += converted_weight |
||||
|
po_number = order.display_name or False |
||||
|
dept_number = False |
||||
|
if picking.partner_id.country_id.code == 'IN' and picking.picking_type_id.warehouse_id.partner_id.country_id.code == 'IN': |
||||
|
po_number = 'B2B' if picking.partner_id.commercial_partner_id.is_company else 'B2C' |
||||
|
dept_number = 'BILL D/T: SENDER' |
||||
|
master_tracking_id = False |
||||
|
package_labels = [] |
||||
|
carrier_tracking_refs = [] |
||||
|
flattened_packages = [item for sublist in packages for item in sublist] |
||||
|
for sequence, package in enumerate(flattened_packages, start=1): |
||||
|
srm.add_package( |
||||
|
self, |
||||
|
package, |
||||
|
_convert_curr_iso_fdx(package.company_id.currency_id.name), |
||||
|
sequence_number=sequence, |
||||
|
po_number=po_number, |
||||
|
dept_number=dept_number, |
||||
|
reference=picking.display_name, |
||||
|
) |
||||
|
srm.set_master_package(net_weight, len(flattened_packages), |
||||
|
master_tracking_id=master_tracking_id) |
||||
|
self._fedex_update_srm(srm, 'ship', picking=picking) |
||||
|
request = serialize_object( |
||||
|
dict(WebAuthenticationDetail=srm.WebAuthenticationDetail, |
||||
|
ClientDetail=srm.ClientDetail, |
||||
|
TransactionDetail=srm.TransactionDetail, |
||||
|
VersionId=srm.VersionId, |
||||
|
RequestedShipment=srm.RequestedShipment)) |
||||
|
self._fedex_add_extra_data_to_request(request, 'ship') |
||||
|
response = srm.process_shipment(request) |
||||
|
warnings = response.get('warnings_message') |
||||
|
if warnings: |
||||
|
_logger.info(warnings) |
||||
|
if response.get('errors_message'): |
||||
|
raise UserError(response['errors_message']) |
||||
|
package_name = package.name or 'package-' + str(sequence) |
||||
|
package_labels.append((package_name, srm.get_label())) |
||||
|
carrier_tracking_refs.append(response['tracking_number']) |
||||
|
if sequence == 1: |
||||
|
master_tracking_id = response['master_tracking_id'] |
||||
|
# Last package |
||||
|
if sequence == len(flattened_packages): |
||||
|
carrier_price = self._get_request_price(response['price'], |
||||
|
order, |
||||
|
order_currency) |
||||
|
if self.fedex_label_file_type != 'PDF': |
||||
|
attachments = [('%s-%s.%s' % ( |
||||
|
self._get_delivery_label_prefix(), pl[0], |
||||
|
self.fedex_label_file_type), pl[1]) for pl in |
||||
|
package_labels] |
||||
|
if self.fedex_label_file_type == 'PDF': |
||||
|
attachments = [ |
||||
|
('%s.pdf' % (self._get_delivery_label_prefix()), |
||||
|
pdf.merge_pdf( |
||||
|
[pl[1] for pl in package_labels]))] |
||||
|
num = 0 |
||||
|
for pick in filtered_picking_ids: |
||||
|
if not pick.carrier_tracking_ref and num < len( |
||||
|
carrier_tracking_refs): |
||||
|
logmessage = Markup( |
||||
|
_("Shipment created into Fedex<br/>" |
||||
|
"<b>Tracking Numbers:</b> %s<br/>" |
||||
|
"<b>Packages:</b> ")) % ( |
||||
|
carrier_tracking_refs[num], |
||||
|
) |
||||
|
num += 1 |
||||
|
pick.message_post(body=logmessage, |
||||
|
attachments=attachments) |
||||
|
shipping_data = {'exact_price': carrier_price, |
||||
|
'tracking_number': ','.join( |
||||
|
carrier_tracking_refs)} |
||||
|
res = res + [shipping_data] |
||||
|
logmessage = Markup(_("Shipment created into Fedex<br/>" |
||||
|
"<b>Tracking Numbers:</b> %s<br/>" |
||||
|
"<b>Packages:</b> %s")) % ( |
||||
|
','.join(carrier_tracking_refs), |
||||
|
','.join([pl[0] for pl in package_labels])) |
||||
|
if self.fedex_label_file_type != 'PDF': |
||||
|
attachments = [('%s-%s.%s' % ( |
||||
|
self._get_delivery_label_prefix(), pl[0], |
||||
|
self.fedex_label_file_type), pl[1]) for pl in |
||||
|
package_labels] |
||||
|
if self.fedex_label_file_type == 'PDF': |
||||
|
attachments = [('%s.pdf' % ( |
||||
|
self._get_delivery_label_prefix()), pdf.merge_pdf( |
||||
|
[pl[1] for pl in package_labels]))] |
||||
|
picking.batch_id.message_post(body=logmessage, |
||||
|
attachments=attachments) |
||||
|
return res |
@ -0,0 +1,140 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Anzil K A(odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from markupsafe import Markup |
||||
|
from odoo import models, fields, _ |
||||
|
|
||||
|
|
||||
|
class StockPicking(models.Model): |
||||
|
"""This class inherits from the base stock picking model in Odoo and allows |
||||
|
for additional customization and functionality to be added |
||||
|
to picking operations. """ |
||||
|
_inherit = "stock.picking" |
||||
|
|
||||
|
is_batch = fields.Boolean( |
||||
|
"Is Batch", store=True, |
||||
|
default=False, help="Is batch processing or not") |
||||
|
|
||||
|
def send_to_shipper(self): |
||||
|
""" Overriding function for adding to check condition |
||||
|
for batch transfer """ |
||||
|
self.ensure_one() |
||||
|
partner_id = self.partner_id.id |
||||
|
carrier_id = self.carrier_id.id |
||||
|
filtered_picking_ids = self.batch_id.picking_ids.filtered( |
||||
|
lambda |
||||
|
x: x.partner_id.id == partner_id and x.carrier_id.id == carrier_id) |
||||
|
if self.batch_id and len(filtered_picking_ids) > 1: |
||||
|
self._batch_send_to_shipper() |
||||
|
else: |
||||
|
res = self.carrier_id.send_shipping(self)[0] |
||||
|
if self.carrier_id.free_over and self.sale_id: |
||||
|
amount_without_delivery = self.sale_id._compute_amount_total_without_delivery() |
||||
|
if self.carrier_id._compute_currency(self.sale_id, |
||||
|
amount_without_delivery, |
||||
|
'pricelist_to_company') >= self.carrier_id.amount: |
||||
|
res['exact_price'] = 0.0 |
||||
|
self.carrier_price = res['exact_price'] * ( |
||||
|
1.0 + (self.carrier_id.margin / 100.0)) |
||||
|
if res['tracking_number']: |
||||
|
related_pickings = self.env[ |
||||
|
'stock.picking'] if self.carrier_tracking_ref and res[ |
||||
|
'tracking_number'] in self.carrier_tracking_ref else self |
||||
|
accessed_moves = previous_moves = self.move_ids.move_orig_ids |
||||
|
while previous_moves: |
||||
|
related_pickings |= previous_moves.picking_id |
||||
|
previous_moves = previous_moves.move_orig_ids - accessed_moves |
||||
|
accessed_moves |= previous_moves |
||||
|
accessed_moves = next_moves = self.move_ids.move_dest_ids |
||||
|
while next_moves: |
||||
|
related_pickings |= next_moves.picking_id |
||||
|
next_moves = next_moves.move_dest_ids - accessed_moves |
||||
|
accessed_moves |= next_moves |
||||
|
without_tracking = related_pickings.filtered( |
||||
|
lambda p: not p.carrier_tracking_ref) |
||||
|
without_tracking.carrier_tracking_ref = res['tracking_number'] |
||||
|
for p in related_pickings - without_tracking: |
||||
|
p.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", |
||||
|
carrier_name=self.carrier_id.name, |
||||
|
ref=self.carrier_tracking_ref) + \ |
||||
|
Markup("<br/>") + \ |
||||
|
_("Cost: %(price).2f %(currency)s", |
||||
|
price=self.carrier_price, |
||||
|
currency=order_currency.name) |
||||
|
self.message_post(body=msg) |
||||
|
self._add_delivery_cost_to_so() |
||||
|
|
||||
|
def _batch_send_to_shipper(self): |
||||
|
""" Method to batch send shipments to the shipper. |
||||
|
This method is responsible for sending shipments to the designated |
||||
|
carrier. It calculates the shipping cost, updates tracking |
||||
|
information, and posts messages related to the shipment. """ |
||||
|
partner_id = self.partner_id.id |
||||
|
carrier_id = self.carrier_id.id |
||||
|
filtered_picking_ids = self.batch_id.picking_ids.filtered( |
||||
|
lambda |
||||
|
x: x.partner_id.id == partner_id and x.carrier_id.id == carrier_id) |
||||
|
res = self.carrier_id.send_shipping(self)[0] |
||||
|
if self.carrier_id.free_over and self.sale_id: |
||||
|
amount_without_delivery = self.sale_id._compute_amount_total_without_delivery() |
||||
|
if self.carrier_id._compute_currency(self.sale_id, |
||||
|
amount_without_delivery, |
||||
|
'pricelist_to_company') >= self.carrier_id.amount: |
||||
|
res['exact_price'] = 0.0 |
||||
|
self.carrier_price = res['exact_price'] * ( |
||||
|
1.0 + (self.carrier_id.margin / 100.0)) |
||||
|
if res['tracking_number']: |
||||
|
related_pickings = self.env[ |
||||
|
'stock.picking'] if self.carrier_tracking_ref and res[ |
||||
|
'tracking_number'] in self.carrier_tracking_ref else self |
||||
|
accessed_moves = previous_moves = self.move_ids.move_orig_ids |
||||
|
while previous_moves: |
||||
|
related_pickings |= previous_moves.picking_id |
||||
|
previous_moves = previous_moves.move_orig_ids - accessed_moves |
||||
|
accessed_moves |= previous_moves |
||||
|
accessed_moves = next_moves = self.move_ids.move_dest_ids |
||||
|
while next_moves: |
||||
|
related_pickings |= next_moves.picking_id |
||||
|
next_moves = next_moves.move_dest_ids - accessed_moves |
||||
|
accessed_moves |= next_moves |
||||
|
num = 0 |
||||
|
for pick in filtered_picking_ids: |
||||
|
if not pick.carrier_tracking_ref: |
||||
|
tracking_numbers = res['tracking_number'].split(',') |
||||
|
if num < len(tracking_numbers): |
||||
|
pick.carrier_tracking_ref = tracking_numbers[num] |
||||
|
num += 1 |
||||
|
else: |
||||
|
pick.carrier_tracking_ref = res['tracking_number'] |
||||
|
order_currency = pick.sale_id.currency_id or pick.company_id.currency_id |
||||
|
msg = _( |
||||
|
"Shipment sent to carrier %(carrier_name)s for shipping with tracking number %(ref)s", |
||||
|
carrier_name=pick.carrier_id.name, |
||||
|
ref=pick.carrier_tracking_ref) + \ |
||||
|
Markup("<br/>") + \ |
||||
|
_("Cost: %(price).2f %(currency)s", |
||||
|
price=pick.carrier_price, |
||||
|
currency=order_currency.name) |
||||
|
pick.message_post(body=msg) |
||||
|
pick._add_delivery_cost_to_so() |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 565 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 112 KiB |
After Width: | Height: | Size: 258 KiB |
After Width: | Height: | Size: 690 KiB |