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

[14.0][ADD] sale_line_service_qty_delivered: Set qty_delivered of service lines #2717

Open
wants to merge 3 commits into
base: 14.0
Choose a base branch
from

Conversation

mt-software-de
Copy link

As soon as a sale.order.line is delivered
the qty_delivered of the siblings service lines
is set to its max qty

Copy link

@vuwnevska vuwnevska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIS
https://github.com/OCA/delivery-carrier/blob/14.0/delivery_auto_refresh/models/stock_picking.py
solves the similar issue of the delivery update on outgoing picking done

sale_line_service_qty_delivered/models/sale_order_line.py Outdated Show resolved Hide resolved
sale_line_service_qty_delivered/models/sale_order_line.py Outdated Show resolved Hide resolved
sale_line_service_qty_delivered/models/sale_order_line.py Outdated Show resolved Hide resolved
@mt-software-de
Copy link
Author

AFAIS https://github.com/OCA/delivery-carrier/blob/14.0/delivery_auto_refresh/models/stock_picking.py solves the similar issue of the delivery update on outgoing picking done

Not really.

@rousseldenis
Copy link
Contributor

@mt-software-de What's the status of this ?

@mt-software-de mt-software-de force-pushed the 14.0-add-sale_line_service_qty_delivered branch 2 times, most recently from 205db9c to 3382d99 Compare February 5, 2025 19:58
…ines

As soon as a sale.order.line is delivered
the qty_delivered of the siblings service lines
is set to its max qty
@mt-software-de mt-software-de force-pushed the 14.0-add-sale_line_service_qty_delivered branch from 3382d99 to bddf437 Compare February 5, 2025 21:05
@mt-software-de mt-software-de force-pushed the 14.0-add-sale_line_service_qty_delivered branch from bddf437 to 867cbc9 Compare February 5, 2025 21:08
@mt-software-de
Copy link
Author

@mt-software-de What's the status of this ?

I checked the failing tests, they were coming from sale_order_invoicing_finished_task, because they interfere with each other.

Also check the code of the new addon.
I did like that, if there is a stock_move sale.order.line and a delivery sale.order.line the delivered qty of the delivery line was set to its max when the stock.move sale.order.line was delivered.
But when there is a order with just a delivery sale.order.line this line was always set marked as delivered,
with the commit 867cbc9 i changed it.
So now if there is just a delivery sale.order.line the delivered qty is 0.

@vuwnevska @jbaudoux @rousseldenis
What do you think is better?

Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me that you do what is in standard (at least in v16).
If you configure the delivery service as invoiced at order, then it will be invoiced as soon as there is a stock line delivered.

Comment on lines 10 to 23
def _get_invoice_status(self):
super()._get_invoice_status()
to_invoice_state = "to invoice"
for order in self:
if order.state not in ("sale", "done"):
continue
if order.invoice_status != "no":
continue
if any(
line._is_delivered_method_delivery()
and line.invoice_status == to_invoice_state
for line in order.order_line
):
order.invoice_status = to_invoice_state
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has nothing to do with the module purpose ??

In standard, a SO is not to invoice if only the delivery line is to invoice. This should not be changed. You need at least another line to invoice to be able to invoice the SO

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lines which are is_delivery and invoice_policy == 'delivery' and type == 'service' they should only be invoice when something is shipped.
But for Service Products which are not added via deliver costs so is_delivery == False and invoice_policy == 'delivery' and type == 'service' it should be possible to invoice if there are no other sale.order.lines.

I will extend it.

sale_line_service_qty_delivered/models/sale_order_line.py Outdated Show resolved Hide resolved
sale_line_service_qty_delivered/models/sale_order_line.py Outdated Show resolved Hide resolved
def _is_delivered_method_delivery(self):
self.ensure_one()
return (
self.product_id.type == "service"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All service lines?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no not all, only if the invoice_policy of the product is delivery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants