Skip to content
Closed
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
2 changes: 2 additions & 0 deletions edi_chunk_processing_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import components
from . import models
28 changes: 28 additions & 0 deletions edi_chunk_processing_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2021 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "EDI Chunk Processing OCA",
"summary": "Add a new component for spliting and processing file using chunk",
"version": "14.0.1.0.0",
"category": "Uncategorized",
"website": "https://github.com/OCA/edi",
"author": " Akretion, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"external_dependencies": {
"python": [],
"bin": [],
},
"depends": [
"chunk_processing",
"edi_oca",
],
"data": [
"views/edi_exchange_record_views.xml",
"security/ir.model.access.csv",
],
"demo": [],
}
1 change: 1 addition & 0 deletions edi_chunk_processing_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import input_process_with_chunk
28 changes: 28 additions & 0 deletions edi_chunk_processing_oca/components/input_process_with_chunk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2021 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import Component

CHUNK_GROUP_FIELDS = [
"job_priority",
"chunk_size",
"process_multi",
"data_format",
"apply_on_model",
"usage",
"xml_split_xpath",
]


class ProcessWithChunk(Component):
_name = "edi.input.process.with.chunk"
_inherit = "edi.component.input.mixin"
_usage = "process.with.chunk"

def process(self):
vals = {"edi_exchange_record_id": [(4, self.exchange_record.id, 0)]}
for key in CHUNK_GROUP_FIELDS:
if hasattr(self.work, key):
vals[key] = getattr(self.work, key)
self.env["chunk.group"].create(vals)
2 changes: 2 additions & 0 deletions edi_chunk_processing_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import edi_exchange_record
from . import chunk_group
26 changes: 26 additions & 0 deletions edi_chunk_processing_oca/models/chunk_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2021 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import base64

from odoo import fields, models


class ChunkGroup(models.Model):
_inherit = "chunk.group"

# We use a O2M but as there is a sql constraint we can have only
# one pattern file, this is why the fieldname end with "id"
edi_exchange_record_id = fields.One2many(
"edi.exchange.record", "chunk_group_id", "Exchange Record"
)

def _get_data(self):
self.ensure_one()
if self.edi_exchange_record_id:
return base64.b64decode(
self.edi_exchange_record_id.exchange_file.decode("utf-8")
)
else:
return super()._get_data()
15 changes: 15 additions & 0 deletions edi_chunk_processing_oca/models/edi_exchange_record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class EdiExchangeRecord(models.Model):
_inherit = "edi.exchange.record"

chunk_group_id = fields.Many2one("chunk.group", string="Chunk Group")

_sql_constraints = [
("uniq_chunk_group_id", "unique(chunk_group_id)", "The Group must be unique!")
]
3 changes: 3 additions & 0 deletions edi_chunk_processing_oca/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_chunk_group,Chunk group,chunk_processing.model_chunk_group,base_edi.group_edi_manager,1,1,1,1
access_chunk_item,Chunk item,chunk_processing.model_chunk_item,base_edi.group_edi_manager,1,1,1,1
12 changes: 12 additions & 0 deletions edi_chunk_processing_oca/views/edi_exchange_record_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="edi_exchange_record_view_form" model="ir.ui.view">
<field name="model">edi.exchange.record</field>
<field name="inherit_id" ref="edi_oca.edi_exchange_record_view_form" />
<field name="arch" type="xml">
<field name="exchange_file" position="after">
<field name="chunk_group_id" />
</field>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/edi_chunk_processing_oca/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)