-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[10.0][ADD] add module shopinvader_delivery_note
- Loading branch information
Showing
12 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
1 change: 1 addition & 0 deletions
1
setup/shopinvader_delivery_note/odoo/addons/shopinvader_delivery_note
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../shopinvader_delivery_note |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Shopinvader delivery note", | ||
"description": """Shopinvader addons to let user define a delivery note""", | ||
"author": "ACSONE SA/NV", | ||
"website": "http://shopinvader.com/", | ||
"category": "e-commerce", | ||
"version": "10.0.1.0.0", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"shopinvader", | ||
# OCA/stock-logistics-workflow | ||
"sale_stock_delivery_note", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import abstract_sale | ||
from . import cart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from odoo.addons.component.core import AbstractComponent | ||
|
||
|
||
class AbstractSaleService(AbstractComponent): | ||
_inherit = "shopinvader.abstract.sale.service" | ||
|
||
def _convert_one_sale(self, sale): | ||
values = super(AbstractSaleService, self)._convert_one_sale(sale) | ||
values.update({"delivery_note": sale.delivery_note}) | ||
return values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from odoo.addons.component.core import Component | ||
|
||
|
||
class CartService(Component): | ||
_inherit = "shopinvader.cart.service" | ||
|
||
def _validator_update(self): | ||
validator = super(CartService, self)._validator_update() | ||
validator.update({"delivery_note": {"type": "string"}}) | ||
return validator | ||
|
||
def _prepare_delivery_note(self, delivery_note, params): | ||
""" | ||
Put the given delivery note into params dict (used to create the | ||
sale.order). | ||
:param delivery_note: str or bool | ||
:param params: dict | ||
:return: bool | ||
""" | ||
# If the user try to remove the value, we'll have an empty string | ||
if delivery_note or isinstance(delivery_note, (str, unicode)): | ||
params.update({"delivery_note": delivery_note}) | ||
return True | ||
|
||
def _prepare_update(self, cart, params): | ||
params = super(CartService, self)._prepare_update(cart, params) | ||
self._prepare_delivery_note(params.pop("delivery_note", False), params) | ||
return params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import test_sale_order_delivery_note |
46 changes: 46 additions & 0 deletions
46
shopinvader_delivery_note/tests/test_sale_order_delivery_note.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from uuid import uuid4 | ||
|
||
from odoo.addons.shopinvader.tests.test_cart import CommonConnectedCartCase | ||
|
||
|
||
class TestSaleOrderDeliveryNote(CommonConnectedCartCase): | ||
""" | ||
Tests about the delivery note provided by the customer. | ||
This field should by passed into the related picking. | ||
""" | ||
|
||
def setUp(self): | ||
super(TestSaleOrderDeliveryNote, self).setUp() | ||
|
||
def test_update_delivery_note1(self): | ||
""" | ||
Execute some update on existing cart (update many times the | ||
delivery_note) then confirm it to check if the delivery_note is | ||
passed to related pickings. | ||
:return: | ||
""" | ||
delivery_notes = [ | ||
str(uuid4()), | ||
str(uuid4()), | ||
"", | ||
"", | ||
str(uuid4()), | ||
str(uuid4()), | ||
] | ||
for delivery_note in delivery_notes: | ||
params = {"delivery_note": delivery_note} | ||
self.service.dispatch("update", params=params) | ||
self.assertEquals(self.cart.delivery_note, delivery_note) | ||
result = self.service.dispatch("update", _id=self.cart.id) | ||
data = result.get("data", {}) | ||
self.assertEquals(data.get("delivery_note"), delivery_note) | ||
self.cart.action_confirm() | ||
pickings = self.cart.picking_ids | ||
self.assertTrue(pickings) | ||
for picking in pickings: | ||
# Should be equals to the last delivery_note set on the cart | ||
self.assertEquals(picking.delivery_note, delivery_note) | ||
return |