Skip to content

[18.0][MIG] connector_ecommerce: Migration to 18.0 #83

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

Draft
wants to merge 86 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
58ea784
[CHG] rename 'base_sale_multichannels' to 'connector_ecommerce'
guewen Feb 19, 2013
9e37830
[ADD] Base support to export picking (partial and complete)
jgrandguillaume Mar 12, 2013
155c52a
[FIX] improve styling, remove unused imports, fix license (done by Joel)
guewen Mar 12, 2013
dd9bb2c
[ADD] Event to handle the adding of the tracking number on picking
jgrandguillaume Mar 13, 2013
2aa847a
[FIX] remove the carrier tracking number from the event, fix missing …
guewen Mar 13, 2013
aed4f0a
[ADD] Support for exporting the account_invoice to Magento
jgrandguillaume Mar 13, 2013
c74b2ed
[FIX] styling, license, imports, some fixes
guewen Mar 13, 2013
1ee8efe
[FIX] add product_view.xml file
bealdav Mar 14, 2013
9e7451a
[IMP] start adding support of onchange in connector-ecommerce
sebastienbeau Mar 13, 2013
2e19c36
[REF] code review
Mar 14, 2013
af28824
[IMP] code review
sebastienbeau Mar 14, 2013
b8b00b3
[IMP] play on change on sale.order and sale.order.lines in new framew…
gurneyalex Mar 15, 2013
80bb689
[FIX] wrong arguments in action_done
guewen Mar 18, 2013
fdcf3af
[ADD] 'Authorized' import rules to be able to import sales orders aut…
Jun 14, 2013
1e51403
[REF] started to use ConnectorUnit classes to add extra lines in sale…
guewen Jun 25, 2013
43f31dc
Fix a bug : remove special fields before database storage (avoid to t…
Jun 27, 2013
c230e77
[DEL] remove old stuff
guewen Jul 5, 2013
902e5e9
[IMP] - make possible to inherit the method _add_order_extra_line (do…
mathieuvatel Jul 15, 2013
58ff4c2
[FIX] indentation according to pep8
guewen Jul 15, 2013
c542c2f
Added "invoice validated" event and called upon "on_invoice_validate".
Aug 5, 2013
62cd2e5
[FIX] the onchange test had a TypeError, now it fails for some reason
guewen Aug 5, 2013
68cd0c1
[BUMP] release 2.1.0
guewen Jan 15, 2014
c2db2b2
[IMP] move product_normal_form_view in connector_base_product
bealdav Feb 4, 2014
0ed66ba
[FIX] product_view.xml in __openerp__.py
bealdav Feb 14, 2014
e90ebcf
The special sales orders lines can have a sequence and have low prior…
guewen Mar 31, 2014
7ea1fb2
[FIX] related_backorder_ids shoud not be linked with a new copy
rdeheele Apr 7, 2014
4e956be
rise the sequence of the special lines to reduce chances to be reache…
guewen Apr 9, 2014
c79a86d
[IMP] allow to override payment rules
bealdav Apr 25, 2014
b7b8f0f
Bump to version 2.2.0
guewen May 26, 2014
067ae88
set modules to not installable
guewen Jul 7, 2014
5afdff0
Add bug tracker link on README.rst
yvaucher May 22, 2015
756d10f
Trigger the change of price on the newly created product
guewen Jul 23, 2015
4acc323
[FIX] Bug throwing exception importing sale order
kikopeiro Aug 27, 2015
1d518b6
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
c85ce9d
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
615c8e9
[IMP] made module installable
parthiv Mar 18, 2016
b03bebc
Replace product.price.type by predefined fields
guewen Apr 12, 2016
51d7bdd
[FIX] changed to MVC structure
atchuthan May 12, 2016
9e12289
Remove account.tax.group, now exists in 'account'
guewen May 26, 2016
30c4323
[FIX] renamed filename to account_payment_mode
atchuthan May 27, 2016
afd9990
Capitalize products names for consistency
guewen May 27, 2016
d1f89c9
[FIX] removed duplicate line
parthiv Aug 24, 2016
f389cc7
Extract onchange fields for better extensibility
guewen Sep 8, 2016
113d9ba
[MIG] Make modules uninstallable
pedrobaeza Oct 6, 2016
23050c5
connector_ecommerce: Add security groups to avoid show information al…
sergio-teruel Jan 20, 2017
b077bbb
[MIG] Migration to 10.0
Nov 23, 2016
2431f79
[MIG] Migration to 10.0: Adapt code to 10.0
lmignon May 15, 2017
4b4ad45
fix message_post() expecting a len(recordset) == 1
guewen Jun 9, 2017
4820a7f
Fire new event: 'on_picking_dropship_done' when an 'incoming' shipmen…
jaredkipe Oct 21, 2017
55cb71b
Fix lint error introduced in #43
guewen Oct 30, 2017
d1068ca
[MIG] connector_ecommerce to V11
hugosantosred Feb 8, 2018
09f0f61
Connector Ecommerce to version 12
ljimenezsidoo Mar 20, 2019
4cc6447
Update connector_ecommerce/views/sale_view.xml
sebalix Apr 29, 2019
29f3a7e
Update connector_ecommerce/tests/test_picking_event.py
ljimenezsidoo May 31, 2019
d8a8bad
Update connector_ecommerce/tests/test_picking_event.py
ljimenezsidoo May 31, 2019
9bbdd3a
RMV rule_group from ecommerce data xml
Oct 15, 2019
1423bad
[IMP] connector_ecommerce: black, isort
HviorForgeFlow Mar 23, 2020
de92dd4
[MIG] connector_ecommerce: Migration to 13.0
HviorForgeFlow Mar 23, 2020
b6f83bb
[FIX]not exist field in model raise error so remove those before call…
bizzappdev Nov 23, 2020
a275ddd
[FIX]proper exception rule
bizzappdev Feb 4, 2021
e9f694a
[FIX]tax_id test case from plan onchange. (based on Company from orde…
bizzappdev Mar 8, 2021
34f8d15
[FIX]pre-commit
bizzappdev Mar 8, 2021
d9e1322
[FIX]remove not needed fields
bizzappdev Mar 9, 2021
eb2638d
[FIX] Fix action done
florian-dacosta Jan 3, 2021
6008576
[FIX] Fix Invoice validate notification
florian-dacosta Jan 14, 2021
6f7bc34
[FIX] Remove checkpoint as it has been removed from connector
florian-dacosta Apr 2, 2021
0b0d40d
[IMP] connector_ecommerce: black, isort, prettier
hailangvn May 16, 2021
270c197
[MIG] connector_ecommerce: Migration to 14.0
hailangvn May 16, 2021
a46aabc
[FIX] rule must be created as inactive as it could break standard beh…
Aug 19, 2021
4a2c87a
[FIX] connector_ecommerce: resolve error searching non-stored field
hailangvn Feb 24, 2022
dca0cf2
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 30, 2022
249fe14
[FIX] connector_ecommerce: remove obsoleted rule
hailangvn Apr 25, 2022
9eceafc
Missing env variable in openupgrade method call
StephaneMangin May 4, 2022
c8fa880
[MIG][15.0] connector_ecommerce: 15.0
flachica May 6, 2022
b9e0a91
[MIG] connector_ecommerce: Migration to 16.0
juliocabrerizo Oct 4, 2022
36a795b
[MIG] connector_ecommerce: FIX test
asierneiradev Jan 31, 2023
98e5b8e
[16.0][MIG] connector_ecommerce: adapt necessary changes for correct …
asierneiradev Mar 13, 2023
bf70cae
Translated using Weblate (Spanish)
SoniaViciana Jun 26, 2023
8bd6053
Translated using Weblate (Spanish)
Ivorra78 Jul 1, 2023
c007627
Translated using Weblate (Spanish)
Ivorra78 Oct 10, 2023
623a90e
[IMP] connector_ecommerce: pre-commit auto fixes
john-herholz-dt Jan 12, 2024
00efb8d
[MIG] connector_ecommerce: Migration to 17.0
john-herholz-dt Jan 12, 2024
b7f4cf8
[IMP] connector_ecommerce: pre-commit auto fixes
vvrossem Feb 12, 2025
bb09863
[MIG] connector_ecommerce: Migration to 18.0
vvrossem Feb 12, 2025
80fde91
[DO NOT MERGE] test-requirements.txt
vvrossem Feb 24, 2025
6c23ff8
connector_ecommerce: update _get_payment_method_domain signature
Ricardoalso Feb 28, 2025
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
117 changes: 117 additions & 0 deletions connector_ecommerce/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
========================
Connector for E-Commerce
========================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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%2Fconnector--ecommerce-lightgray.png?logo=github
:target: https://github.com/OCA/connector-ecommerce/tree/18.0/connector_ecommerce
:alt: OCA/connector-ecommerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/connector-ecommerce-18-0/connector-ecommerce-18-0-connector_ecommerce
: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/connector-ecommerce&target_branch=18.0
:alt: Try me on Runboat

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

This modules aims to be a common layer for the connectors dealing with
e-commerce.

It sits on top of the `connector <http://odoo-connector.com>`__
framework and is used by the e-commerce connectors, like
`magentoerpconnect <http://odoo-magento-connector.com>`__ or
`prestashoperpconnect <https://github.com/OCA/connector-prestashop>`__.

That's a technical module, which include amongst other things:

Events

On which the connectors can subscribe listeners. The events it adds
are:

- ``on_invoice_paid(self, record)``
- ``on_invoice_validated(self, record)``
- ``on_invoice_validated(self, record)``
- ``on_picking_out_done(self, record, method)`` where method is
'partial' or 'complete'
- ``on_tracking_number_added(self, record)``
- ``on_product_price_changed(self, record)``

Components

A piece of code which allows to play all the ``onchanges`` required
when we create a sales order.

Another one which allows to add special lines in imported sales
orders such as Shipping fees, Cash on Delivery or Discounts.

Data Model

Add structures shared for e-commerce connectors

**Table of contents**

.. contents::
:local:

Installation
============

This module is a dependency for more advanced connectors. It does
nothing on its own and there is no reason to install it alone.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector-ecommerce/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/connector-ecommerce/issues/new?body=module:%20connector_ecommerce%0Aversion:%2018.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
* Akretion

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

See
`contributors <https://github.com/OCA/connector-ecommerce/graphs/contributors>`__.

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.

This module is part of the `OCA/connector-ecommerce <https://github.com/OCA/connector-ecommerce/tree/18.0/connector_ecommerce>`_ 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 connector_ecommerce/__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
34 changes: 34 additions & 0 deletions connector_ecommerce/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# © 2013-2016 Camptocamp SA
# © 2013-2016 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "Connector for E-Commerce",
"version": "18.0.1.0.0",
"category": "Hidden",
"author": "Camptocamp,Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector-ecommerce",
"license": "AGPL-3",
"depends": [
# odoo
"stock_delivery",
# OCA/bank-payment
"account_payment_sale",
# OCA/connector
"connector_base_product",
# OCA/sale-workflow
"sale_exception",
],
"data": [
"security/security.xml",
"security/ir.model.access.csv",
"wizard/sale_ignore_cancel_view.xml",
"data/ecommerce_data.xml",
"views/sale_order.xml",
"views/account_move.xml",
"views/stock_picking.xml",
"views/account_journal.xml",
"views/account_payment_method_line.xml",
],
"installable": True,
}
2 changes: 2 additions & 0 deletions connector_ecommerce/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import line_builder
from . import sale_order_onchange
110 changes: 110 additions & 0 deletions connector_ecommerce/components/line_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# © 2013-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import models

from odoo.addons.component.core import Component


class SpecialOrderLineBuilder(Component):
"""Base class to build a sales order line for a sales order

Used when extra order lines have to be added in a sales order
but we only know some parameters (product, price, ...), for instance,
a line for the shipping costs or the gift coupons.

It can be subclassed to customize the way the lines are created.

Usage::

builder = self.components(usage='shipping.line.builder',
model_name='sale.order.line')
builder.price_unit = 100
builder.get_line()

"""

_name = "ecommerce.order.line.builder"
_inherit = "base.connector"
_usage = "order.line.builder"

def __init__(self, work_context):
super().__init__(work_context)
self.product = None # id or browse_record

Check warning on line 33 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L32-L33

Added lines #L32 - L33 were not covered by tests
# when no product_id, fallback to a product_ref
self.product_ref = None # tuple (module, xmlid)
self.price_unit = None
self.quantity = 1
self.sign = 1
self.sequence = 980

Check warning on line 39 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L35-L39

Added lines #L35 - L39 were not covered by tests

def get_line(self):
assert self.product_ref or self.product
assert self.price_unit is not None

Check warning on line 43 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L42-L43

Added lines #L42 - L43 were not covered by tests

product = self.product

Check warning on line 45 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L45

Added line #L45 was not covered by tests
if product is None:
product = self.env.ref(".".join(self.product_ref))

Check warning on line 47 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L47

Added line #L47 was not covered by tests

if not isinstance(product, models.BaseModel):
product = self.env["product.product"].browse(product)
return {

Check warning on line 51 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L50-L51

Added lines #L50 - L51 were not covered by tests
"product_id": product.id,
"name": product.name,
"product_uom": product.uom_id.id,
"product_uom_qty": self.quantity,
"price_unit": self.price_unit * self.sign,
"sequence": self.sequence,
}


class ShippingLineBuilder(Component):
"""Return values for a Shipping line"""

_name = "ecommerce.order.line.builder.shipping"
_inherit = "ecommerce.order.line.builder"
_usage = "order.line.builder.shipping"

def __init__(self, work_context):
super().__init__(work_context)
self.product_ref = ("connector_ecommerce", "product_product_shipping")
self.sequence = 999

Check warning on line 71 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L69-L71

Added lines #L69 - L71 were not covered by tests

def get_line(self):
values = super().get_line()
values["is_delivery"] = True
return values

Check warning on line 76 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L74-L76

Added lines #L74 - L76 were not covered by tests


class CashOnDeliveryLineBuilder(Component):
"""Return values for a Cash on Delivery line"""

_name = "ecommerce.order.line.builder.cod"
_inherit = "ecommerce.order.line.builder"
_usage = "order.line.builder.cod"

def __init__(self, work_context):
super().__init__(work_context)
self.product_ref = ("connector_ecommerce", "product_product_cash_on_delivery")
self.sequence = 995

Check warning on line 89 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L87-L89

Added lines #L87 - L89 were not covered by tests


class GiftOrderLineBuilder(Component):
"""Return values for a Gift line"""

_name = "ecommerce.order.line.builder.gift"
_inherit = "ecommerce.order.line.builder"
_usage = "order.line.builder.gift"

def __init__(self, work_context):
super().__init__(work_context)
self.product_ref = ("connector_ecommerce", "product_product_gift")
self.sign = -1
self.gift_code = None
self.sequence = 990

Check warning on line 104 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L100-L104

Added lines #L100 - L104 were not covered by tests

def get_line(self):
line = super().get_line()

Check warning on line 107 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L107

Added line #L107 was not covered by tests
if self.gift_code:
line["name"] = "{} [{}]".format(line["name"], self.gift_code)
return line

Check warning on line 110 in connector_ecommerce/components/line_builder.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/line_builder.py#L109-L110

Added lines #L109 - L110 were not covered by tests
111 changes: 111 additions & 0 deletions connector_ecommerce/components/sale_order_onchange.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# © 2013-TODAY Akretion (Sébastien Beau)
# © 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo.addons.component.core import Component


class OnChangeManager(Component):
_name = "ecommerce.onchange.manager"
_inherit = "base.connector"

def get_new_values(self, record, on_change_result, model=None):
vals = on_change_result.get("value", {})
new_values = {}

Check warning on line 14 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L13-L14

Added lines #L13 - L14 were not covered by tests
for fieldname, value in vals.items():
if fieldname not in record:
if model:
column = self.env[model]._fields[fieldname]

Check warning on line 18 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L18

Added line #L18 was not covered by tests
if column.type == "many2one":
value = value["id"]
new_values[fieldname] = value
return new_values

Check warning on line 22 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L20-L22

Added lines #L20 - L22 were not covered by tests

def play_onchanges(self, model, values, onchange_fields):
model = self.env[model]
field_spec = model._get_fields_spec()

Check warning on line 26 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L25-L26

Added lines #L25 - L26 were not covered by tests
# we need all fields in the dict even the empty ones
# otherwise 'onchange()' will not apply changes to them
all_values = {k: v for k, v in values.items() if k in model._fields}
not_values = {k: v for k, v in values.items() if k not in model._fields}

Check warning on line 30 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L29-L30

Added lines #L29 - L30 were not covered by tests
for field in model._fields:
if field not in all_values:
all_values[field] = False

Check warning on line 33 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L33

Added line #L33 was not covered by tests

# we work on a temporary record
new_record = model.new(all_values)

Check warning on line 36 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L36

Added line #L36 was not covered by tests

new_values = {}

Check warning on line 38 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L38

Added line #L38 was not covered by tests
for field in onchange_fields:
onchange_values = new_record.onchange(all_values, [field], field_spec)
new_values.update(

Check warning on line 41 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L40-L41

Added lines #L40 - L41 were not covered by tests
self.get_new_values(values, onchange_values, model=model._name)
)
all_values.update(new_values)

Check warning on line 44 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L44

Added line #L44 was not covered by tests

for fld in not_values:
if fld not in all_values:
all_values[fld] = not_values[fld]
res = {f: v for f, v in all_values.items() if f in values or f in new_values}
return res

Check warning on line 50 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L48-L50

Added lines #L48 - L50 were not covered by tests


class SaleOrderOnChange(Component):
_name = "ecommerce.onchange.manager.sale.order"
_inherit = "ecommerce.onchange.manager"
_usage = "ecommerce.onchange.manager.sale.order"

order_onchange_fields = ["partner_id"]

line_onchange_fields = ["order_id", "product_id"]

def play(self, order, order_lines):
"""Play the onchange of the sales order and it's lines

:param order: sales order values
:type: dict
:param order_lines: data of the sales order lines
:type: list of dict

:return: the sales order updated by the onchanges
:rtype: dict
"""
# play onchange on sales order
order = self.play_onchanges("sale.order", order, self.order_onchange_fields)

Check warning on line 74 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L74

Added line #L74 was not covered by tests

# play onchange on sales order line
processed_order_lines = []
line_lists = [order_lines]

Check warning on line 78 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L77-L78

Added lines #L77 - L78 were not covered by tests
if "order_line" in order and order["order_line"] is not order_lines:
# we have both backend-dependent and oerp-native order lines.
# oerp-native lines can have been added to map
# shipping fees with an Odoo Product
line_lists.append(order["order_line"])

Check warning on line 83 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L83

Added line #L83 was not covered by tests

for line_list in line_lists:
for idx, command_line in enumerate(line_list):
# line_list format:[(0, 0, {...}), (0, 0, {...})]
if command_line[0] in (0, 1): # create or update values
# we work on a temporary record
order_model = self.env["sale.order"]

Check warning on line 90 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L90

Added line #L90 was not covered by tests

all_values = {

Check warning on line 92 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L92

Added line #L92 was not covered by tests
k: v for k, v in order.items() if k in order_model._fields
}
for field in order_model._fields:
if field not in all_values:
all_values[field] = False
new_record = order_model.new(all_values)

Check warning on line 98 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L97-L98

Added lines #L97 - L98 were not covered by tests
# keeps command number and ID (or 0)
old_line_data = command_line[2]

Check warning on line 100 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L100

Added line #L100 was not covered by tests
# passing order_id also so order_id.company_id based onchange will
# also work
old_line_data["order_id"] = new_record
new_line_data = self.play_onchanges(

Check warning on line 104 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L103-L104

Added lines #L103 - L104 were not covered by tests
"sale.order.line", old_line_data, self.line_onchange_fields
)
new_line = (command_line[0], command_line[1], new_line_data)
processed_order_lines.append(new_line)

Check warning on line 108 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L107-L108

Added lines #L107 - L108 were not covered by tests
# in place modification of the sales order line in the list
line_list[idx] = new_line
return order

Check warning on line 111 in connector_ecommerce/components/sale_order_onchange.py

View check run for this annotation

Codecov / codecov/patch

connector_ecommerce/components/sale_order_onchange.py#L110-L111

Added lines #L110 - L111 were not covered by tests
Loading
Loading