Skip to content
Open
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
5 changes: 3 additions & 2 deletions fieldservice_crm/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ Usage
- User must have Field Service User permissions
- Go to CRM app
- Create a new Opportunity
- Click the FS Orders Smart Button
- Create a Field Service Order
- Click the **Create FSM Order** button in the header to open a
pre-filled order form, or click the **FS Orders** smart button to
manage existing orders

Known issues / Roadmap
======================
Expand Down
15 changes: 15 additions & 0 deletions fieldservice_crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,18 @@ class Lead(models.Model):
def _compute_fsm_order_count(self):
for rec in self:
rec.fsm_order_count = len(rec.fsm_order_ids)

def action_create_fsm_order(self):
self.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id(
"fieldservice.action_fsm_operation_order"
)
action["context"] = {
"default_opportunity_id": self.id,
"default_location_id": self.fsm_location_id.id,
"default_description": self.description,
"default_priority": self.priority,
}
view = self.env.ref("fieldservice.fsm_order_form", raise_if_not_found=False)
action["views"] = [(view and view.id or False, "form")]
return action
4 changes: 2 additions & 2 deletions fieldservice_crm/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- User must have Field Service User permissions
- Go to CRM app
- Create a new Opportunity
- Click the FS Orders Smart Button
- Create a Field Service Order
- Click the **Create FSM Order** button in the header to open a pre-filled order form,
or click the **FS Orders** smart button to manage existing orders
5 changes: 3 additions & 2 deletions fieldservice_crm/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,9 @@ <h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<li>User must have Field Service User permissions</li>
<li>Go to CRM app</li>
<li>Create a new Opportunity</li>
<li>Click the FS Orders Smart Button</li>
<li>Create a Field Service Order</li>
<li>Click the <strong>Create FSM Order</strong> button in the header to open a
pre-filled order form, or click the <strong>FS Orders</strong> smart button to
manage existing orders</li>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
Expand Down
23 changes: 23 additions & 0 deletions fieldservice_crm/tests/test_fsm_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,26 @@ def test_fieldservicecrm(self):

location_1._compute_opportunity_count()
self.assertEqual(location_1.opportunity_count, 1)

def test_action_create_fsm_order(self):
location = self.env["fsm.location"].create(
{
"name": "Test Location",
"owner_id": self.env["res.partner"].create({"name": "Test Owner"}).id,
}
)
lead = self.env["crm.lead"].create(
{
"name": "Test Opportunity",
"type": "opportunity",
"fsm_location_id": location.id,
"description": "<p>Test description</p>",
"priority": "1",
}
)
action = lead.action_create_fsm_order()
ctx = action.get("context", {})
self.assertEqual(ctx.get("default_opportunity_id"), lead.id)
self.assertEqual(ctx.get("default_location_id"), location.id)
self.assertEqual(ctx.get("default_description"), "<p>Test description</p>")
self.assertEqual(ctx.get("default_priority"), "1")
12 changes: 11 additions & 1 deletion fieldservice_crm/views/crm_lead.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
<field name="name">fieldservice.crm.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form" />
<field eval="1" name="priority" />
<field eval="20" name="priority" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_set_won_rainbowman']" position="before">
<button
name="action_create_fsm_order"
string="Create FSM Order"
type="object"
class="oe_highlight"
groups="fieldservice.group_fsm_user"
invisible="type == 'lead'"
/>
</xpath>
<xpath expr="//div[@name='button_box']" position="inside">
<button
class="oe_stat_button o_res_partner_tip_opp"
Expand Down
Loading