Skip to content

Commit

Permalink
[MIG] sale_order_import: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
duongtq committed Sep 26, 2023
1 parent 418d7df commit 23dd7a7
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 113 deletions.
15 changes: 8 additions & 7 deletions sale_order_import/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Sale Order Import
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:35292a110f9d19dbd36bec18d748fcca76a94b2a97a60d0fe563c00d4078493f
!! source digest: sha256:488cfb728bd029ca722e0084a281dfd3772ad7bd8237142ac2629be32c2493a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Sale Order Import
: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/sale_order_import
:target: https://github.com/OCA/edi/tree/16.0/sale_order_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-sale_order_import
:target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-sale_order_import
: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
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -57,7 +57,7 @@ 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:%20sale_order_import%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20sale_order_import%0Aversion:%2016.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.

Expand All @@ -77,11 +77,12 @@ Contributors
* Dennis Sluijk <[email protected]>
* Andrea Stirpe <[email protected]>
* Simone Orsi <[email protected]>
* Duong (Tran Quoc) <[email protected]>

Other credits
~~~~~~~~~~~~~

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

Maintainers
~~~~~~~~~~~
Expand All @@ -96,6 +97,6 @@ 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.

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion sale_order_import/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Sale Order Import",
"version": "14.0.1.5.0",
"version": "16.0.1.0.0",
"category": "Sales Management",
"license": "AGPL-3",
"summary": "Import RFQ or sale orders from files",
Expand Down
7 changes: 4 additions & 3 deletions sale_order_import/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def name_get(self):
# I didn't find a python method to easily display
# a float + currency symbol (before or after)
# depending on lang of context and currency
name += _(" Amount w/o tax: %s %s)") % (
sale.amount_untaxed,
sale.currency_id.name,
name += _(
" Amount w/o tax: %(amount)s %(currency)s",
amount=sale.amount_untaxed,
currency=sale.currency_id.name,
)
new_res.append((sale_id, name))
return new_res
Expand Down
1 change: 1 addition & 0 deletions sale_order_import/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
* Dennis Sluijk <[email protected]>
* Andrea Stirpe <[email protected]>
* Simone Orsi <[email protected]>
* Duong (Tran Quoc) <[email protected]>
2 changes: 1 addition & 1 deletion sale_order_import/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp
The migration of this module from 13.0 to 16.0 was financially supported by Camptocamp
47 changes: 24 additions & 23 deletions sale_order_import/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Sale Order Import</title>
<style type="text/css">

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

Expand Down Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Sale Order Import</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:35292a110f9d19dbd36bec18d748fcca76a94b2a97a60d0fe563c00d4078493f
!! source digest: sha256:488cfb728bd029ca722e0084a281dfd3772ad7bd8237142ac2629be32c2493a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/edi/tree/14.0/sale_order_import"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-sale_order_import"><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/edi&amp;target_branch=14.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" 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" 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" href="https://github.com/OCA/edi/tree/16.0/sale_order_import"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-sale_order_import"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/edi&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds support for the import of electronic RFQ or orders. This module provides the base methods to import electronic orders ; it requires additional modules to support specific order formats:</p>
<ul class="simple">
<li>module <em>sale_order_import_csv</em>: adds support for CSV orders,</li>
Expand All @@ -382,61 +382,62 @@ <h1 class="title">Sale Order Import</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-6">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id6">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>This module adds a wizard in the sale menu named <em>Import RFQ or Order</em>. This wizard will propose you to select the order or RFQ file. Depending on the format of the file (CSV, XML or PDF) and the type of file (RFQ or order), it may propose you additional options.</p>
<p>When you import an order, if there is a quotation in Odoo for the same customer, the wizard will propose you to either update the existing quotation or create a new order (in fact, it will create a new quotation, so that you are free to make some modifications before you click on the <em>Confirm Sale</em> button to convert the quotation to a sale order).</p>
<p>Once the RFQ/order is imported, you should read the messages in the chatter of the quotation because it may contain important information about the import.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20sale_order_import%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20sale_order_import%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
<li>Dennis Sluijk &lt;<a class="reference external" href="mailto:d.sluijk&#64;onestein.nl">d.sluijk&#64;onestein.nl</a>&gt;</li>
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
<li>Duong (Tran Quoc) &lt;<a class="reference external" href="mailto:duongtq&#64;trobz.com">duongtq&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
<p>The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp</p>
<h2><a class="toc-backref" href="#id6">Other credits</a></h2>
<p>The migration of this module from 13.0 to 16.0 was financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/14.0/sale_order_import">OCA/edi</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/16.0/sale_order_import">OCA/edi</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions sale_order_import/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import base64
import os

from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase


class TestCommon(SavepointCase):
class TestCommon(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
33 changes: 13 additions & 20 deletions sale_order_import/tests/test_parse_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# @author: Simone Orsi <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import base64
from unittest import mock

import mock
from lxml import etree

from odoo import exceptions
Expand All @@ -29,23 +29,14 @@ def test_onchange_validation_not_supported(self):
# Test it gets called (cannot do it w/ Form)
mock_file_msg = mock.patch.object(type(self.wiz_model), "_unsupported_file_msg")
with mock_file_msg as mocked:
with Form(self.wiz_model) as form:
form.order_filename = "test.omg"
with Form(
self.wiz_model.with_context(default_order_filename="test.omg")
) as form:
form.order_file = "00100000"
self.assertFalse(form.csv_import)
self.assertFalse(form.doc_type)
mocked.assert_called()

def test_onchange_validation_csv(self):
csv_data = base64.b64encode(b"id,name\n,1,Foo")

with Form(self.wiz_model) as form:
form.partner_id = self.partner # required by the view if CSV is set
form.order_filename = "test.csv"
form.order_file = csv_data
self.assertTrue(form.csv_import)
self.assertFalse(form.doc_type)

def test_onchange_validation_xml(self):
xml_data = base64.b64encode(
b"<?xml version='1.0' encoding='utf-8'?><root><foo>baz</foo></root>"
Expand All @@ -54,8 +45,9 @@ def test_onchange_validation_xml(self):
# Simulate bad file handling
mock_parse_xml = mock.patch.object(type(self.wiz_model), "_parse_xml")

with Form(self.wiz_model) as form:
form.order_filename = "test.xml"
with Form(
self.wiz_model.with_context(default_order_filename="test.xml")
) as form:
with mock_parse_xml as mocked:
mocked.return_value = ("", "I don't like this file")
with self.assertRaisesRegex(
Expand All @@ -66,8 +58,9 @@ def test_onchange_validation_xml(self):

mock_parse_order = mock.patch.object(type(self.wiz_model), "parse_xml_order")

with Form(self.wiz_model) as form:
form.order_filename = "test.xml"
with Form(
self.wiz_model.with_context(default_order_filename="test.xml")
) as form:
with mock_parse_order as mocked:
mocked.return_value = "rfq"
form.order_file = xml_data
Expand All @@ -79,9 +72,9 @@ def test_onchange_validation_pdf(self):
pdf_data = self.read_test_file("test.pdf", mode="rb", as_b64=True)
mock_parse_order = mock.patch.object(type(self.wiz_model), "parse_pdf_order")

with Form(self.wiz_model) as form:
# form.partner_id = self.partner # required by the view if CSV is set
form.order_filename = "test.pdf"
with Form(
self.wiz_model.with_context(default_order_filename="test.pdf")
) as form:
with mock_parse_order as mocked:
mocked.return_value = "rfq"
form.order_file = pdf_data
Expand Down
11 changes: 6 additions & 5 deletions sale_order_import/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase


class TestOrderImport(SavepointCase):
class TestOrderImport(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

def test_name_get(self):
sale_order = self.env.ref("sale.sale_order_1")
name = sale_order.name + _(" Amount w/o tax: %s %s)") % (
sale_order.amount_untaxed,
sale_order.currency_id.name,
name = sale_order.name + _(
" Amount w/o tax: %(amount)s %(currency)s",
amount=sale_order.amount_untaxed,
currency=sale_order.currency_id.name,
)
so = self.env["sale.order"].with_context(sale_order_show_amount=True)
name_get_res = so.search([("id", "=", sale_order.id)]).name_get()
Expand Down
Loading

0 comments on commit 23dd7a7

Please sign in to comment.