Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] use total delivery price instead of total article price in totalAmount #123

Open
wants to merge 1 commit into
base: 10-roulier
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions delivery_roulier_laposte/models/stock_quant_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ class StockQuantPackage(models.Model):
_inherit = 'stock.quant.package'

def _laposte_before_call(self, picking, request):
def calc_package_price():
return sum(
[op.product_id.list_price * op.product_qty
for op in self.get_operations()]
)
def calc_delivery_price():
prices = []
for op in self.get_operations():
for sale_line in op.picking_id.sale_id.order_line:
if sale_line.is_delivery:
prices.append(sale_line.price_total)
return sum(prices)
# TODO _get_options is called fo each package by the result
# is the same. Should be store after first call
request['parcels'][0].update(picking._laposte_get_options(self))
if request['parcels'][0].get('COD'):
request['parcels'][0]['codAmount'] = self._get_cash_on_delivery(
picking)
request['service']['totalAmount'] = '%.f' % ( # truncate to string
calc_package_price() * 100 # totalAmount is in centimes
calc_delivery_price() * 100 # totalAmount is in centimes
)
request['service']['returnTypeChoice'] = 3 # do not return to sender
return request
Expand Down