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

[MIG][17.0] connector_ecommerce: Migration to 17.0 #80

Open
wants to merge 89 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
89 commits
Select commit Hold shift + click to select a range
e0c86c2
[CHG] rename 'base_sale_multichannels' to 'connector_ecommerce'
guewen Feb 19, 2013
d26b626
[ADD] Base support to export picking (partial and complete)
jgrandguillaume Mar 12, 2013
527022a
[FIX] improve styling, remove unused imports, fix license (done by Joel)
guewen Mar 12, 2013
a023038
[ADD] Event to handle the adding of the tracking number on picking
jgrandguillaume Mar 13, 2013
8784181
[FIX] remove the carrier tracking number from the event, fix missing …
guewen Mar 13, 2013
a4e7d01
[ADD] Support for exporting the account_invoice to Magento
jgrandguillaume Mar 13, 2013
fba7eab
[FIX] styling, license, imports, some fixes
guewen Mar 13, 2013
7430b95
[FIX] add product_view.xml file
bealdav Mar 14, 2013
f7d1939
[IMP] start adding support of onchange in connector-ecommerce
sebastienbeau Mar 13, 2013
3196388
[REF] code review
Mar 14, 2013
1bcfecb
[IMP] code review
sebastienbeau Mar 14, 2013
55ea19b
[IMP] play on change on sale.order and sale.order.lines in new framew…
gurneyalex Mar 15, 2013
92e71bd
[FIX] wrong arguments in action_done
guewen Mar 18, 2013
444c787
[ADD] 'Authorized' import rules to be able to import sales orders aut…
Jun 14, 2013
8912e4d
[REF] started to use ConnectorUnit classes to add extra lines in sale…
guewen Jun 25, 2013
47664a9
Fix a bug : remove special fields before database storage (avoid to t…
Jun 27, 2013
b95ef06
[DEL] remove old stuff
guewen Jul 5, 2013
a250b83
[IMP] - make possible to inherit the method _add_order_extra_line (do…
mathieuvatel Jul 15, 2013
27a6434
[FIX] indentation according to pep8
guewen Jul 15, 2013
3c91031
Added "invoice validated" event and called upon "on_invoice_validate".
Aug 5, 2013
1057c8e
[FIX] the onchange test had a TypeError, now it fails for some reason
guewen Aug 5, 2013
f4613d9
[BUMP] release 2.1.0
guewen Jan 15, 2014
cc338c0
[IMP] move product_normal_form_view in connector_base_product
bealdav Feb 4, 2014
7824c1e
[FIX] product_view.xml in __openerp__.py
bealdav Feb 14, 2014
a8d7698
The special sales orders lines can have a sequence and have low prior…
guewen Mar 31, 2014
c7811bb
[FIX] related_backorder_ids shoud not be linked with a new copy
rdeheele Apr 7, 2014
9c3d2fd
rise the sequence of the special lines to reduce chances to be reache…
guewen Apr 9, 2014
8652e7c
[IMP] allow to override payment rules
bealdav Apr 25, 2014
05fa15c
Bump to version 2.2.0
guewen May 26, 2014
48ce15d
set modules to not installable
guewen Jul 7, 2014
31d72d6
Add bug tracker link on README.rst
yvaucher May 22, 2015
e3aef2d
Trigger the change of price on the newly created product
guewen Jul 23, 2015
ddc3135
[FIX] Bug throwing exception importing sale order
kikopeiro Aug 27, 2015
fdaecba
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
c698507
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
cc0bdd4
[IMP] made module installable
parthiv Mar 18, 2016
254e3a2
Replace product.price.type by predefined fields
guewen Apr 12, 2016
2f2d467
[FIX] changed to MVC structure
atchuthan May 12, 2016
aad8f8d
Remove account.tax.group, now exists in 'account'
guewen May 26, 2016
79b5dbd
[FIX] renamed filename to account_payment_mode
atchuthan May 27, 2016
3dd78c3
Capitalize products names for consistency
guewen May 27, 2016
037eb86
[FIX] removed duplicate line
parthiv Aug 24, 2016
5a73a6c
Extract onchange fields for better extensibility
guewen Sep 8, 2016
52349d9
[MIG] Make modules uninstallable
pedrobaeza Oct 6, 2016
043846c
connector_ecommerce: Add security groups to avoid show information al…
sergio-teruel Jan 20, 2017
a697c3a
[MIG] Migration to 10.0
Nov 23, 2016
b72257f
[MIG] Migration to 10.0: Adapt code to 10.0
lmignon May 15, 2017
f72d727
fix message_post() expecting a len(recordset) == 1
guewen Jun 9, 2017
9c17855
Fire new event: 'on_picking_dropship_done' when an 'incoming' shipmen…
jaredkipe Oct 21, 2017
519bed4
Fix lint error introduced in #43
guewen Oct 30, 2017
caa3b08
[MIG] connector_ecommerce to V11
hugosantosred Feb 8, 2018
5856f7d
Connector Ecommerce to version 12
ljimenezsidoo Mar 20, 2019
0d01132
Update connector_ecommerce/views/sale_view.xml
sebalix Apr 29, 2019
bbf5b5a
Update connector_ecommerce/tests/test_picking_event.py
ljimenezsidoo May 31, 2019
ca40fc1
Update connector_ecommerce/tests/test_picking_event.py
ljimenezsidoo May 31, 2019
39fd063
RMV rule_group from ecommerce data xml
Oct 15, 2019
fa3e775
[IMP] connector_ecommerce: black, isort
HviorForgeFlow Mar 23, 2020
40a126e
[MIG] connector_ecommerce: Migration to 13.0
HviorForgeFlow Mar 23, 2020
c218dab
[FIX]not exist field in model raise error so remove those before call…
bizzappdev Nov 23, 2020
33ab710
[FIX]proper exception rule
bizzappdev Feb 4, 2021
9469507
[FIX]tax_id test case from plan onchange. (based on Company from orde…
bizzappdev Mar 8, 2021
faf2f9e
[FIX]pre-commit
bizzappdev Mar 8, 2021
efcddb6
[FIX]remove not needed fields
bizzappdev Mar 9, 2021
6b3f3b7
[FIX] Fix action done
florian-dacosta Jan 3, 2021
ace1450
[FIX] Fix Invoice validate notification
florian-dacosta Jan 14, 2021
8869de7
[FIX] Remove checkpoint as it has been removed from connector
florian-dacosta Apr 2, 2021
3d0bcf9
[IMP] connector_ecommerce: black, isort, prettier
hailangvn May 16, 2021
20e84a2
[MIG] connector_ecommerce: Migration to 14.0
hailangvn May 16, 2021
553dc41
[FIX] rule must be created as inactive as it could break standard beh…
Aug 19, 2021
8e717e2
[FIX] connector_ecommerce: resolve error searching non-stored field
hailangvn Feb 24, 2022
b788ab0
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 30, 2022
a369855
[FIX] connector_ecommerce: remove obsoleted rule
hailangvn Apr 25, 2022
94a4469
Missing env variable in openupgrade method call
StephaneMangin May 4, 2022
1609b7d
[MIG][15.0] connector_ecommerce: 15.0
flachica May 6, 2022
0e3c325
[MIG] connector_ecommerce: Migration to 16.0
juliocabrerizo Oct 4, 2022
9cc0c10
[MIG] connector_ecommerce: FIX test
asierneiradev Jan 31, 2023
89d14f4
[16.0][MIG] connector_ecommerce: adapt necessary changes for correct …
asierneiradev Mar 13, 2023
ca8db89
[UPD] Update connector_ecommerce.pot
Apr 18, 2023
2cf8c0c
[UPD] README.rst
OCA-git-bot Apr 18, 2023
c169bf5
Update translation files
weblate Apr 18, 2023
9784ca6
Translated using Weblate (Spanish)
SoniaViciana Jun 26, 2023
0916615
Translated using Weblate (Spanish)
Ivorra78 Jul 1, 2023
6cb7368
[UPD] README.rst
OCA-git-bot Sep 3, 2023
f696a49
Update translation files
weblate Oct 10, 2023
16c1520
Translated using Weblate (Spanish)
Ivorra78 Oct 10, 2023
4bb4131
[IMP] connector_ecommerce: pre-commit auto fixes
john-herholz-dt Jan 12, 2024
627d70d
[MIG] connector_ecommerce: Migration to 17.0
john-herholz-dt Jan 12, 2024
30db326
[DON'T MERGE] test-requirements.txt
john-herholz-dt Jan 12, 2024
baaa2cd
run tests
john-herholz-dt Aug 18, 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
123 changes: 123 additions & 0 deletions connector_ecommerce/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
========================
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/17.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-17-0/connector-ecommerce-17-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=17.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:%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
* Akretion

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

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

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

The migration of this module from 13.0 to 14.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.

This module is part of the `OCA/connector-ecommerce <https://github.com/OCA/connector-ecommerce/tree/17.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
30 changes: 30 additions & 0 deletions connector_ecommerce/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# © 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": "17.0.1.0.0",
"category": "Hidden",
"author": "Camptocamp,Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector-ecommerce",
"license": "AGPL-3",
"depends": [
"connector",
"sale_automatic_workflow_payment_mode",
"sale_exception",
"delivery",
"connector_base_product",
],
"data": [
"security/security.xml",
"security/ir.model.access.csv",
"wizard/sale_ignore_cancel_view.xml",
"data/ecommerce_data.xml",
"views/sale_view.xml",
"views/invoice_view.xml",
"views/stock_view.xml",
"views/payment_mode_view.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}
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]

Check warning on line 48 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

Added line #L48 was not covered by tests
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#L50

Added line #L50 was 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 = {
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