Skip to content

Commit

Permalink
[FIX] delivery: only update not yet processed pickings based on the n…
Browse files Browse the repository at this point in the history
…ew carrier

closes #73624

X-original-commit: 0f2d378
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Signed-off-by: Wolfgang Taferner <wtaferner@users.noreply.github.com>
  • Loading branch information
wtaferner authored and agr-odoo committed Jul 20, 2021
1 parent 1726f1c commit 3dce2fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions addons/delivery/i18n/delivery.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,16 @@ msgstr ""
msgid "Weight unit of measure label"
msgstr ""

#. module: delivery
#: code:addons/delivery/models/sale_order.py:0
#, python-format
msgid ""
"You can not update the shipping costs on an order where it was already invoiced!\n"
"\n"
"The following delivery lines (product, invoiced quantity and price) have already been processed:\n"
"\n"
msgstr ""

#. module: delivery
#: model_terms:ir.ui.view,arch_db:delivery.delivery_tracking_url_warning_form
msgid "You have multiple tracker links, they are available in the chatter."
Expand Down
11 changes: 10 additions & 1 deletion addons/delivery/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ def onchange_order_line(self):
self.recompute_delivery_price = True

def _remove_delivery_line(self):
self.env['sale.order.line'].search([('order_id', 'in', self.ids), ('is_delivery', '=', True)]).unlink()
delivery_lines = self.env['sale.order.line'].search([('order_id', 'in', self.ids), ('is_delivery', '=', True)])
if not delivery_lines:
return
to_delete = delivery_lines.filtered(lambda x: x.qty_invoiced == 0)
if not to_delete:
raise UserError(
_('You can not update the shipping costs on an order where it was already invoiced!\n\nThe following delivery lines (product, invoiced quantity and price) have already been processed:\n\n')
+ '\n'.join(['- %s: %s x %s' % (line.product_id.with_context(display_default_code=False).display_name, line.qty_invoiced, line.price_unit) for line in delivery_lines])
)
to_delete.unlink()

def set_delivery_line(self, carrier, amount):

Expand Down

0 comments on commit 3dce2fd

Please sign in to comment.