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

[FW][FIX] delivery: fix a recent fix and stop deleting invoiced order lines on update #74412

Closed
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions addons/delivery/i18n/delivery.pot
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,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