Skip to content

Commit

Permalink
[FIX][14.0] fieldservice_sale_recurring: make link between invoice an…
Browse files Browse the repository at this point in the history
…d fsm order for recurring order
  • Loading branch information
paradoxxxzero committed Feb 28, 2023
1 parent 3ba281e commit b6fa0fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions fieldservice_sale_recurring/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"depends": [
"fieldservice_recurring",
"fieldservice_sale",
"fieldservice_account",
],
"data": [
"security/ir.model.access.csv",
Expand Down
5 changes: 5 additions & 0 deletions fieldservice_sale_recurring/models/fsm_recurring.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ def action_view_sales(self):
"context": {"create": False},
"name": _("Sales Orders"),
}

def _prepare_order_values(self, date=None):
res = super()._prepare_order_values(date)
res["sale_line_id"] = self.sale_line_id.id
return res
18 changes: 18 additions & 0 deletions fieldservice_sale_recurring/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ def _field_create_fsm_recurring(self):
fsm_recurring.message_post(body=fsm_recurring_msg)
result[so_line.id] = fsm_recurring
return result

def _get_invoiceable_fsm_order_domain(self):
"""
add fsm_recurring_id to domain
:return:
"""
dom = super()._get_invoiceable_fsm_order_domain()
if self.fsm_recurring_id:
dom.append(("fsm_recurring_id", "=", self.fsm_recurring_id.id))
return dom

def _prepare_invoice_line(self, **optional_values):
res = super()._prepare_invoice_line(**optional_values)
if self.fsm_recurring_id:
fsm_orders = self._get_invoiceable_fsm_order()
if fsm_orders:
res.update({"fsm_order_ids": [(6, 0, fsm_orders.ids)]})
return res

0 comments on commit b6fa0fb

Please sign in to comment.