Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Oct 17, 2024
1 parent 98358b0 commit d856716
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 39 deletions.
9 changes: 7 additions & 2 deletions sheet_dataframe_process/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Sheet Dataframe Process
!! source digest: sha256:3fb8a401fe8c3d73e23b477915bbd9ff0b2bcb331711726a4fd5be280ad53d5d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
Expand Down Expand Up @@ -52,6 +52,11 @@ Why Polars ?
- environment consideration
- dynamic project

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
Expand Down
6 changes: 3 additions & 3 deletions sheet_dataframe_process/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "18.0.1.0.0",
"category": "Reporting",
"license": "AGPL-3",
"development_status": "Alpha",
"summary": "Allow to create a Polars dataframe from a sheet file and "
"process it according to rules",
"website": "https://github.com/OCA/reporting-engine",
Expand All @@ -19,16 +20,15 @@
]
},
"data": [
"data/action.xml",
"data/demo.xml",
"security/ir.model.access.xml",
"wizards/sheet_dataframe.xml",
"views/file_config.xml",
"views/file_field.xml",
"views/file_partner_field.xml",
# "views/file_config_field.xml",
"views/test_polars_file.xml",
"views/menu.xml",
"data/action.xml",
"data/demo.xml",
],
"installable": True,
}
6 changes: 3 additions & 3 deletions sheet_dataframe_process/data/action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<odoo>

<record id="refresh_conf" model="ir.actions.server">
<field name="name">📙 Mise à jour config</field>
<field name="name">Update config</field>
<field name="model_id" ref="model_file_config" />
<field name="binding_model_id" ref="model_file_config" />
<field name="state">code</field>
<field name="code">env["file.config"]._refresh_conf()</field>
<field name="code">env["file.config"]._refresh_conf_hook()</field>
</record>

<record id="refresh_file_example" model="ir.actions.server">
<field name="name"> Populate file polars example</field>
<field name="name">🐻‍❄️ Populate file polars example</field>
<field name="model_id" ref="model_test_polars_file" />
<field name="binding_model_id" ref="model_test_polars_file" />
<field name="state">code</field>
Expand Down
15 changes: 4 additions & 11 deletions sheet_dataframe_process/data/demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<record id="file_config_contact" model="file.config">
<field name="model_id" ref="base.model_res_partner" />
<field
name="partner_ids"
eval="[ref('base.res_partner_18'), ref('base.res_partner_5')]"
/>
</record>

<record id="file_config_contact_country" model="file.field">
Expand All @@ -15,15 +19,4 @@
<field name="on_fail">skip</field>
</record>

<record id="file_config_contact_country_partner18" model="file.partner.field">
<field name="line_id" ref="file_config_contact_country" />
<field name="partner_id" ref="base.res_partner_18" />
<field name="matching_column">pays</field>
</record>
<record id="file_config_contact_country_partner5" model="file.partner.field">
<field name="line_id" ref="file_config_contact_country" />
<field name="partner_id" ref="base.res_partner_5" />
<field name="matching_column">Blabla</field>
</record>

</odoo>
33 changes: 27 additions & 6 deletions sheet_dataframe_process/models/file_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from odoo import fields, models
from odoo import Command, fields, models


class FileConfig(models.Model):
_name = "file.config"
_inherit = "mail.thread"
_description = "Config import fournisseur"
_description = "File Configuration"
_rec_name = "model_id"

model_id = fields.Many2one(
Expand All @@ -19,12 +19,33 @@ class FileConfig(models.Model):
default="display",
help="Some other behaviors can be implemented",
)
partner_ids = fields.Many2many(comodel_name="res.partner")
field_ids = fields.One2many(comodel_name="file.field", inverse_name="config_id")
partner_ids = fields.Many2many(
comodel_name="res.partner", domain="[('active', 'in', (True, False))]"
)
field_ids = fields.One2many(
comodel_name="file.field", inverse_name="config_id", copy=True
)
field_match_ids = fields.One2many(
comodel_name="file.partner.field", inverse_name="config_id"
comodel_name="file.partner.field", inverse_name="config_id", copy=True
)

def populate_match_lines(self):
# TODO use api depends instead of ui button
self.ensure_one()
return NotImplemented
for partner in self.partner_ids:
fields_ = self.field_match_ids.filtered(
lambda s: s.partner_id == partner
).mapped("field_id")
line_ids = self.field_ids.filtered(
lambda s: s.field_id not in fields_
).mapped("id")
self.field_match_ids = [
Command.create({"partner_id": partner.id, "line_id": x})
for x in line_ids
]
self.field_match_ids.filtered(
lambda s: s.partner_id not in s.config_id.partner_ids
).unlink()

def _refresh_conf_hook(self):
"You use it to trigger specific behavior"
1 change: 0 additions & 1 deletion sheet_dataframe_process/models/file_partner_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ class FilePartnerField(models.Model):
)
partner_id = fields.Many2one(
comodel_name="res.partner",
readonly=True,
)
matching_column = fields.Char(help="Field name in spreadsheet")
8 changes: 7 additions & 1 deletion sheet_dataframe_process/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Sheet Dataframe Process</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3fb8a401fe8c3d73e23b477915bbd9ff0b2bcb331711726a4fd5be280ad53d5d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/18.0/sheet_dataframe_process"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-sheet_dataframe_process"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/18.0/sheet_dataframe_process"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-sheet_dataframe_process"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Based on an imported spreadsheet like file, this module allows to create
Polars dataframe and process them according to rules in order to:</p>
<ul class="simple">
Expand All @@ -393,6 +393,12 @@ <h1 class="title">Sheet Dataframe Process</h1>
<li>environment consideration</li>
<li>dynamic project</li>
</ul>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
<a class="reference external" href="https://odoo-community.org/page/development-status">More details on development status</a></p>
</div>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand Down
18 changes: 10 additions & 8 deletions sheet_dataframe_process/views/file_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
<field name="arch" type="xml">
<form>
<header>
<button
<button
name="populate_match_lines"
string="Populate"
string="Populate Matching Files"
type="object"
help="Populate matching lines with partners"
/>
<!--

<button
name="%(sheet_dataframe_transient_action)d"
type="action"
context="{'default_config_id': id}"
string="Import"
context="{'default_partner_id': partner_id}"
/>
-->
</header>
<sheet>
<group>
Expand All @@ -30,10 +29,13 @@
<field name="code" />
<field name="partner_ids" widget="many2many_tags" />
</group>
<separator string="Odoo field rules" />
<separator string="Field rules" />
<field name="field_ids" />
<separator string="Matching file fields" />
<field name="field_match_ids" />
<separator
string="Matching files - optional part"
invisible="not partner_ids"
/>
<field name="field_match_ids" invisible="not partner_ids" />
</group>
</sheet>
<chatter />
Expand Down
6 changes: 3 additions & 3 deletions sheet_dataframe_process/views/file_partner_field.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
context="{'default_config_id': parent}"
optional="hide"
/>
<field name="field_id" />
<field name="partner_id" />
<field name="matching_column" />
<field name="field_id" readonly="1" />
<field name="partner_id" readonly="1" />
<field name="matching_column" placeholder="Name in the spreadsheet" />
</list>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion sheet_dataframe_process/views/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<menuitem
id="dataframe_menu"
name="Dataframe 🐻‍❄️"
name="Dataframe"
parent="contacts.menu_contacts"
sequence="3"
/>
Expand Down

0 comments on commit d856716

Please sign in to comment.