Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Oct 26, 2024
1 parent 5e38a87 commit 7eb69b7
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 3 deletions.
2 changes: 2 additions & 0 deletions polars_db_process/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
},
"data": [
"data/demo.xml",
"security/ir.model.access.xml",
"wizards/df_process.xml",
"views/dataframe.xml",
"views/df_field.xml",
"views/df_source.xml",
"views/database_config.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions polars_db_process/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import dataframe
from . import df_field
from . import df_source
from . import database_config
20 changes: 20 additions & 0 deletions polars_db_process/models/database_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from odoo import fields, models

EXAMPLES = """
postgres://user:PASSWORD@server:port/database
mssql://user:PASSWORD@server:port/database?encrypt=true&trusted_connection=false
sqlite:///home/user/path/test.db
mysql://user:PASSWORD@server:port/database
oracle://user:PASSWORD@server:port/database
"""


class DatabaseConfig(models.Model):
_name = "database.config"
_description = "External database configuration"

name = fields.Char(required=True)
string_connexion = fields.Char(required=True)
password = fields.Char(required=True)
connexion_example = fields.Text(default=EXAMPLES, readonly=True)
5 changes: 4 additions & 1 deletion polars_db_process/models/df_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from odoo import models
from odoo import fields, models


class DfSource(models.Model):
_inherit = "df.source"

query = fields.Char()
db_id = fields.Many2one(comodel_name="database.config", help="Database")
11 changes: 11 additions & 0 deletions polars_db_process/security/ir.model.access.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo>
<record id="database_config_all" model="ir.model.access">
<field name="name">Database Config</field>
<field name="model_id" ref="model_database_config" />
<field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="1" />
<field name="perm_write" eval="1" />
<field name="perm_unlink" eval="1" />
</record>
</odoo>
55 changes: 55 additions & 0 deletions polars_db_process/views/database_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<odoo>
<record id="database_config_form" model="ir.ui.view">
<field name="model">database.config</field>
<field name="arch" type="xml">
<form>
<sheet>
<header />
<group>
<group>
<field name="name" />
</group>
<group>
<field name="password" password="1" />
</group>
</group>
<group>
<field
name="string_connexion"
placeholder="postgres://username:PASSWORD@server:port/database"
/>
<div>
<b
>PASSWORD in string connexion'll be replaced by password field</b>
</div>
<separator />
<field name="connexion_example" readonly="1" />
</group>
</sheet>
</form>
</field>
</record>

<record id="dataframe_tree" model="ir.ui.view">
<field name="model">database.config</field>
<field name="arch" type="xml">
<list>
<field name="name" />
</list>
</field>
</record>

<record id="database_config_action" model="ir.actions.act_window">
<field name="name">Database Config</field>
<field name="res_model">database.config</field>
<field name="view_mode">list,form</field>
<field name="path">database-config</field>
</record>

<menuitem
id="database_config_menu"
action="database_config_action"
parent="polars_process.polars_menu"
sequence="7"
/>
</odoo>
49 changes: 48 additions & 1 deletion polars_db_process/views/df_source.xml
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
<odoo />
<odoo>
<record id="df_source_form" model="ir.ui.view">
<field name="model">df.source</field>
<field name="inherit_id" ref="polars_process.df_source_form" />
<field name="arch" type="xml">
<xpath expr="//group[1]" position="after">
<separator />
<group>
<field name="db_id" invisible="template" />
<field name="query" widget="code" invisible="template" />
</group>
</xpath>
</field>
</record>

<record id="df_source_list" model="ir.ui.view">
<field name="model">df.source</field>
<field name="inherit_id" ref="polars_process.df_source_list" />
<field name="arch" type="xml">
<xpath expr="//list/field[last()]" position="after">
<field name="db_id" />
</xpath>
<xpath expr="//list/field[@name='template']" position="attributes">
<attribute
name="options"
>{'accepted_file_extensions': '.xlsx,.sql'}</attribute>
</xpath>
</field>
</record>

<record id="df_source_search" model="ir.ui.view">
<field name="model">df.source</field>
<field name="inherit_id" ref="polars_process.df_source_search" />
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="db_id" />
</xpath>
<xpath expr="//group" position="inside">
<filter
string="Database"
name="db_id"
domain="[]"
context="{'group_by': 'db_id'}"
/>
</xpath>
</field>
</record>
</odoo>
2 changes: 1 addition & 1 deletion test-requirement.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
odoo-addon-polars_process @ git+https://github.com/OCA/reporting-engine.git@refs/pull/943/head#subdirectory=polars_process
odoo-addon-polars_process @ git+https://github.com/OCA/reporting-engine.git@refs/pull/943/head#subdirectory=polars_process

0 comments on commit 7eb69b7

Please sign in to comment.