Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
7a74d96
[CHG] rename 'base_sale_multichannels' to 'connector_ecommerce'
Feb 19, 2013
8443b66
[ADD] Base support to export picking (partial and complete)
jgrandguillaume Mar 12, 2013
a9e27de
[FIX] improve styling, remove unused imports, fix license (done by Joel)
Mar 12, 2013
c7c4550
[ADD] Event to handle the adding of the tracking number on picking
jgrandguillaume Mar 13, 2013
91deb2d
[FIX] remove the carrier tracking number from the event, fix missing …
Mar 13, 2013
45c8e80
[ADD] Support for exporting the account_invoice to Magento
jgrandguillaume Mar 13, 2013
a750d02
[FIX] styling, license, imports, some fixes
Mar 13, 2013
801eb31
[FIX] add product_view.xml file
bealdav Mar 14, 2013
ab0e4a1
[IMP] start adding support of onchange in connector-ecommerce
sebastienbeau Mar 13, 2013
1fe3bb6
[REF] code review
Mar 14, 2013
9ab8dfc
[IMP] code review
sebastienbeau Mar 14, 2013
33abade
[IMP] play on change on sale.order and sale.order.lines in new framew…
gurneyalex Mar 15, 2013
659636e
[FIX] wrong arguments in action_done
Mar 18, 2013
f920898
[ADD] 'Authorized' import rules to be able to import sales orders aut…
Jun 14, 2013
770fa1c
[REF] started to use ConnectorUnit classes to add extra lines in sale…
Jun 25, 2013
44ebddf
Fix a bug : remove special fields before database storage (avoid to t…
Jun 27, 2013
f496fe8
[DEL] remove old stuff
Jul 5, 2013
6be773c
[IMP] - make possible to inherit the method _add_order_extra_line (do…
mathieuvatel Jul 15, 2013
4ac3e92
[FIX] indentation according to pep8
Jul 15, 2013
17a20ef
Added "invoice validated" event and called upon "on_invoice_validate".
Aug 5, 2013
104dfad
[FIX] the onchange test had a TypeError, now it fails for some reason
Aug 5, 2013
c0d44db
[BUMP] release 2.1.0
Jan 15, 2014
0a0fc14
[IMP] move product_normal_form_view in connector_base_product
bealdav Feb 4, 2014
459586e
[FIX] product_view.xml in __openerp__.py
bealdav Feb 14, 2014
acdbef8
The special sales orders lines can have a sequence and have low prior…
Mar 31, 2014
ca12765
[FIX] related_backorder_ids shoud not be linked with a new copy
rdeheele Apr 7, 2014
f689484
rise the sequence of the special lines to reduce chances to be reache…
Apr 9, 2014
e96bd04
[IMP] allow to override payment rules
bealdav Apr 25, 2014
e5138a3
Bump to version 2.2.0
May 26, 2014
e0d1184
set modules to not installable
Jul 7, 2014
02122ef
Add bug tracker link on README.rst
yvaucher May 22, 2015
3ab723e
Trigger the change of price on the newly created product
Jul 23, 2015
74e5236
[FIX] Bug throwing exception importing sale order
kikopeiro Aug 27, 2015
1877ec5
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
472266f
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
115c0ec
[IMP] made module installable
parthiv Mar 18, 2016
4e014cc
Replace product.price.type by predefined fields
Apr 12, 2016
813772d
[FIX] changed to MVC structure
atchuthan May 12, 2016
3ea85b9
Remove account.tax.group, now exists in 'account'
May 26, 2016
177c58e
[FIX] renamed filename to account_payment_mode
atchuthan May 27, 2016
7b33c50
Capitalize products names for consistency
May 27, 2016
6a45fb8
[FIX] removed duplicate line
parthiv Aug 24, 2016
70b9fba
Extract onchange fields for better extensibility
Sep 8, 2016
6fe5a75
[MIG] Make modules uninstallable
pedrobaeza Oct 6, 2016
d6f5de2
connector_ecommerce: Add security groups to avoid show information al…
sergio-teruel Jan 20, 2017
7fdbbce
[MIG] Migration to 10.0
Nov 23, 2016
2c4104a
[MIG] Migration to 10.0: Adapt code to 10.0
lmignon May 15, 2017
3ed5519
fix message_post() expecting a len(recordset) == 1
Jun 9, 2017
7950d33
Fire new event: 'on_picking_dropship_done' when an 'incoming' shipmen…
jaredkipe Oct 21, 2017
20e62e4
Fix lint error introduced in #43
Oct 30, 2017
f6df8fe
[MIG] connector_ecommerce to V11
hugosantosred Feb 8, 2018
2dc696b
Connector Ecommerce to version 12
ljimenezsidoo Mar 20, 2019
cca3ad0
Update connector_ecommerce/views/sale_view.xml
sebalix Apr 29, 2019
6a35058
Update connector_ecommerce/tests/test_picking_event.py
ljimenezsidoo May 31, 2019
7512ec4
Update connector_ecommerce/tests/test_picking_event.py
ljimenezsidoo May 31, 2019
fd450d9
RMV rule_group from ecommerce data xml
Oct 15, 2019
84eb147
[IMP] connector_ecommerce: black, isort
HviorForgeFlow Mar 23, 2020
01fd295
[MIG] connector_ecommerce: Migration to 13.0
HviorForgeFlow Mar 23, 2020
de06870
[FIX]not exist field in model raise error so remove those before call…
bizzappdev Nov 23, 2020
ef4f487
[FIX]proper exception rule
bizzappdev Feb 4, 2021
6eecbe2
[FIX]tax_id test case from plan onchange. (based on Company from orde…
bizzappdev Mar 8, 2021
7d253c4
[FIX]pre-commit
bizzappdev Mar 8, 2021
4062007
[FIX]remove not needed fields
bizzappdev Mar 9, 2021
38b6dbd
[FIX] Fix action done
florian-dacosta Jan 3, 2021
de026ea
[FIX] Fix Invoice validate notification
florian-dacosta Jan 14, 2021
81afd66
[FIX] Remove checkpoint as it has been removed from connector
florian-dacosta Apr 2, 2021
6c67109
[IMP] connector_ecommerce: black, isort, prettier
hailangvn May 16, 2021
fcd1a74
[MIG] connector_ecommerce: Migration to 14.0
hailangvn May 16, 2021
9b98a3f
[FIX] rule must be created as inactive as it could break standard beh…
Aug 19, 2021
428c798
[FIX] connector_ecommerce: resolve error searching non-stored field
hailangvn Feb 24, 2022
ea2dd9b
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 30, 2022
d95ef9c
[FIX] connector_ecommerce: remove obsoleted rule
hailangvn Apr 25, 2022
351bdef
Missing env variable in openupgrade method call
May 4, 2022
4d82562
[IMP] connector_ecommerce: black, isort
flachica May 6, 2022
1dcc64a
[MIG][15.0] connector_ecommerce: 15.0
flachica May 6, 2022
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
84 changes: 84 additions & 0 deletions connector_ecommerce/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License

Connector for E-Commerce
========================

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

It sits on top of the `connector`_ framework and is used by the
e-commerce connectors, like `magentoerpconnect`_ or
`prestashoperpconnect`_.

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

.. _`connector`: http://odoo-connector.com
.. _`magentoerpconnect`: http://odoo-magento-connector.com
.. _`prestashoperpconnect`: https://github.com/OCA/connector-prestashop

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 smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/connector-ecommerce/issues/new?body=module:%20connector_ecommerce%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Credits
=======

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

See `contributors' list`_

.. _contributors' list: ./AUTHORS

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit http://odoo-community.org.
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": "15.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(SpecialOrderLineBuilder, self).__init__(work_context)
self.product = None # id or browse_record
# 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

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

product = self.product
if product is None:
product = self.env.ref(".".join(self.product_ref))

if not isinstance(product, models.BaseModel):
product = self.env["product.product"].browse(product)
return {
"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(ShippingLineBuilder, self).__init__(work_context)
self.product_ref = ("connector_ecommerce", "product_product_shipping")
self.sequence = 999

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


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(CashOnDeliveryLineBuilder, self).__init__(work_context)
self.product_ref = ("connector_ecommerce", "product_product_cash_on_delivery")
self.sequence = 995


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(GiftOrderLineBuilder, self).__init__(work_context)
self.product_ref = ("connector_ecommerce", "product_product_gift")
self.sign = -1
self.gift_code = None
self.sequence = 990

def get_line(self):
line = super(GiftOrderLineBuilder, self).get_line()
if self.gift_code:
line["name"] = "{} [{}]".format(line["name"], self.gift_code)
return line
120 changes: 120 additions & 0 deletions connector_ecommerce/components/sale_order_onchange.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# © 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 = {}
for fieldname, value in vals.items():
if fieldname not in record:
if model:
column = self.env[model]._fields[fieldname]
if column.type == "many2one":
value = value[0] # many2one are tuple (id, name)
new_values[fieldname] = value
return new_values

def play_onchanges(self, model, values, onchange_fields):
model = self.env[model]
onchange_specs = model._onchange_spec()

# 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

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

new_values = {}
for field in onchange_fields:
onchange_values = new_record.onchange(all_values, field, onchange_specs)
new_values.update(
self.get_new_values(values, onchange_values, model=model._name)
)
all_values.update(new_values)

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


class SaleOrderOnChange(Component):

_name = "ecommerce.onchange.manager.sale.order"
_inherit = "ecommerce.onchange.manager"
_usage = "ecommerce.onchange.manager.sale.order"

order_onchange_fields = [
"partner_id",
"partner_shipping_id",
"payment_mode_id",
"workflow_process_id",
]

line_onchange_fields = ["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)

# play onchange on sales order line
processed_order_lines = []
line_lists = [order_lines]
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"])

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"]

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)
# keeps command number and ID (or 0)
old_line_data = command_line[2]
# 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(
"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)
# in place modification of the sales order line in the list
line_list[idx] = new_line
return order
Loading