Skip to content

Commit

Permalink
[UPD] controller moved based on commit comments (#135)
Browse files Browse the repository at this point in the history
* [UPD] controller moved based on commit comments

* [FIX] fixed unit tests
  • Loading branch information
Marcoapu authored Oct 25, 2024
1 parent 2cd097b commit d39e238
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 28 deletions.
3 changes: 2 additions & 1 deletion controllo_accessi_inrim_app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import models
from . import controllers
1 change: 1 addition & 0 deletions controllo_accessi_inrim_app/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import anag_tipologie_istanze
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from odoo import http

from .api_controller_inrim import InrimApiController, BadRequest
from ...inrim_controllo_accessi_api.controllers.api_controller_inrim import InrimApiController, BadRequest

class InrimApiAnagTipologieIstanze(InrimApiController):

Expand Down
2 changes: 0 additions & 2 deletions inrim_controllo_accessi/data/ca_punto_accesso_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<field name="ca_lettore_id" eval="ref('inrim_anagrafiche.inrim_demo_ca_lettore_1')"/>
<field name="direction">in</field>
<field name="typology">stamping</field>
<field name="codice_lettore_grum">20</field>
<field name="enable_sync">True</field>
<field name="date_start" eval="datetime.today()"/>
<field name="date_end" eval="datetime.today() + timedelta(days=15)"/>
Expand All @@ -17,7 +16,6 @@
<field name="ca_lettore_id" eval="ref('inrim_anagrafiche.inrim_demo_ca_lettore_2')"/>
<field name="direction">out</field>
<field name="typology">stamping</field>
<field name="codice_lettore_grum">20</field>
<field name="enable_sync">True</field>
<field name="date_start" eval="datetime.today()"/>
<field name="date_end" eval="datetime.today() + timedelta(days=15)"/>
Expand Down
12 changes: 0 additions & 12 deletions inrim_controllo_accessi/models/ca_punto_accesso.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ class CaPuntoAccesso(models.Model):
ca_tag_lettore_ids = fields.One2many('ca.tag_lettore', 'ca_punto_accesso_id')
remote_update = fields.Boolean(readonly=True)
active = fields.Boolean(default=True)
codice_lettore_grum = fields.Integer(
string='Codice Lettore GRUM',
)

@api.constrains('codice_lettore_grum', 'typology')
def _check_codice_lettore_grum(self):
for record in self:
if record.typology == 'stamping' and not record.codice_lettore_grum:
raise UserError("Il codice lettore GRUM è obbligatorio se la tipologia è: Timbratura.")
if record.codice_lettore_grum:
if not (20 <= record.codice_lettore_grum <= 999):
raise UserError("Il codice lettore GRUM deve essere compreso tra 20 e 999.")

@api.constrains('date_start', 'date_end')
def _check_date(self):
Expand Down
2 changes: 0 additions & 2 deletions inrim_controllo_accessi/tests/test_inrim.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def test_5(self):
'ca_spazio_id': self.spazio_8.id,
'ca_lettore_id': self.lettore_3.id,
'typology': 'stamping',
'codice_lettore_grum': 20,
'date_start': date.today(),
'date_end': date.today() + relativedelta(days=30)
})
Expand Down Expand Up @@ -180,7 +179,6 @@ def test_7(self):
'ca_spazio_id': self.spazio_3.id,
'ca_lettore_id': self.lettore_3.id,
'typology': 'stamping',
'codice_lettore_grum': 20,
'enable_sync': False,
'date_start': date.today(),
'date_end': date.today() + relativedelta(days=30),
Expand Down
1 change: 0 additions & 1 deletion inrim_controllo_accessi/views/ca_punto_accesso_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
<field name="system_error"/>
<field name="direction"/>
<field name="typology"/>
<field name="codice_lettore_grum" required="typology == 'stamping'"/>
<field name="type_ids" invisible="True"/>
</group>
<group>
Expand Down
6 changes: 1 addition & 5 deletions inrim_controllo_accessi_api/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@
from . import documento
from . import tag
from . import settore_ente
from . import anag_servizi
from . import anag_avanzamento_rich
from . import anag_tipologie_istanze
from . import richiesta_servizi_persona
from . import richiesta_accesso_persona
from . import anag_servizi
1 change: 1 addition & 0 deletions inrim_controllo_accessi_custom/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions inrim_controllo_accessi_custom/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
'name': 'Inrim Controllo Accessi Custom',
'version': '17.0.1.0.0',
'description': "Inrim Controllo Accessi Custom",
"author": "Alessio Gerace - Inrim",
"website": "https://github.com/INRIM",
'depends': [
'inrim_controllo_accessi'
],
'data': [
'views/ca_punto_accesso_views.xml',
],
'demo': [],
'installable': True,
'application': True,
}
26 changes: 26 additions & 0 deletions inrim_controllo_accessi_custom/data/ca_punto_accesso_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="inrim_controllo_accessi.ca_punto_accesso_1p001" model="ca.punto_accesso">
<field name="ca_spazio_id" eval="ref('inrim_anagrafiche.ca_spazio_1p001')"/>
<field name="ca_lettore_id" eval="ref('inrim_anagrafiche.inrim_demo_ca_lettore_1')"/>
<field name="direction">in</field>
<field name="typology">stamping</field>
<field name="codice_lettore_grum">20</field>
<field name="enable_sync">True</field>
<field name="date_start" eval="datetime.today()"/>
<field name="date_end" eval="datetime.today() + timedelta(days=15)"/>
</record>

<record id="inrim_controllo_accessi.ca_punto_accesso_1p002" model="ca.punto_accesso">
<field name="ca_spazio_id" eval="ref('inrim_anagrafiche.ca_spazio_1p002')"/>
<field name="ca_lettore_id" eval="ref('inrim_anagrafiche.inrim_demo_ca_lettore_2')"/>
<field name="direction">out</field>
<field name="typology">stamping</field>
<field name="codice_lettore_grum">20</field>
<field name="enable_sync">True</field>
<field name="date_start" eval="datetime.today()"/>
<field name="date_end" eval="datetime.today() + timedelta(days=15)"/>
</record>
</data>
</odoo>
1 change: 1 addition & 0 deletions inrim_controllo_accessi_custom/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ca_punto_accesso
19 changes: 19 additions & 0 deletions inrim_controllo_accessi_custom/models/ca_punto_accesso.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import models, fields, api, _
from odoo.exceptions import UserError


class CaPuntoAccesso(models.Model):
_inherit = "ca.punto_accesso"

codice_lettore_grum = fields.Integer(
string='Codice Lettore GRUM',
)

@api.constrains('codice_lettore_grum', 'typology')
def _check_codice_lettore_grum(self):
for record in self:
if record.typology == 'stamping' and not record.codice_lettore_grum:
raise UserError("Il codice lettore GRUM è obbligatorio se la tipologia è: Timbratura.")
if record.codice_lettore_grum:
if not (20 <= record.codice_lettore_grum <= 999):
raise UserError("Il codice lettore GRUM deve essere compreso tra 20 e 999.")
13 changes: 13 additions & 0 deletions inrim_controllo_accessi_custom/views/ca_punto_accesso_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="ca_punto_accesso_view_form_inherit" model="ir.ui.view">
<field name="name">ca.punto_accesso.view.form.inherit</field>
<field name="model">ca.punto_accesso</field>
<field name="inherit_id" ref="inrim_controllo_accessi.ca_punto_accesso_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='typology']" position="after">
<field name="codice_lettore_grum" required="typology == 'stamping'"/>
</xpath>
</field>
</record>
</odoo>
3 changes: 2 additions & 1 deletion inrim_controllo_accessi_richieste_accesso/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import models
from . import controllers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import richiesta_accesso_persona
from . import richiesta_servizi_persona
from . import anag_avanzamento_rich
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from odoo import http

from .api_controller_inrim import InrimApiController, BadRequest
from ...inrim_controllo_accessi_api.controllers.api_controller_inrim import InrimApiController, BadRequest

class InrimApiAnagAvanzamentoRich(InrimApiController):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from odoo import http

from .api_controller_inrim import InrimApiController, BadRequest
from ...inrim_controllo_accessi_api.controllers.api_controller_inrim import InrimApiController, BadRequest

class InrimApiRichiestaAccessoPersona(InrimApiController):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from odoo import http

from .api_controller_inrim import InrimApiController, BadRequest
from ...inrim_controllo_accessi_api.controllers.api_controller_inrim import InrimApiController, BadRequest

class InrimApiRichiestaServiziPersona(InrimApiController):

Expand Down

0 comments on commit d39e238

Please sign in to comment.