Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] edi_account_invoice_import #67

Open
wants to merge 7 commits into
base: 16.0
Choose a base branch
from
Open
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
102 changes: 102 additions & 0 deletions edi_account_invoice_import/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
==========================
EDI Account Invoice Import
==========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
: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
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github
:target: https://github.com/OCA/edi/tree/14.0/edi_account_invoice_import
:alt: OCA/edi
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-edi_account_invoice_import
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/226/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

Plug account_invoice_import into EDI machinery.


Control invoice confirmation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can decide if the invoice should be posted by exchange type.

On your exchange type, go to advanced settings and add the following::

[...]
components:
process:
usage: input.process.account.invoice
[...]
account_invoice:
post_invoice: true

.. 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::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20edi_account_invoice_import%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Lois Rilo <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px
:target: https://github.com/LoisRForgeFlow
:alt: LoisRForgeFlow

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-LoisRForgeFlow|

This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/14.0/edi_account_invoice_import>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions edi_account_invoice_import/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import components
17 changes: 17 additions & 0 deletions edi_account_invoice_import/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# @author: Lois Rilo <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "EDI Account Invoice Import",
"summary": """Plug account_invoice_import into EDI machinery.""",
"version": "16.0.1.1.0",
"development_status": "Alpha",
"license": "AGPL-3",
"website": "https://github.com/OCA/edi-framework",
"author": "ForgeFlow,Odoo Community Association (OCA)",
"maintainers": ["LoisRForgeFlow"],
"depends": ["edi_oca", "account_invoice_import"],
"auto_install": True,
"data": ["templates/exchange_chatter_msg.xml"],
}
1 change: 1 addition & 0 deletions edi_account_invoice_import/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import process
67 changes: 67 additions & 0 deletions edi_account_invoice_import/components/process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# @author: Lois Rilo <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import _
from odoo.exceptions import UserError

from odoo.addons.component.core import Component


class EDIExchangeSOInput(Component):
"""Process Invoices (journal entries)."""

_name = "edi.input.account.invoice.process"
_inherit = "edi.component.input.mixin"
_usage = "input.process.account.invoice"

def __init__(self, work_context):
super().__init__(work_context)
self.settings = self.type_settings.get("account_invoice_import", {})

def process(self):
wiz = self._setup_wizard()
res = wiz.import_invoice()
if wiz.state == "update" and wiz.invoice_id:
invoice = wiz.invoice_id
msg = _("Invoice has already been imported before")
self._handle_existing_invoice(invoice, msg)
raise UserError(msg)
else:
invoice_id = res["res_id"]
invoice = self.env["account.move"].browse(invoice_id)
if self._invoice_should_be_posted():
invoice.action_post()

Check warning on line 35 in edi_account_invoice_import/components/process.py

View check run for this annotation

Codecov / codecov/patch

edi_account_invoice_import/components/process.py#L35

Added line #L35 was not covered by tests
self.exchange_record.sudo()._set_related_record(invoice)
return _("Invoice %s created") % invoice.name
raise UserError(_("Something went wrong with the importing wizard."))

def _setup_wizard(self):
"""Init a `account.invoice.import` instance for current record."""
ctx = self.settings.get("wiz_ctx", {})
wiz = self.env["account.invoice.import"].with_context(**ctx).sudo().create({})
wiz.invoice_file = self.exchange_record._get_file_content(binary=False)
wiz.invoice_filename = self.exchange_record.exchange_filename
return wiz

def _invoice_should_be_posted(self):
return self.settings.get("post_invoice", False)

def _handle_existing_invoice(self, invoice, message):
prev_record = self._get_previous_record(invoice)
self.exchange_record.message_post_with_view(
"edi_account_invoice_import.message_already_imported",
values={
"invoice": invoice,
"prev_record": prev_record,
"message": message,
"level": "info",
},
subtype_id=self.env.ref("mail.mt_note").id,
)

def _get_previous_record(self, invoice):
return self.env["edi.exchange.record"].search(
[("model", "=", "account.move"), ("res_id", "=", invoice.id)], limit=1
)
47 changes: 47 additions & 0 deletions edi_account_invoice_import/i18n/edi_account_invoice_import.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * edi_account_invoice_import
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: edi_account_invoice_import
#: model_terms:ir.ui.view,arch_db:edi_account_invoice_import.message_already_imported
msgid "<strong>Invoice:</strong>"
msgstr ""

#. module: edi_account_invoice_import
#: model_terms:ir.ui.view,arch_db:edi_account_invoice_import.message_already_imported
msgid "<strong>Message:</strong>"
msgstr ""

#. module: edi_account_invoice_import
#: model_terms:ir.ui.view,arch_db:edi_account_invoice_import.message_already_imported
msgid "<strong>Previous record:</strong>"
msgstr ""

#. module: edi_account_invoice_import
#: code:addons/edi_account_invoice_import/components/process.py:0
#, python-format
msgid "Invoice %s created"
msgstr ""

#. module: edi_account_invoice_import
#: code:addons/edi_account_invoice_import/components/process.py:0
#, python-format
msgid "Invoice has already been imported before"
msgstr ""

#. module: edi_account_invoice_import
#: code:addons/edi_account_invoice_import/components/process.py:0
#, python-format
msgid "Something went wrong with the importing wizard."
msgstr ""
1 change: 1 addition & 0 deletions edi_account_invoice_import/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Lois Rilo <[email protected]>
17 changes: 17 additions & 0 deletions edi_account_invoice_import/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Plug account_invoice_import into EDI machinery.


Control invoice confirmation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can decide if the invoice should be posted by exchange type.

On your exchange type, go to advanced settings and add the following::

[...]
components:
process:
usage: input.process.account.invoice
[...]
account_invoice:
post_invoice: true
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading