[MIG] partner_equipment_applications to 18.0
This commit is contained in:
parent
4142187feb
commit
8e69382d84
7 changed files with 166 additions and 0 deletions
1
partner_equipment_applications/__init__.py
Normal file
1
partner_equipment_applications/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import models
|
||||||
36
partner_equipment_applications/__manifest__.py
Normal file
36
partner_equipment_applications/__manifest__.py
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#
|
||||||
|
# Bemade Inc.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023-June Bemade Inc. (<https://www.bemade.org>).
|
||||||
|
# Author: Marc Durepos (Contact : marc@bemade.org)
|
||||||
|
#
|
||||||
|
# This program is under the terms of the GNU Lesser General Public License,
|
||||||
|
# version 3.
|
||||||
|
#
|
||||||
|
# For full license details, see https://www.gnu.org/licenses/lgpl-3.0.en.html.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
{
|
||||||
|
"name": "Partner Application Equipment",
|
||||||
|
"version": "18.0.1.0.0",
|
||||||
|
"summary": "Make the link between customer_applications and fsm_equipment.",
|
||||||
|
"category": "Services/Field Service",
|
||||||
|
"author": "Bemade Inc.",
|
||||||
|
"website": "http://www.bemade.org",
|
||||||
|
"license": "LGPL-3",
|
||||||
|
"depends": ["fsm_equipment", "customer_applications"],
|
||||||
|
"data": [
|
||||||
|
"views/equipment_views.xml",
|
||||||
|
"views/application_views.xml",
|
||||||
|
],
|
||||||
|
"assets": {},
|
||||||
|
"installable": True,
|
||||||
|
"auto_install": True,
|
||||||
|
}
|
||||||
2
partner_equipment_applications/models/__init__.py
Normal file
2
partner_equipment_applications/models/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
from . import application
|
||||||
|
from . import equipment
|
||||||
29
partner_equipment_applications/models/application.py
Normal file
29
partner_equipment_applications/models/application.py
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class PartnerApplication(models.Model):
|
||||||
|
_inherit = "partner.application"
|
||||||
|
|
||||||
|
equipment_ids = fields.One2many(
|
||||||
|
comodel_name="fsm.equipment",
|
||||||
|
inverse_name="application_id",
|
||||||
|
string="Equipment",
|
||||||
|
)
|
||||||
|
equipment_count = fields.Integer(
|
||||||
|
compute="_compute_equipment_count",
|
||||||
|
string="Equipment Count",
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.constrains("equipment_ids")
|
||||||
|
def _check_equipment_ids(self):
|
||||||
|
for application in self:
|
||||||
|
if len(application.equipment_ids.partner_id) > 1:
|
||||||
|
raise ValidationError(
|
||||||
|
_("An application can only be linked to one partner.")
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends("equipment_ids")
|
||||||
|
def _compute_equipment_count(self):
|
||||||
|
for application in self:
|
||||||
|
application.equipment_count = len(application.equipment_ids)
|
||||||
17
partner_equipment_applications/models/equipment.py
Normal file
17
partner_equipment_applications/models/equipment.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class Equipment(models.Model):
|
||||||
|
_inherit = "fsm.equipment"
|
||||||
|
|
||||||
|
application_id = fields.Many2one(
|
||||||
|
comodel_name="partner.application",
|
||||||
|
tracking=1,
|
||||||
|
domain="[('partner_id', '=', partner_id)]",
|
||||||
|
ondelete="restrict",
|
||||||
|
)
|
||||||
|
application_type_id = fields.Many2one(
|
||||||
|
comodel_name="partner.application.type",
|
||||||
|
related="application_id.application_type_id",
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
39
partner_equipment_applications/views/application_views.xml
Normal file
39
partner_equipment_applications/views/application_views.xml
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="action_view_application_equipment" model="ir.actions.act_window">
|
||||||
|
<field name="name">Partner Equipments</field>
|
||||||
|
<field name="res_model">fsm.equipment</field>
|
||||||
|
<field name="view_mode">list,form</field>
|
||||||
|
<field name="context">{'default_application_id': context.get("application_id")}</field>
|
||||||
|
<field name="domain">[('application_id', '=', context.get("application_id"))]</field>
|
||||||
|
</record>
|
||||||
|
<record id="view_partner_application_search" model="ir.ui.view">
|
||||||
|
<field name="name">partner.application.search</field>
|
||||||
|
<field name="model">partner.application</field>
|
||||||
|
<field name="inherit_id" ref="customer_applications.view_partner_application_search"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="application_type_id" position="after">
|
||||||
|
<field name="equipment_ids"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="view_partner_application_form" model="ir.ui.view">
|
||||||
|
<field name="name">partner.application.form</field>
|
||||||
|
<field name="model">partner.application</field>
|
||||||
|
<field name="inherit_id" ref="customer_applications.view_partner_application_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<div name="button_box">
|
||||||
|
<button name="%(action_view_application_equipment)d"
|
||||||
|
type="action"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-tachometer"
|
||||||
|
context="{'application_id': id}"
|
||||||
|
>
|
||||||
|
<field string="Equipments" name="equipment_count" widget="statinfo"/>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
42
partner_equipment_applications/views/equipment_views.xml
Normal file
42
partner_equipment_applications/views/equipment_views.xml
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="view_search_fsm_equipment" model="ir.ui.view">
|
||||||
|
<field name="name">fsm.equipment.view.search</field>
|
||||||
|
<field name="model">fsm.equipment</field>
|
||||||
|
<field name="inherit_id" ref="fsm_equipment.equipment_view_search"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="partner_id" position="after">
|
||||||
|
<field name="application_id"/>
|
||||||
|
<field name="application_type_id"/>
|
||||||
|
<filter name="groupby_application_id" string="Application"
|
||||||
|
context="{'group_by':'application_id'}"/>
|
||||||
|
<filter name="groupby_application_type_id"
|
||||||
|
string="Application Type"
|
||||||
|
context="{'group_by':'application_type_id'}"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_list_fsm_equipment" model="ir.ui.view">
|
||||||
|
<field name="name">fsm.equipment.view.list</field>
|
||||||
|
<field name="model">fsm.equipment</field>
|
||||||
|
<field name="inherit_id" ref="fsm_equipment.equipment_view_list"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="name" position="after">
|
||||||
|
<field name="application_id" optional="show"/>
|
||||||
|
<field name="application_type_id" optional="show"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_form_fsm_equipment" model="ir.ui.view">
|
||||||
|
<field name="name">fsm.equipment.view.form</field>
|
||||||
|
<field name="model">fsm.equipment</field>
|
||||||
|
<field name="inherit_id" ref="fsm_equipment.equipment_view_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="partner_id" position="after">
|
||||||
|
<field name="application_id"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in a new issue