Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mt-software-de committed Dec 12, 2022
1 parent 2e57b42 commit dc24d36
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 28 deletions.
1 change: 0 additions & 1 deletion delivery_line_qty_delivered/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"website": "https://github.com/OCA/delivery-carrier",
"depends": [
"delivery",
"sale_delivery_state",
],
"installable": True,
}
1 change: 0 additions & 1 deletion delivery_line_qty_delivered/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import sale_order
from . import sale_order_line
17 changes: 0 additions & 17 deletions delivery_line_qty_delivered/models/sale_order.py

This file was deleted.

25 changes: 17 additions & 8 deletions delivery_line_qty_delivered/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.tools import float_is_zero, groupby


class SaleOrderLine(models.Model):
Expand All @@ -16,18 +17,26 @@ def _compute_qty_delivered_method(self):
if line._is_delivery() and line.product_id.type == "service":
line.qty_delivered_method = "delivery"

def _get_delivery_qty_delivered(self):
def _get_delivery_qty_delivered(self, delivered):
self.ensure_one()
if (
self.product_id.invoice_policy == "delivery"
and self.order_id.delivery_state in ["done", "partially"]
):
if delivered:
return self.product_uom_qty
return 0.0

# @api.depends("qty_delivered_manual")
def _compute_qty_delivered(self):
super(SaleOrderLine, self)._compute_qty_delivered()
for line in self:
if line.qty_delivered_method != "delivery":
precision = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
lines_grouped = groupby(self, lambda l: l.order_id)
for order, lines in lines_grouped:
lines = dict(groupby(order.order_line, lambda l: l.qty_delivered_method))
if "delivery" not in lines or "stock_move" not in lines:
continue
line.qty_delivered = line._get_delivery_qty_delivered()
delivered = any(
not float_is_zero(line.qty_delivered, precision)
for line in lines["stock_move"]
)
for line in lines["delivery"]:
line.qty_delivered = line._get_delivery_qty_delivered(delivered)
1 change: 0 additions & 1 deletion oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt
partner-contact
sale-workflow

0 comments on commit dc24d36

Please sign in to comment.