Skip to content

Commit

Permalink
[ADD] - add stock_release_channel_geoengine
Browse files Browse the repository at this point in the history
[FIX] - fix geo-fields import
  • Loading branch information
sbejaoui committed Mar 14, 2023
1 parent e8caa54 commit 160a297
Show file tree
Hide file tree
Showing 21 changed files with 931 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
name: test with OCB
services:
postgres:
image: postgres:12.0
image: postgis/postgis:12-3.3
env:
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoo
Expand Down
6 changes: 6 additions & 0 deletions setup/stock_release_channel_geoengine/setup.py
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,
)
92 changes: 92 additions & 0 deletions stock_release_channel_geoengine/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
===============================
Stock Release Channel Geoengine
===============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-OCA%2Fwms-lightgray.png?logo=github
:target: https://github.com/OCA/wms/tree/16.0/stock_release_channel_geoengine
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_release_channel_geoengine
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/wms&target_branch=16.0
:alt: Try me on Runboat

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

This module enhance release channels with the addition of
a delivery zone that can be selected by the delivery manager through the UI.
If a zone is specified, the release channel will exclusively select deliveries
for partners who are localized within that zone.

**Table of contents**

.. contents::
:local:

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

In order to determine if a contact belongs to a geographical zone,
this module relies on the `base_geoengine` addon. Thus, the `postgis` extension
module for `postgresql` is needed for this purpose.

Configuration
=============

- On the release channel, check `Restrict To Delivery Zone`.
- Select the delivery zone.
- To exclude certain partners from selection based on their location, you can
uncheck the "Delivery based on geo-localization?" option in the partner view.

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

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

* Laurent Mignon <[email protected]>
* Souheil Bejaoui <[email protected]>

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/wms <https://github.com/OCA/wms/tree/16.0/stock_release_channel_geoengine>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_release_channel_geoengine/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions stock_release_channel_geoengine/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Release Channel Geoengine",
"summary": """Release channel based on geo-localization""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/wms",
"depends": ["geoengine_partner", "stock_release_channel"],
"data": [
"views/res_partner.xml",
"views/stock_release_channel.xml",
],
"demo": [],
}
3 changes: 3 additions & 0 deletions stock_release_channel_geoengine/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import stock_release_channel
from . import res_partner
from . import stock_picking
30 changes: 30 additions & 0 deletions stock_release_channel_geoengine/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ResPartner(models.Model):

_inherit = "res.partner"

in_geo_release_channel = fields.Boolean(
string="Delivery based on geo-localization?",
help="Include in release channels based on geographic zones",
default=True,
)
stock_release_channel_ids = fields.Many2many(
comodel_name="stock.release.channel",
string="Release Channels",
compute="_compute_stock_release_channel_id",
)

@api.depends("geo_point", "in_geo_release_channel")
def _compute_stock_release_channel_id(self):
for rec in self:
if not rec.geo_point or not rec.in_geo_release_channel:
rec.stock_release_channel_ids = False
continue
rec.stock_release_channel_ids = rec.stock_release_channel_ids.search(
[("delivery_zone", "geo_intersect", rec.geo_point)]
)
22 changes: 22 additions & 0 deletions stock_release_channel_geoengine/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class StockPicking(models.Model):

_inherit = "stock.picking"

def _get_release_channel_possible_candidate_domain(self):
self.ensure_one()
domain = super()._get_release_channel_possible_candidate_domain()
if self.partner_id.in_geo_release_channel:
domain += [
"|",
("restrict_to_delivery_zone", "=", False),
("delivery_zone", "geo_intersect", self.partner_id.geo_point),
]
else:
domain += [("restrict_to_delivery_zone", "=", False)]
return domain
18 changes: 18 additions & 0 deletions stock_release_channel_geoengine/models/stock_release_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging

from odoo import fields, models

from odoo.addons.base_geoengine.fields import GeoMultiPolygon

_logger = logging.getLogger(__name__)


class StockReleaseChannel(models.Model):

_inherit = "stock.release.channel"

restrict_to_delivery_zone = fields.Boolean()
delivery_zone = GeoMultiPolygon()
4 changes: 4 additions & 0 deletions stock_release_channel_geoengine/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- On the release channel, check `Restrict To Delivery Zone`.
- Select the delivery zone.
- To exclude certain partners from selection based on their location, you can
uncheck the "Delivery based on geo-localization?" option in the partner view.
2 changes: 2 additions & 0 deletions stock_release_channel_geoengine/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Laurent Mignon <[email protected]>
* Souheil Bejaoui <[email protected]>
4 changes: 4 additions & 0 deletions stock_release_channel_geoengine/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module enhance release channels with the addition of
a delivery zone that can be selected by the delivery manager through the UI.
If a zone is specified, the release channel will exclusively select deliveries
for partners who are localized within that zone.
3 changes: 3 additions & 0 deletions stock_release_channel_geoengine/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In order to determine if a contact belongs to a geographical zone,
this module relies on the `base_geoengine` addon. Thus, the `postgis` extension
module for `postgresql` is needed for this purpose.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 160a297

Please sign in to comment.