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

[13.0][PORT] 647 from 10.0 #820

Merged
merged 2 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exclude: >
shopinvader_product_stock_assortment|
shopinvader_promotion_rule|
shopinvader_quotation|
shopinvader_sale_communication|
shopinvader_sale_report
)/
)
Expand Down
59 changes: 59 additions & 0 deletions shopinvader_sale_communication/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
=============================
Shopinvader Sale Communcation
=============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github
:target: https://github.com/shopinvader/odoo-shopinvader
:alt: shopinvader/odoo-shopinvader

|badge1| |badge2| |badge3|

This module adds information fields for customers and vendors.
Vendor communicates with customer with online_information_for_customer.
Customer can request information to vendor with online_information_request.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/shopinvader/odoo-shopinvader/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 <https://github.com/shopinvader/odoo-shopinvader/issues/new?body=module:%20shopinvader_sale_communication%0Aversion:%2010.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
~~~~~~~

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Benoit Aimont <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `shopinvader/odoo-shopinvader <https://github.com/shopinvader/odoo-shopinvader>`_ project on GitHub.

You are welcome to contribute.
2 changes: 2 additions & 0 deletions shopinvader_sale_communication/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import services
16 changes: 16 additions & 0 deletions shopinvader_sale_communication/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Shopinvader Sale Communication",
"summary": """
This module adds information fields for customers and vendors.""",
"version": "10.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV",
"website": "https://shopinvader.com/",
"depends": ["sale", "shopinvader"],
"data": ["views/sale_order.xml"],
"demo": [],
"installable": False,
}
1 change: 1 addition & 0 deletions shopinvader_sale_communication/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
19 changes: 19 additions & 0 deletions shopinvader_sale_communication/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SaleOrder(models.Model):

_inherit = "sale.order"

online_information_for_customer = fields.Html(
help="Fill in this field to provide your customer more information "
"on his online account"
)
online_information_request = fields.Text(
help="This field is filled by the customer to request information",
readonly=True,
)
1 change: 1 addition & 0 deletions shopinvader_sale_communication/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Benoit Aimont <[email protected]>
3 changes: 3 additions & 0 deletions shopinvader_sale_communication/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module adds information fields for customers and vendors.
Vendor communicates with customer with online_information_for_customer.
Customer can request information to vendor with online_information_request.
2 changes: 2 additions & 0 deletions shopinvader_sale_communication/services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import abstract_sale
from . import cart
19 changes: 19 additions & 0 deletions shopinvader_sale_communication/services/abstract_sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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(
{
"online_information_for_customer": sale.online_information_for_customer,
"online_information_request": sale.online_information_request,
}
)
return values
14 changes: 14 additions & 0 deletions shopinvader_sale_communication/services/cart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2020 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({"online_information_request": {"type": "string"}})
return validator
2 changes: 2 additions & 0 deletions shopinvader_sale_communication/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import test_cart
from . import test_sale
31 changes: 31 additions & 0 deletions shopinvader_sale_communication/tests/test_cart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.shopinvader.tests.common import CommonCase


class TestCart(CommonCase):
def setUp(self):
super(TestCart, self).setUp()
self.cart = self.env.ref("shopinvader.sale_order_2")
self.shopinvader_session = {"cart_id": self.cart.id}
self.partner = self.env.ref("shopinvader.partner_1")
with self.work_on_services(
partner=self.partner, shopinvader_session=self.shopinvader_session
) as work:
self.service = work.component(usage="cart")

def test_cart(self):
online_information_for_customer = "CUSTOMER INFO"
online_information_request = "VENDOR INFO REQUEST"
params = {
"online_information_for_customer": online_information_for_customer,
"online_information_request": online_information_request,
}
self.service.dispatch("update", params=params)
# online_information_for_customer should not be updated from the front
self.assertFalse(self.cart.online_information_for_customer)
self.assertEqual(
self.cart.online_information_request, online_information_request
)
32 changes: 32 additions & 0 deletions shopinvader_sale_communication/tests/test_sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.shopinvader.tests.common import CommonCase


class TestSale(CommonCase):
def setUp(self):
super(TestSale, self).setUp()
self.partner = self.env.ref("base.res_partner_2")
with self.work_on_services(partner=self.partner) as work:
self.service = work.component(usage="sales")

def test_sale_order_info(self):
online_information_for_customer = "TEST"
so = self.env["sale.order"].create(
{
"partner_id": self.env.ref("base.res_partner_2").id,
"online_information_for_customer": online_information_for_customer,
"shopinvader_backend_id": self.env.ref(
"shopinvader.backend_1"
).id,
"typology": "sale",
}
)
so.action_confirm()
res = self.service.get(so.id)
self.assertEqual(
res.get("online_information_for_customer"),
so.online_information_for_customer,
)
23 changes: 23 additions & 0 deletions shopinvader_sale_communication/views/sale_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<record model="ir.ui.view" id="sale_order_form_view">
<field name="name">sale.order.form (in shopinvader_sale_communication)</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook" postion="inside">
<page string="Information for Customer" name="customer_info">
<field name="online_information_for_customer"/>
</page>
<page string="Information for Salesperson" name="salesperson_info">
<field name="online_information_request"/>
</page>
</xpath>
</field>
</record>

</odoo>