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

[14.0][BPRT] edi_sale_oca: Backport from v16.0 #1023

Merged
merged 30 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7a12d78
Add edi_sale_oca
simahawk Aug 2, 2022
4ee531f
edi_sale: take over edi_sale_order_import
simahawk Aug 14, 2022
d86e9a2
edi_sale: filter/group by origin
simahawk Sep 2, 2022
e55c2f8
edi_sale: handle ext ref for sol
simahawk Sep 14, 2022
7111831
edi_sale: show edi_id
simahawk May 15, 2023
8053611
edi_sale: store metadata
simahawk May 18, 2023
b502b3f
edi_sale: clean file and drop *type_auto dependency
simahawk May 19, 2023
e07c9cc
edi_sale: add process hook for order create
simahawk May 19, 2023
24ec539
edi_sale: process propagate edi origin
simahawk May 19, 2023
482b148
edi_sale: add edi_exchange_ready
simahawk May 23, 2023
9a86b11
edi_sale: fix edi disable flag
simahawk May 26, 2023
da06fa3
edi_sale: fix _edi_exchange_ready for qty=0
simahawk Jul 6, 2023
f6f078e
edi_sale: move OrderMixin from edi_sale_ubl
simahawk Aug 7, 2023
48a81f0
edi_sale: fix test_process
simahawk Aug 7, 2023
35ec71e
edi_sale: propagate origin on lines
simahawk Aug 7, 2023
b1f710e
[MIG] edi_sale_oca: Migration to 16.0
Oct 18, 2023
c203284
[IMP] edi_sale_oca: Support edi_id for edi_sale_edifact_oca
Oct 18, 2023
48c754b
[IMP] edi_sale_oca: Refactor code for passing all configurations via …
Oct 26, 2023
01469d8
[UPD] Update edi_sale_oca.pot
Nov 21, 2023
fd73801
[BOT] post-merge updates
OCA-git-bot Nov 21, 2023
d61c20d
[IMP] edi_oca: add partner form page
Jan 10, 2024
ccac2c9
[UPD] Update edi_sale_oca.pot
Jan 15, 2024
c24da23
[BOT] post-merge updates
OCA-git-bot Jan 15, 2024
9f86a3f
[FIX] edi_sale_oca: fix test
Jan 22, 2024
efbc5cd
[UPD] Update edi_sale_oca.pot
Jan 31, 2024
25bf865
[BOT] post-merge updates
OCA-git-bot Jan 31, 2024
4956da6
[UPD] Update edi_sale_oca.pot
Feb 4, 2024
1195ead
Added translation using Weblate (Italian)
mymage May 13, 2024
bd3e057
[BPRT] edi_sale_oca: Backport from v16.0
thienvh332 Jun 27, 2024
d4dd854
[IMP] edi_sale_oca: add partner form page
thienvh332 Jul 4, 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
122 changes: 122 additions & 0 deletions edi_sale_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
=========
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-lightgray.png?logo=github
:target: https://github.com/OCA/edi/tree/14.0/edi_sale_oca
: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_sale_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&target_branch=14.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/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/issues/new?body=module:%20edi_sale_oca%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
~~~~~~~

* Camptocamp

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

* Simone Orsi <simone.orsi@camptocamp.com>
* Duong (Tran Quoc) <duongtq@trobz.com>
* Thien (Vo Hong) <thienvh@trobz.com>

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 <https://github.com/OCA/edi/tree/14.0/edi_sale_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_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
27 changes: 27 additions & 0 deletions edi_sale_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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": "14.0.1.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"author": "Camptocamp,Odoo Community Association (OCA)",
"maintainers": ["simahawk"],
"website": "https://github.com/OCA/edi",
"depends": [
"edi_oca",
"edi_record_metadata_oca",
"sale_order_import",
],
"data": [
"data/job_function.xml",
"views/res_partner.xml",
"views/sale_order.xml",
"views/edi_exchange_record.xml",
"templates/exchange_chatter_msg.xml",
],
}
1 change: 1 addition & 0 deletions edi_sale_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import process
79 changes: 79 additions & 0 deletions edi_sale_oca/components/process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2021 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# 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

@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")

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_view(
"edi_sale_oca.message_already_imported",
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_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