Skip to content

Commit

Permalink
[IMP] sale_order_carrier_auto_assign enable feature settings
Browse files Browse the repository at this point in the history
  • Loading branch information
santostelmo committed Feb 28, 2024
1 parent 2ddc76b commit 81bdb1c
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 31 deletions.
19 changes: 12 additions & 7 deletions sale_order_carrier_auto_assign/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
Sale Order Carrier Auto Assign
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dc237a5ac9a9f0f9a2c205d8db4420ee59d8444bb3347da5ac880f2dbbb21758
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
Expand All @@ -23,10 +20,10 @@ Sale Order Carrier Auto Assign
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_carrier_auto_assign
: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/sale-workflow&target_branch=16.0
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/sale-workflow&target_branch=16.0
:alt: Try me on Runboat

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

This module assigns automatically delivery carrier on sale order confirmation.

Expand All @@ -40,12 +37,19 @@ This module assigns automatically delivery carrier on sale order confirmation.
.. contents::
:local:

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

To enable sale order carrier auto assign:

#. Go to *Settings > Sales > Carrier Auto Assign*.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/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
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_carrier_auto_assign%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.
Expand All @@ -64,6 +68,7 @@ Contributors
* Akim Juillerat <[email protected]>
* Son (Ho Dac) <[email protected]>
* Phuc (Tran Thanh) <[email protected]>
* Telmo Santos <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions sale_order_carrier_auto_assign/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"website": "https://github.com/OCA/sale-workflow",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"data": ["views/res_config_settings_views.xml"],
"application": False,
"installable": True,
"depends": ["delivery"],
Expand Down
2 changes: 2 additions & 0 deletions sale_order_carrier_auto_assign/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import sale_order
from . import res_company
from . import res_config_settings
10 changes: 10 additions & 0 deletions sale_order_carrier_auto_assign/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

carrier_auto_assign = fields.Boolean()
14 changes: 14 additions & 0 deletions sale_order_carrier_auto_assign/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

carrier_auto_assign = fields.Boolean(
related="company_id.carrier_auto_assign",
readonly=False,
help="Enable carrier auto assign on sale order confirmation.",
)
5 changes: 1 addition & 4 deletions sale_order_carrier_auto_assign/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models
from odoo.tools import config


class SaleOrder(models.Model):

_inherit = "sale.order"

def action_confirm(self):
if config["test_enable"] and not self.env.context.get(
"test_carrier_auto_assign"
):
if not self.env.user.company_id.carrier_auto_assign:
return super().action_confirm()
self._add_delivery_carrier_on_confirmation()
return super().action_confirm()
Expand Down
3 changes: 3 additions & 0 deletions sale_order_carrier_auto_assign/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To enable sale order carrier auto assign:

#. Go to *Settings > Sales > Carrier Auto Assign*.
1 change: 1 addition & 0 deletions sale_order_carrier_auto_assign/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Akim Juillerat <[email protected]>
* Son (Ho Dac) <[email protected]>
* Phuc (Tran Thanh) <[email protected]>
* Telmo Santos <[email protected]>
42 changes: 25 additions & 17 deletions sale_order_carrier_auto_assign/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Sale Order Carrier Auto Assign</title>
<style type="text/css">

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

Expand Down Expand Up @@ -365,10 +366,8 @@ <h1 class="title">Sale Order Carrier Auto Assign</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dc237a5ac9a9f0f9a2c205d8db4420ee59d8444bb3347da5ac880f2dbbb21758
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/16.0/sale_order_carrier_auto_assign"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_carrier_auto_assign"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/16.0/sale_order_carrier_auto_assign"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_carrier_auto_assign"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/webui/builds.html?repo=OCA/sale-workflow&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module assigns automatically delivery carrier on sale order confirmation.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
Expand All @@ -379,41 +378,50 @@ <h1 class="title">Sale Order Carrier Auto Assign</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>To enable sale order carrier auto assign:</p>
<ol class="arabic simple">
<li>Go to <em>Settings &gt; Sales &gt; Carrier Auto Assign</em>.</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/issues">GitHub Issues</a>.
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
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_carrier_auto_assign%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li>Son (Ho Dac) &lt;<a class="reference external" href="mailto:hodacson.6491&#64;gmail.com">hodacson.6491&#64;gmail.com</a>&gt;</li>
<li>Phuc (Tran Thanh) &lt;<a class="reference external" href="mailto:phuc&#64;trobz.com">phuc&#64;trobz.com</a>&gt;</li>
<li>Telmo Santos &lt;<a class="reference external" href="mailto:telmo.santos&#64;camptocamp.com">telmo.santos&#64;camptocamp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo.tests import Form, TransactionCase

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT


class TestSaleOrderCarrierAutoAssign(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
test_context = cls.env.context.copy()
test_context["test_carrier_auto_assign"] = True
cls.env = cls.env(context=dict(test_context, tracking_disable=True))
cls.env = cls.env["base"].with_context(**DISABLED_MAIL_CONTEXT).env
cls.settings = cls.env["res.config.settings"].create({})
cls.settings.carrier_auto_assign = True
cls.settings.set_values()

cls.partner = cls.env.ref("base.res_partner_2")
product = cls.env.ref("product.product_product_9")
cls.delivery_local_delivery = cls.env.ref("delivery.delivery_local_delivery")
Expand Down
24 changes: 24 additions & 0 deletions sale_order_carrier_auto_assign/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="res_config_settings_view_form_sale" model="ir.ui.view">
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='shipping_setting_container']" position="inside">
<div class="col-12 col-lg-6 o_setting_box" id="carrier_auto_assign">
<div class="o_setting_left_pane">
<field name="carrier_auto_assign" />
</div>
<div class="o_setting_right_pane">
<label for="carrier_auto_assign" string="Carrier auto assign" />
<div class="text-muted">
Assigns automatically delivery carrier on sale order confirmation.
</div>
</div>
</div>
</xpath>
</field>
</record>

</odoo>

0 comments on commit 81bdb1c

Please sign in to comment.