Skip to content

Commit

Permalink
[17.0][MIG] fieldservice_sale_recurring: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ilo committed Sep 17, 2024
1 parent e4d7ade commit a7b52c2
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 41 deletions.
1 change: 1 addition & 0 deletions fieldservice_sale_recurring/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Contributors
- Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
- Brian McMaster <brian@mcmpest.com>
- Raphaël Reverdy <raphael.reverdy@akretion.com>
- Italo LOPES <italo.lopes@camptocamp.com>

Maintainers
-----------
Expand Down
20 changes: 9 additions & 11 deletions fieldservice_sale_recurring/i18n/fieldservice_sale_recurring.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-17 15:03+0000\n"
"PO-Revision-Date: 2024-09-17 15:03+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -63,17 +65,15 @@ msgid "Field Service Tracking"
msgstr ""

#. module: fieldservice_sale_recurring
#. odoo-python
#: code:addons/fieldservice_sale_recurring/models/sale_order_line.py:0
#, python-format
msgid ""
"Field Service recurring Created (%(product)s): <a href=\n"
" # data-oe-model=fsm.recurring data-oe-id=%(id)s>%(name)s</a>\n"
" "
msgid "Field Service recurring Created ({product_name}): "
msgstr ""

#. module: fieldservice_sale_recurring
#: model:ir.model,name:fieldservice_sale_recurring.model_product_template
msgid "Product Template"
msgid "Product"
msgstr ""

#. module: fieldservice_sale_recurring
Expand Down Expand Up @@ -102,6 +102,7 @@ msgid "Sales Order Line"
msgstr ""

#. module: fieldservice_sale_recurring
#. odoo-python
#: code:addons/fieldservice_sale_recurring/models/fsm_recurring.py:0
#, python-format
msgid "Sales Orders"
Expand All @@ -114,11 +115,8 @@ msgid "Select a field service recurring order template to be created"
msgstr ""

#. module: fieldservice_sale_recurring
#. odoo-python
#: code:addons/fieldservice_sale_recurring/models/sale_order_line.py:0
#, python-format
msgid ""
"This recurring has been created from: <a href=\n"
" # data-oe-model=sale.order data-oe-id=%(order_id)s>%(order)s</a>\n"
" (%(product)s)\n"
" "
msgid "This recurring has been created ({product_name}) from: "
msgstr ""
6 changes: 3 additions & 3 deletions fieldservice_sale_recurring/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def action_view_fsm_recurring(self):

def _action_confirm(self):
"""On SO confirmation, some lines generate field service recurrings."""
result = super(SaleOrder, self)._action_confirm()
result = super()._action_confirm()
self.order_line.filtered(
lambda l: l.product_id.field_service_tracking == "recurring"
and not l.fsm_recurring_id
lambda line: line.product_id.field_service_tracking == "recurring"
and not line.fsm_recurring_id
)._field_create_fsm_recurring()
return result
38 changes: 16 additions & 22 deletions fieldservice_sale_recurring/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _field_create_fsm_recurring_prepare_values(self):

def _field_create_fsm_recurring(self):
"""Generate fsm_recurring for the given so line, and link it.
:return a mapping with the so line id and its linked fsm_recurring
return a mapping with the so line id and its linked fsm_recurring
:rtype dict
"""
result = {}
Expand All @@ -47,33 +47,27 @@ def _field_create_fsm_recurring(self):
values = so_line._field_create_fsm_recurring_prepare_values()
fsm_recurring = self.env["fsm.recurring"].sudo().create(values)
so_line.write({"fsm_recurring_id": fsm_recurring.id})

product_name = so_line.product_id.name

# post message on SO
msg_body = _(
"""Field Service recurring Created (%(product)s): <a href=
# data-oe-model=fsm.recurring data-oe-id=%(id)s>%(name)s</a>
"""
).format(
{
"product": so_line.product_id.name,
"id": fsm_recurring.id,
"name": fsm_recurring.name,
}
msg_body = (
_("Field Service recurring Created ({product_name}): ").format(
product_name=product_name
)
+ fsm_recurring._get_html_link()
)
so_line.order_id.message_post(body=msg_body)

# post message on fsm_recurring
fsm_recurring_msg = _(
"""This recurring has been created from: <a href=
# data-oe-model=sale.order data-oe-id=%(order_id)s>%(order)s</a>
(%(product)s)
"""
).format(
{
"order_id": so_line.order_id.id,
"order": so_line.order_id.name,
"product": so_line.product_id.name,
}
fsm_recurring_msg = (
_("This recurring has been created ({product_name}) from: ").format(
product_name=product_name
)
+ so_line.order_id._get_html_link()
)
fsm_recurring.message_post(body=fsm_recurring_msg)

result[so_line.id] = fsm_recurring
return result

Expand Down
1 change: 1 addition & 0 deletions fieldservice_sale_recurring/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- Serpent Consulting Services Pvt. Ltd. \<<support@serpentcs.com>\>
- Brian McMaster \<<brian@mcmpest.com>\>
- Raphaël Reverdy \<<raphael.reverdy@akretion.com>\>
- Italo LOPES \<<italo.lopes@camptocamp.com>\>
1 change: 1 addition & 0 deletions fieldservice_sale_recurring/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<li>Serpent Consulting Services Pvt. Ltd. &lt;<a class="reference external" href="mailto:support&#64;serpentcs.com">support&#64;serpentcs.com</a>&gt;</li>
<li>Brian McMaster &lt;<a class="reference external" href="mailto:brian&#64;mcmpest.com">brian&#64;mcmpest.com</a>&gt;</li>
<li>Raphaël Reverdy &lt;<a class="reference external" href="mailto:raphael.reverdy&#64;akretion.com">raphael.reverdy&#64;akretion.com</a>&gt;</li>
<li>Italo LOPES &lt;<a class="reference external" href="mailto:italo.lopes&#64;camptocamp.com">italo.lopes&#64;camptocamp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class TestFSMSaleRecurring(TestFSMSale):
@classmethod
def setUpClass(cls):
super(TestFSMSaleRecurring, cls).setUpClass()
super().setUpClass()
cls.test_location = cls.env.ref("fieldservice.test_location")

# Setup products that when sold will create some FSM orders
Expand Down
4 changes: 2 additions & 2 deletions fieldservice_sale_recurring/views/fsm_recurring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
name="action_view_sales"
class="oe_stat_button"
icon="fa-credit-card"
attrs="{'invisible': [('sale_line_id', '=', False)]}"
invisible="sale_line_id == False"
>
<span class="o_stat_text">Sale Orders</span>
<field name="sale_line_id" attrs="{'invisible': 1}" />
<field name="sale_line_id" invisible="1" />
</button>
</xpath>
</field>
Expand Down
2 changes: 1 addition & 1 deletion fieldservice_sale_recurring/views/product_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field name="fsm_order_template_id" position="after">
<field
name="fsm_recurring_template_id"
attrs="{'invisible':[('field_service_tracking', 'not in', ['recurring'])]}"
invisible="field_service_tracking not in ['recurring']"
/>
</field>
</field>
Expand Down
2 changes: 1 addition & 1 deletion fieldservice_sale_recurring/views/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name="action_view_fsm_recurring"
class="oe_stat_button"
icon="fa-calendar"
attrs="{'invisible': [('fsm_recurring_count', '=', 0)]}"
invisible="fsm_recurring_count == 0"
groups="fieldservice.group_fsm_user"
>
<field
Expand Down

0 comments on commit a7b52c2

Please sign in to comment.