Skip to content

Commit

Permalink
[17.0][IMP] sale_validity_auto_cancel: Extend the auto cancel expired…
Browse files Browse the repository at this point in the history
… SO functionality by adding new field to contact

[17.0][IMP] sale_validity_auto_cancel: Extend the auto cancel expired SO functionality by adding new field to contact

[17.0][IMP] sale_validity_auto_cancel: Extend the auto cancel expired SO functionality by adding new field to contact
  • Loading branch information
fd-oerp committed Jul 2, 2024
1 parent 747e92b commit 7badc79
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 4 deletions.
1 change: 1 addition & 0 deletions sale_validity_auto_cancel/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Authors
-------

* ForgeFlow
* OERP Canada

Contributors
------------
Expand Down
9 changes: 7 additions & 2 deletions sale_validity_auto_cancel/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2023 ForgeFlow S.L.
# Copyright 2024 OERP Canada <https://www.oerp.ca>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
Expand All @@ -8,9 +9,13 @@
"license": "LGPL-3",
"summary": "Automatically cancel quotations after validity period.",
"depends": ["sale_management"],
"author": "ForgeFlow, Odoo Community Association (OCA)",
"author": "ForgeFlow, OERP Canada, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"data": ["data/ir_cron.xml", "views/res_config_settings.xml"],
"data": [
"data/ir_cron.xml",
"views/res_config_settings.xml",
"views/res_partner_views.xml",
],
"installable": True,
"maintainers": ["JordiMForgeFlow"],
}
1 change: 1 addition & 0 deletions sale_validity_auto_cancel/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ForgeFlow S.L.
Copyright 2024 OERP Canada <https://www.oerp.ca>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
-->
<odoo noupdate="1">
Expand Down
24 changes: 22 additions & 2 deletions sale_validity_auto_cancel/i18n/sale_validity_auto_cancel.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-24 16:06+0000\n"
"PO-Revision-Date: 2024-06-24 16:06+0000\n"
"POT-Creation-Date: 2024-07-02 19:37+0000\n"
"PO-Revision-Date: 2024-07-02 19:37+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -20,6 +20,17 @@ msgstr ""
msgid "<span> days</span>"
msgstr ""

#. module: sale_validity_auto_cancel
#: model:ir.model.fields,field_description:sale_validity_auto_cancel.field_sale_order__auto_cancel_expired_so
msgid "Auto Cancel"
msgstr ""

#. module: sale_validity_auto_cancel
#: model:ir.model.fields,field_description:sale_validity_auto_cancel.field_res_partner__auto_cancel_expired_so
#: model:ir.model.fields,field_description:sale_validity_auto_cancel.field_res_users__auto_cancel_expired_so
msgid "Auto Cancel Expired SaleOrder"
msgstr ""

#. module: sale_validity_auto_cancel
#: model:ir.model.fields,field_description:sale_validity_auto_cancel.field_res_company__sale_validity_auto_cancel_days
#: model:ir.model.fields,field_description:sale_validity_auto_cancel.field_res_config_settings__sale_validity_auto_cancel_days
Expand All @@ -46,6 +57,15 @@ msgstr ""
msgid "Contact"
msgstr ""

#. module: sale_validity_auto_cancel
#: model:ir.model.fields,help:sale_validity_auto_cancel.field_res_partner__auto_cancel_expired_so
#: model:ir.model.fields,help:sale_validity_auto_cancel.field_res_users__auto_cancel_expired_so
#: model:ir.model.fields,help:sale_validity_auto_cancel.field_sale_order__auto_cancel_expired_so
msgid ""
"If unchecked, you will be able to restrict this contact's expired SO from "
"being auto-canceled."
msgstr ""

#. module: sale_validity_auto_cancel
#: model_terms:ir.ui.view,arch_db:sale_validity_auto_cancel.res_config_settings_view_form
msgid ""
Expand Down
1 change: 1 addition & 0 deletions sale_validity_auto_cancel/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

from . import res_company
from . import res_config_settings
from . import res_partner
from . import sale_order
1 change: 1 addition & 0 deletions sale_validity_auto_cancel/models/res_company.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2023 ForgeFlow S.L.
# Copyright 2024 OERP Canada <https://www.oerp.ca>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models
Expand Down
1 change: 1 addition & 0 deletions sale_validity_auto_cancel/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2023 ForgeFlow S.L.
# Copyright 2024 OERP Canada <https://www.oerp.ca>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models
Expand Down
16 changes: 16 additions & 0 deletions sale_validity_auto_cancel/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 ForgeFlow S.L.
# Copyright 2024 OERP Canada <https://www.oerp.ca>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

auto_cancel_expired_so = fields.Boolean(
string="Auto Cancel Expired SaleOrder",
default=True,
help="If unchecked, you will be able to restrict \n"
"this contact's expired SO from being auto-canceled.",
)
6 changes: 6 additions & 0 deletions sale_validity_auto_cancel/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2023 ForgeFlow S.L.
# Copyright 2024 OERP Canada <https://www.oerp.ca>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
import logging

Expand All @@ -12,6 +13,10 @@
class SaleOrder(models.Model):
_inherit = "sale.order"

auto_cancel_expired_so = fields.Boolean(
related="partner_id.auto_cancel_expired_so", string="Auto Cancel"
)

def _get_expired_order_states(self):
# Can be inherited to exclude/include order states
return ["draft", "sent"]
Expand All @@ -27,6 +32,7 @@ def cron_sale_validity_auto_cancel(self):
[
("state", "in", expired_states),
("validity_date", "<", threshold),
("auto_cancel_expired_so", "=", True),
]
)
for order in orders:
Expand Down
1 change: 1 addition & 0 deletions sale_validity_auto_cancel/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow</li>
<li>OERP Canada</li>
</ul>
</div>
<div class="section" id="contributors">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ def test_sale_validity_auto_cancel(self):
self.assertEqual(so.state, "draft")
so.cron_sale_validity_auto_cancel()
self.assertEqual(so.state, "cancel")

def test_sale_validity_auto_cancel_keep_so(self):
self.partner.write({"auto_cancel_expired_so": False})
so = self.create_so()
self.assertEqual(so.state, "draft")
so.cron_sale_validity_auto_cancel()
self.assertEqual(so.state, "draft")
1 change: 1 addition & 0 deletions sale_validity_auto_cancel/views/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2023 ForgeFlow S.L.
Copyright 2024 OERP Canada <https://www.oerp.ca>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
-->
<odoo>
Expand Down
18 changes: 18 additions & 0 deletions sale_validity_auto_cancel/views/res_partner_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2023 ForgeFlow S.L.
Copyright 2024 OERP Canada <https://www.oerp.ca>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
-->
<odoo>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr='//group[@name="sale"]' position="inside">
<field name="auto_cancel_expired_so" />
</xpath>
</field>
</record>
</odoo>

0 comments on commit 7badc79

Please sign in to comment.