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
44 changes: 44 additions & 0 deletions crm_claim_extra_ref/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
===================
CRM claim extra ref
===================

.. |badge1| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

|badge1|

This module creates the new fields "Reference 2" and "Reference 3" and shows
then in the form, in the search search form, and allows grouping records by
these new fields.


**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/avanzosc/crm-addons/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/avanzosc/crm-addons/issues/new?body=module:%crm_claim_extra_ref%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* AvanzOSC

Contributors
~~~~~~~~~~~~

* Pedro M. Baeza
* Ana Juaristi <anajuaristi@avanzosc.es>
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
1 change: 1 addition & 0 deletions crm_claim_extra_ref/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import model
24 changes: 24 additions & 0 deletions crm_claim_extra_ref/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2015 Pedro M. Baeza (http://www.serviciosbaeza.com)
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# Copyright 2026 Eñaut Alberdi - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "CRM Claim Extra Ref",
"version": "18.0.1.0.0",
"author": "OdooMRP team," "AvanzOSC," "Serv. Tecnol. Avanzados - Pedro M. Baeza",
"category": "CRM Claim",
"license": "AGPL-3",
"website": "https://github.com/avanzosc/crm-addons",
"contributors": [
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com",
"Ana Juaristi <anajuaristi@avanzosc.es>",
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>",
"Eñaut Alberdi <enautavanzosc@gmail.com>",
],
"depends": ["crm_claim", "crm_claim_report"],
"data": [
"reports/crm_claim_report.xml",
"views/crm_claim_view.xml",
],
"installable": True,
}
67 changes: 67 additions & 0 deletions crm_claim_extra_ref/i18n/crm_claim_extra_ref.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_claim_extra_ref
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-25 12:42+0000\n"
"PO-Revision-Date: 2024-03-25 12:42+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: crm_claim_extra_ref
#: model:ir.model,name:crm_claim_extra_ref.model_crm_claim
msgid "Claim"
msgstr ""

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_model_name2
msgid "Ref. Model 2"
msgstr ""

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_model_name3
msgid "Ref. Model 3"
msgstr ""

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_name2
msgid "Ref. Name 2"
msgstr ""

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_name3
msgid "Ref. Name 3"
msgstr ""

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref2
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.view_crm_case_claims_filter_inh_extraref
msgid "Reference 2"
msgstr ""

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref3
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.view_crm_case_claims_filter_inh_extraref
msgid "Reference 3"
msgstr ""

#. module: crm_claim_extra_ref
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.report_crmclaim_document
msgid ""
"<br/>\n"
" <strong>Reference 2:</strong>"
msgstr ""

#. module: crm_claim_extra_ref
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.report_crmclaim_document
msgid ""
"<br/>\n"
" <strong>Reference 3:</strong>"
msgstr ""
71 changes: 71 additions & 0 deletions crm_claim_extra_ref/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_claim_extra_ref
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-25 12:42+0000\n"
"PO-Revision-Date: 2024-03-25 12:42+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: crm_claim_extra_ref
#: model:ir.model,name:crm_claim_extra_ref.model_crm_claim
msgid "Claim"
msgstr "Reclamación"

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_model_name2
msgid "Ref. Model 2"
msgstr "Ref. Modelo 2"

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_model_name3
msgid "Ref. Model 3"
msgstr "Ref. Modelo 3"

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_name2
msgid "Ref. Name 2"
msgstr "Ref. Nombre 2"

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref_name3
msgid "Ref. Name 3"
msgstr "Ref. Nombre 3"

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref2
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.view_crm_case_claims_filter_inh_extraref
msgid "Reference 2"
msgstr "Referencia 2"

#. module: crm_claim_extra_ref
#: model:ir.model.fields,field_description:crm_claim_extra_ref.field_crm_claim__ref3
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.view_crm_case_claims_filter_inh_extraref
msgid "Reference 3"
msgstr "Referencia 3"

#. module: crm_claim_extra_ref
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.report_crmclaim_document
msgid ""
"<br/>\n"
" <strong>Reference 2:</strong>"
msgstr ""
"<br/>\n"
" <strong>Referencia 2:</strong>"

#. module: crm_claim_extra_ref
#: model_terms:ir.ui.view,arch_db:crm_claim_extra_ref.report_crmclaim_document
msgid ""
"<br/>\n"
" <strong>Reference 3:</strong>"
msgstr ""
"<br/>\n"
" <strong>Referencia 3:</strong>"
1 change: 1 addition & 0 deletions crm_claim_extra_ref/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import crm_claim
75 changes: 75 additions & 0 deletions crm_claim_extra_ref/model/crm_claim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from odoo import _, api, fields, models

APPLICABLE_MODELS = [
"account.invoice",
"event.registration",
"hr.applicant",
"res.partner",
"product.product",
"purchase.order",
"purchase.order.line",
"sale.order",
"sale.order.line",
]


class CrmClaim(models.Model):
_inherit = "crm.claim"

def _links_get(self):
return [
(x, _(self.env[x]._description)) for x in APPLICABLE_MODELS if x in self.env
]

@api.depends("ref2")
def _compute_ref_model_name2(self):
model_obj = self.env["ir.model"]
for claim in self:
ref_model_name2 = False
if claim.ref2:
cond = [("model", "=", str(claim.ref2._name))]
model = model_obj.search(cond)
ref_model_name2 = model.display_name
claim.ref_model_name2 = ref_model_name2

@api.depends("ref2")
def _compute_ref_name2(self):
for claim in self:
ref_name2 = False
if claim.ref2:
ref_name2 = claim.ref2.display_name or claim.ref2.name
claim.ref_name2 = ref_name2

@api.depends("ref3")
def _compute_ref_model_name3(self):
model_obj = self.env["ir.model"]
for claim in self:
ref_model_name3 = False
if claim.ref3:
cond = [("model", "=", str(claim.ref3._name))]
model = model_obj.search(cond)
ref_model_name3 = model.display_name
claim.ref_model_name3 = ref_model_name3

@api.depends("ref3")
def _compute_ref_name3(self):
for claim in self:
ref_name3 = False
if claim.ref3:
ref_name3 = claim.ref3.display_name or claim.ref3.name
claim.ref_name3 = ref_name3

ref2 = fields.Reference(string="Reference 2", selection="_links_get")
ref_model_name2 = fields.Char(
string="Ref. Model 2", compute="_compute_ref_model_name2", store=True
)
ref_name2 = fields.Char(
string="Ref. Name 2", compute="_compute_ref_name2", store=True
)
ref3 = fields.Reference(string="Reference 3", selection="_links_get")
ref_model_name3 = fields.Char(
string="Ref. Model 3", compute="_compute_ref_model_name3", store=True
)
ref_name3 = fields.Char(
string="Ref. Name 3", compute="_compute_ref_name3", store=True
)
3 changes: 3 additions & 0 deletions crm_claim_extra_ref/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
20 changes: 20 additions & 0 deletions crm_claim_extra_ref/reports/crm_claim_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="report_crmclaim_document"
inherit_id="crm_claim_report.report_crmclaim_document"
>
<span t-field="o.ref_name" position="after">
<t t-if="o.ref2">
<br />
<strong>Reference 2:</strong>
<span t-field="o.ref_model_name2" />: <span t-field="o.ref_name2" />
</t>
<t t-if="o.ref3">
<br />
<strong>Reference 3:</strong>
<span t-field="o.ref_model_name3" />: <span t-field="o.ref_name3" />
</t>
</span>
</template>
</odoo>
54 changes: 54 additions & 0 deletions crm_claim_extra_ref/views/crm_claim_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_crm_case_claims_filter_inh_extraref" model="ir.ui.view">
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.view_crm_case_claims_filter" />
<field name="arch" type="xml">
<field name="name" position="after">
<separator />
<field name="ref_name2" />
<field name="ref_name3" />
</field>
<filter name="partner" position="after">
<filter
name="group-ref2"
string="Reference 2"
domain="[]"
help="Reference 2"
context="{'group_by':'ref_model_name2'}"
/>
<filter
name="group-ref3"
string="Reference 3"
domain="[]"
help="Reference 3"
context="{'group_by':'ref_model_name3'}"
/>
</filter>
</field>
</record>

<record id="crm_case_claims_tree_view_inh_extraref" model="ir.ui.view">
<field name="name">crm.case.claims.tree.view.inh.extraref</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_tree_view" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="ref2" optional="show" />
<field name="ref3" optional="show" />
</field>
</field>
</record>

<record id="crm_case_claims_form_view_inh_extraref" model="ir.ui.view">
<field name="name">crm.case.claims.form.view.inh.extraref</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view" />
<field name="arch" type="xml">
<field name="model_ref_id" position="after">
<field name="ref2" />
<field name="ref3" />
</field>
</field>
</record>
</odoo>