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

[17.0][MIG] edi_sale_oca: Migration and Split of code #120

Open
wants to merge 31 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3699938
Add edi_sale_oca
simahawk Aug 2, 2022
2191f85
edi_sale: take over edi_sale_order_import
simahawk Aug 14, 2022
b1c8309
edi_sale: filter/group by origin
simahawk Sep 2, 2022
af90548
edi_sale: handle ext ref for sol
simahawk Sep 14, 2022
f74d0e5
edi_sale: show edi_id
simahawk May 15, 2023
385f1f5
edi_sale: store metadata
simahawk May 18, 2023
c47a55e
edi_sale: clean file and drop *type_auto dependency
simahawk May 19, 2023
464620b
edi_sale: add process hook for order create
simahawk May 19, 2023
d90249f
edi_sale: process propagate edi origin
simahawk May 19, 2023
759245e
edi_sale: add edi_exchange_ready
simahawk May 23, 2023
f03a9c7
edi_sale: fix edi disable flag
simahawk May 26, 2023
e168602
edi_sale: fix _edi_exchange_ready for qty=0
simahawk Jul 6, 2023
425265f
edi_sale: move OrderMixin from edi_sale_ubl
simahawk Aug 7, 2023
ecf00d5
edi_sale: fix test_process
simahawk Aug 7, 2023
58b10df
edi_sale: propagate origin on lines
simahawk Aug 7, 2023
a1d83c7
[MIG] edi_sale_oca: Migration to 16.0
Oct 18, 2023
39a78ce
[IMP] edi_sale_oca: Support edi_id for edi_sale_edifact_oca
Oct 18, 2023
17b58a6
[IMP] edi_sale_oca: Refactor code for passing all configurations via …
Oct 26, 2023
2af0c59
[UPD] Update edi_sale_oca.pot
Nov 21, 2023
21ee19c
[BOT] post-merge updates
OCA-git-bot Nov 21, 2023
5d950c9
[IMP] edi_oca: add partner form page
Jan 10, 2024
0d2c5df
[UPD] Update edi_sale_oca.pot
Jan 15, 2024
e4532b7
[BOT] post-merge updates
OCA-git-bot Jan 15, 2024
f3426b7
[FIX] edi_sale_oca: fix test
Jan 22, 2024
bddf1e6
[UPD] Update edi_sale_oca.pot
Jan 31, 2024
294241a
[BOT] post-merge updates
OCA-git-bot Jan 31, 2024
a1e39a5
[UPD] Update edi_sale_oca.pot
Feb 4, 2024
382536c
Added translation using Weblate (Italian)
mymage May 13, 2024
e77919d
Translated using Weblate (Italian)
mymage Sep 10, 2024
e86a91b
[MIG] edi_sale_import_oca: Migration to 17.0
etobella Oct 28, 2024
0d5a1a0
[MIG] edi_sale_oca: Migration to 17.0
etobella Oct 28, 2024
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
126 changes: 126 additions & 0 deletions edi_sale_import_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
=========
EDI Sales
=========

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2b4f89b88e7d4e87c5a1249801ac1225c3c3e33b7c21ecd3f3eeb66e9e38f2da
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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--framework-lightgray.png?logo=github
:target: https://github.com/OCA/edi-framework/tree/17.0/edi_sale_import_oca
:alt: OCA/edi-framework
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-framework-17-0/edi-framework-17-0-edi_sale_import_oca
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi-framework&target_branch=17.0
:alt: Try me on Runboat

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

Inbound
-------

Receive sale orders from EDI channels.

Control sale order confirmation
-------------------------------

You can decide if the order should be confirmed by exchange type.

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

::

[...]
components:
process:
usage: input.process.sale.order
env_ctx:
# Values for the wizard
default_confirm_order: true
default_price_source: order
# Custom keys, whatever you need
random_one: true

Note that env_ctx will propagate all keys to the whole env so you can
use it for any kind of context related configuration. In the case of the
sale order import wizard here we are just passing defaults as we could
do in odoo standard.

TODO: shall we add an exchange type example as demo?

.. 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-framework/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/edi-framework/issues/new?body=module:%20edi_sale_import_oca%0Aversion:%2017.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
-------

* Camptocamp

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

- Simone Orsi <[email protected]>
- Duong (Tran Quoc) <[email protected]>

Other credits
-------------

The migration of this module from 14.0 to 16.0 was financially supported
by Camptocamp.

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-simahawk| image:: https://github.com/simahawk.png?size=40px
:target: https://github.com/simahawk
:alt: simahawk

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

|maintainer-simahawk|

This module is part of the `OCA/edi-framework <https://github.com/OCA/edi-framework/tree/17.0/edi_sale_import_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions edi_sale_import_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import components
from . import models
from . import wizard
26 changes: 26 additions & 0 deletions edi_sale_import_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "EDI Sales",
"summary": """
Configuration and special behaviors for EDI on sales.
""",
"version": "17.0.1.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"author": "Camptocamp,Odoo Community Association (OCA)",
"maintainers": ["simahawk"],
"website": "https://github.com/OCA/edi-framework",
"depends": [
"edi_sale_oca",
"edi_record_metadata_oca",
"sale_order_import",
],
"data": [
"data/job_function.xml",
"views/sale_order.xml",
"views/edi_exchange_record.xml",
"templates/exchange_chatter_msg.xml",
],
}
1 change: 1 addition & 0 deletions edi_sale_import_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import process
84 changes: 84 additions & 0 deletions edi_sale_import_oca/components/process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2021 Camptocamp SA
# @author: Simone Orsi <[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 sale orders."""

_name = "edi.input.sale.order.process"
_inherit = "edi.component.input.mixin"
_usage = "input.process.sale.order"

def process(self):
wiz = self._setup_wizard()
res = wiz.import_order_button()
# TODO: log debug
if wiz.state == "update" and wiz.sale_id:
order = wiz.sale_id
msg = self.msg_order_existing_error
self._handle_existing_order(order, msg)
raise UserError(msg)
else:
order = self._handle_create_order(res["res_id"])
return self.msg_order_created % order.name
raise UserError(self.msg_generic_error)

@property
def msg_order_existing_error(self):
return _("Sales order has already been imported before")

@property
def msg_order_created(self):
return _("Sales order %s created")

@property
def msg_generic_error(self):
return _("Something went wrong with the importing wizard.")

def _setup_wizard(self):
"""Init a `sale.order.import` instance for current record."""
# Set the right EDI origin on both order and lines
edi_defaults = {"origin_exchange_record_id": self.exchange_record.id}
addtional_ctx = dict(
sale_order_import__default_vals=dict(order=edi_defaults, lines=edi_defaults)
)
wiz = (
self.env["sale.order.import"]
.with_context(**addtional_ctx)
.sudo()
.create({})
)
wiz.order_file = self.exchange_record._get_file_content(binary=False)
wiz.order_filename = self.exchange_record.exchange_filename
wiz.order_file_change()
return wiz

def _handle_create_order(self, order_id):
order = self.env["sale.order"].browse(order_id)
self.exchange_record._set_related_record(order)
return order

def _handle_existing_order(self, order, message):
prev_record = self._get_previous_record(order)
self.exchange_record.message_post_with_source(
"edi_sale_import_oca.message_already_imported",
render_values={
"order": order,
"prev_record": prev_record,
"message": message,
"level": "info",
},
subtype_id=self.env.ref("mail.mt_note").id,
)

def _get_previous_record(self, order):
return self.env["edi.exchange.record"].search(
[("model", "=", "sale.order"), ("res_id", "=", order.id)], limit=1
)
7 changes: 7 additions & 0 deletions edi_sale_import_oca/data/job_function.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<odoo noupdate="1">
<record id="job_fun_auto_handle" model="queue.job.function">
<field name="model_id" ref="sale.model_sale_order" />
<field name="method">_edi_auto_handle_generate</field>
<field name="channel_id" ref="edi_oca.channel_edi_exchange" />
</record>
</odoo>
Loading
Loading