Skip to content

Commit 9838425

Browse files
committed
Merge PR #1315 into 18.0
Signed-off-by brian10048
2 parents 47c9a51 + ad94f94 commit 9838425

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"pull_requests": {
3+
"OCA/field-service#997": "dotfiles",
4+
"OCA/field-service#999": "(auto) Nothing to port from PR #999"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"pull_requests": {
3+
"OCA/field-service#931": "(auto) Nothing to port from PR #931",
4+
"OCA/field-service#1122": "(auto) Nothing to port from PR #1122"
5+
}
6+
}

fieldservice_account/models/fsm_stage.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ def _get_invoiceable_stage(self):
1515
by other criteria
1616
:return:
1717
"""
18-
return self.search(["is_invoiceable", "=", "True"])
18+
return self.search([("is_invoiceable", "=", "True")])

fieldservice_sale/models/sale_order_line.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2019 Brian McMaster
22
# Copyright (C) 2019 Open Source Integrators
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4-
from odoo import api, fields, models
4+
from odoo import Command, api, fields, models
55

66

77
class SaleOrderLine(models.Model):
@@ -53,8 +53,31 @@ def create(self, vals_list):
5353
line.order_id._field_service_generation()
5454
return lines
5555

56+
def _get_invoiceable_fsm_order_domain(self):
57+
"""
58+
Override this method to define more search criteria for invoiceable
59+
fsm order
60+
:return:
61+
"""
62+
invoiceable_stage_ids = self.env["fsm.stage"]._get_invoiceable_stage()
63+
dom = [
64+
"|",
65+
("sale_line_id", "=", self.id),
66+
("sale_id", "=", self.order_id.id),
67+
("invoice_lines", "=", False),
68+
]
69+
if invoiceable_stage_ids:
70+
dom.append(("stage_id", "in", invoiceable_stage_ids.ids))
71+
return dom
72+
73+
def _get_invoiceable_fsm_order(self):
74+
dom = self._get_invoiceable_fsm_order_domain()
75+
return self.env["fsm.order"].search(dom)
76+
5677
def _prepare_invoice_line(self, **optional_values):
5778
res = super()._prepare_invoice_line(**optional_values)
5879
if self.fsm_order_id:
59-
res.update({"fsm_order_ids": [(4, self.fsm_order_id.id)]})
80+
fsm_orders = self._get_invoiceable_fsm_order()
81+
if fsm_orders:
82+
res.update({"fsm_order_ids": [Command.set(fsm_orders.ids)]})
6083
return res

fieldservice_sale_recurring/models/sale_order_line.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (C) 2019 Open Source Integrators
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
44

5-
from odoo import _, fields, models
5+
from odoo import Command, _, fields, models
66

77

88
class SaleOrderLine(models.Model):
@@ -86,5 +86,5 @@ def _prepare_invoice_line(self, **optional_values):
8686
if self.fsm_recurring_id:
8787
fsm_orders = self._get_invoiceable_fsm_order()
8888
if fsm_orders:
89-
res.update({"fsm_order_ids": [(6, 0, fsm_orders.ids)]})
89+
res.update({"fsm_order_ids": [Command.set(fsm_orders.ids)]})
9090
return res

0 commit comments

Comments
 (0)