Skip to content

Commit

Permalink
[17.0][IMP] fieldservice_euipment_stock: add return order type
Browse files Browse the repository at this point in the history
  • Loading branch information
ilo committed Oct 21, 2024
1 parent 15a55b6 commit 077e64d
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 7 deletions.
2 changes: 2 additions & 0 deletions fieldservice_equipment_stock/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
],
"data": [
"security/ir.model.access.csv",
"data/fsm_order_type.xml",
"views/fsm_equipment.xml",
"views/fsm_order_type_view.xml",
"views/product_template.xml",
"views/stock_picking_type.xml",
"views/stock_lot.xml",
Expand Down
9 changes: 9 additions & 0 deletions fieldservice_equipment_stock/data/fsm_order_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="fsm_order_type_return" model="fsm.order.type">
<field name="name">Return</field>
<field name="internal_type">return</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions fieldservice_equipment_stock/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
stock_move,
stock_picking_type,
fsm_equipment,
fsm_order_type,
product_template,
stock_lot,
)
15 changes: 15 additions & 0 deletions fieldservice_equipment_stock/models/fsm_equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,18 @@ def write(self, vals):
if "lot_id" in vals:
equipment.lot_id.fsm_equipment_id = equipment.id
return res

def create_equip_order_return(self):
order_type = self.env.ref("fieldservice_equipment_stock.fsm_order_type_return")
return {

Check warning on line 50 in fieldservice_equipment_stock/models/fsm_equipment.py

View check run for this annotation

Codecov / codecov/patch

fieldservice_equipment_stock/models/fsm_equipment.py#L49-L50

Added lines #L49 - L50 were not covered by tests
"name": "Return Equipment",
"type": "ir.actions.act_window",
"res_model": "fsm.order",
"view_mode": "form",
"context": {
"default_equipment_id": self.id,
"default_order_type": order_type and order_type.id or False,
"default_partner_id": self.partner_id.id,
},
"target": "new",
}
15 changes: 15 additions & 0 deletions fieldservice_equipment_stock/models/fsm_order_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class FsmOrderType(models.Model):
_inherit = "fsm.order.type"

internal_type = fields.Selection(
selection_add=[("return", "Return")],
)
picking_type_id = fields.Many2one(
domain=[("code", "=", "incoming")],
)
11 changes: 4 additions & 7 deletions fieldservice_equipment_stock/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -461,9 +460,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Other credits</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
9 changes: 9 additions & 0 deletions fieldservice_equipment_stock/views/fsm_equipment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<field name="model">fsm.equipment</field>
<field name="inherit_id" ref="fieldservice.fsm_equipment_form_view" />
<field name="arch" type="xml">
<button id="previous_stage" position="before">
<button
id="new_equip_return"
name="create_equip_order_return"
string="Create Return"
class="oe_highlight"
type="object"
/>
</button>
<group id="secondary" position="inside">
<group string="Inventory" groups="stock.group_stock_user">
<field name="product_id" required="1" />
Expand Down
15 changes: 15 additions & 0 deletions fieldservice_equipment_stock/views/fsm_order_type_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<!-- Fields Service Orders Form View -->
<record id="fsm_order_type_form_view" model="ir.ui.view">
<field name="model">fsm.order.type</field>
<field name="inherit_id" ref="fieldservice.fsm_order_type_form_view" />
<field name="arch" type="xml">
<field name="internal_type" position="after">
<field name="picking_type_id" invisible="internal_type != 'return'" />
</field>
</field>
</record>

</odoo>
17 changes: 17 additions & 0 deletions fieldservice_equipment_stock/views/fsm_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<!-- Fields Service Orders Form View -->
<record id="fsm_order_maintenance_form" model="ir.ui.view">
<field name="model">fsm.order</field>
<field name="inherit_id" ref="fieldservice.fsm_order_form" />
<field name="arch" type="xml">
<field name="equipment_id" position="attributes">
<attribute
name="invisible"
>internal_type not in ['repair', 'maintenance', 'return']</attribute>
</field>
</field>
</record>

</odoo>

0 comments on commit 077e64d

Please sign in to comment.