Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Oct 27, 2024
1 parent 5e38a87 commit 1ebbfef
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 7 deletions.
7 changes: 7 additions & 0 deletions polars_db_process/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Authors

* Akretion

Contributors
------------

- Akretion

- David BEAL <[email protected]>

Maintainers
-----------

Expand Down
10 changes: 8 additions & 2 deletions polars_db_process/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Polars Database Process",
"version": "18.0.1.0.0",
"summary": "Allow to create a Polars dataframe from database query and "
"summary": "Allow to create a Polars dataframe from db.query and "
"check it and process it according to rules",
"category": "Reporting",
"license": "AGPL-3",
Expand All @@ -20,11 +20,17 @@
]
},
"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/db_config.xml",
# "views/db_table.xml",
# "views/db_type.xml",
],
"demo": [
"data/demo.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 db_config
23 changes: 23 additions & 0 deletions polars_db_process/models/db_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from odoo import fields, models

HELP = """
String connexion samples:
postgres://user:PASSWORD@server:port/database
mssql://user:PASSWORD@server:port/db.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 = "db.config"
_description = "External db.configuration"

name = fields.Char(required=True)
string_connexion = fields.Char(required=True, help=HELP)
password = fields.Char(required=True)

def _get_connexion(self):
return self.string_connexion.replace("PASSWORD", self.password)
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="db.config", help="Database")
3 changes: 3 additions & 0 deletions polars_db_process/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Akretion

> - David BEAL \<<[email protected]>\>
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="db_config_all" model="ir.model.access">
<field name="name">Database Config</field>
<field name="model_id" ref="model_db_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>
17 changes: 15 additions & 2 deletions polars_db_process/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ <h1 class="title">Polars Database Process</h1>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-4">Maintainers</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -412,8 +413,20 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul>
<li><p class="first">Akretion</p>
<blockquote>
<ul class="simple">
<li>David BEAL &lt;<a class="reference external" href="mailto:david.beal&#64;akretion.com">david.beal&#64;akretion.com</a>&gt;</li>
</ul>
</blockquote>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-4">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">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" />
Expand Down
53 changes: 53 additions & 0 deletions polars_db_process/views/db_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<odoo>
<record id="db_config_form" model="ir.ui.view">
<field name="model">db.config</field>
<field name="arch" type="xml">
<form>
<header />
<sheet>
<group>
<group>
<field name="name" />
</group>
<group>
<field name="password" password="1" />
</group>
</group>
<group name="connexion">
<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>
</group>
</sheet>
</form>
</field>
</record>

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

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

<menuitem
id="db_config_menu"
action="db_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>
3 changes: 3 additions & 0 deletions polars_db_process/wizards/df_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@

class DfProcessWiz(models.TransientModel):
_inherit = "df.process.wiz"

# def _pre_process(self):
# super()._pre_process()
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 1ebbfef

Please sign in to comment.