Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 purchase_report_date_planned/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions purchase_report_date_planned/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Mathieu Delva <mathieu.delva@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Purchase Report Date Planned",
"version": "14.0.1.1.0",
"author": "Akretion ,Odoo Community Association (OCA)",
"maintainers": ["mathieudelva"],
"website": "https://github.com/OCA/purchase-workflow",
"category": "Purchase",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"purchase_usability",
],
"data": [
"views/purchase_report.xml",
],
}
1 change: 1 addition & 0 deletions purchase_report_date_planned/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import purchase_report
22 changes: 22 additions & 0 deletions purchase_report_date_planned/models/purchase_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from odoo import fields, models


class PurchaseReport(models.Model):
_inherit = "purchase.report"

date_planned = fields.Datetime(compute="_compute_date_planned", store=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you do not have to create a computed field. it's just a normal field and as the model is based on a sql view the data will be here (with the override of _select and _group_by)


def _compute_date_planned(self):
for record in self:
order_line = record.order_id.order_line.filtered(
lambda r: r.product_id == record.product_id
)
record.date_planned = order_line.date_planned

def _select(self):
select_str = super(PurchaseReport, self)._select()
return select_str + ", l.date_planned as date_planned"

def _group_by(self):
group_by_str = super(PurchaseReport, self)._group_by()
return group_by_str + ", l.date_planned"
1 change: 1 addition & 0 deletions purchase_report_date_planned/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Mathieu Delva <mathieu.delva@akretion.com>
1 change: 1 addition & 0 deletions purchase_report_date_planned/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module add the field date_planned on purchase report model, purchase report tree view and add a filter that allows you to display orders that are late for delivery
Loading