Skip to content
Open
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
110 changes: 110 additions & 0 deletions purchase_order_update_date_planned_at_confirm/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
=======================================
Purchase Update Date Planned At Confirm
=======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5fcd15465b18b42a72a17272d160d7b3cfadbb719fd634bd7d8babd72f29a0aa
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_order_update_date_planned_at_confirm
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_order_update_date_planned_at_confirm
: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/purchase-workflow&target_branch=18.0
:alt: Try me on Runboat

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

This module allows to update the planned date from products
configuration at order confirmation.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

Between the purchase order creation and the actual confirmation, some
times may have last. If purchase user does not pay attention to the
planned date, a too soon one may have been set.

So, at purchase order confirmation, update the planned date from
products confiuration is a good option.

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

- Go to Purchase > Configuration > Settings
- Check the 'Update Planned Date at Confirmation'

Usage
=====

- Configure your products to have supplier delays.
- Create a Purchase Order with some of configured products
- Let some days pass
- Confirm the order
- The Planned Date is updated

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-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
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_order_update_date_planned_at_confirm%0Aversion:%2018.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
------------

- Denis Roussel denis.roussel@acsone.eu

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.

.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px
:target: https://github.com/rousseldenis
:alt: rousseldenis

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-rousseldenis|

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/18.0/purchase_order_update_date_planned_at_confirm>`_ 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 purchase_order_update_date_planned_at_confirm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions purchase_order_update_date_planned_at_confirm/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Purchase Update Date Planned At Confirm",
"summary": """This module allows to update the planned date from products "
"configuration at order confirmation""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"maintainers": ["rousseldenis"],
"website": "https://github.com/OCA/purchase-workflow",
"depends": [
"base_partition",
"purchase",
],
"data": ["views/res_config_settings.xml"],
}
97 changes: 97 additions & 0 deletions purchase_order_update_date_planned_at_confirm/i18n/fr.po

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import purchase_order
from . import res_company
from . import res_config_settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from collections import defaultdict
from contextlib import contextmanager

from odoo import _, models


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@contextmanager
def _change_date_order_to_compute_date_planned(self):
# Don't recompute records values
with self.env.protecting(self._fields, self):
purchase_order_dates = {}
for purchase in self:
purchase_order_dates[purchase.id] = purchase.date_order
purchase.date_order = purchase.date_approve
yield
for purchase in self:
purchase.date_order = purchase_order_dates[purchase.id]

def _update_date_planned_at_confirm(self):
"""
Update the date planned from products configuration (sellers)
For tracking, post a message if the date has been modified.
"""
for company, purchases in self.partition("company_id").items():
if not company.purchase_update_date_planned_at_confirm:
continue
purchases_and_dates = defaultdict()
for purchase in purchases:
purchases_and_dates[purchase.id] = purchase.date_planned
with self._change_date_order_to_compute_date_planned():
self.order_line._compute_price_unit_and_date_planned_and_name()
for purchase in self:
if purchase.date_planned != purchases_and_dates[purchase.id]:
initial_date = self.env["ir.qweb.field.datetime"].value_to_html(
purchases_and_dates[purchase.id], {}
)
new_date = self.env["ir.qweb.field.datetime"].value_to_html(
purchase.date_planned, {}
)
body = _(
"The Planned Date was not up-to-date and has been recomputed "
"at confirmation: %(initial_date)s → %(date_planned)s",
initial_date=initial_date,
date_planned=new_date,
)
purchase.message_post(body=body)

def button_confirm(self):
res = super().button_confirm()
self._update_date_planned_at_confirm()
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


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

purchase_update_date_planned_at_confirm = fields.Boolean(
help="Check this if you want to update the planned date "
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


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

purchase_update_date_planned_at_confirm = fields.Boolean(
related="company_id.purchase_update_date_planned_at_confirm",
readonly=False,
)
3 changes: 3 additions & 0 deletions purchase_order_update_date_planned_at_confirm/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Go to Purchase > Configuration > Settings
- Check the 'Update Planned Date at Confirmation'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Between the purchase order creation and the actual confirmation, some times may have
last. If purchase user does not pay attention to the planned date, a too soon one
may have been set.

So, at purchase order confirmation, update the planned date from products confiuration
is a good option.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Denis Roussel <denis.roussel@acsone.eu>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to update the planned date from products configuration at order confirmation.
5 changes: 5 additions & 0 deletions purchase_order_update_date_planned_at_confirm/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Configure your products to have supplier delays.
- Create a Purchase Order with some of configured products
- Let some days pass
- Confirm the order
- The Planned Date is updated
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading