-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] sale_start_end_dates: add fields in sale.report
Inherit standalone sale.order.line views
- Loading branch information
1 parent
d830b4c
commit 4492c86
Showing
6 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from . import reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import sale_report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2024 Akretion France (https://www.akretion.com/) | ||
# @author Alexis de Lattre <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class SaleReport(models.Model): | ||
_inherit = "sale.report" | ||
|
||
start_date = fields.Date(readonly=True) | ||
end_date = fields.Date(readonly=True) | ||
number_of_days = fields.Integer(readonly=True) | ||
|
||
def _select_additional_fields(self): | ||
res = super()._select_additional_fields() | ||
res["start_date"] = "l.start_date" | ||
res["end_date"] = "l.end_date" | ||
res["number_of_days"] = "l.number_of_days" | ||
return res | ||
|
||
def _group_by_sale(self): | ||
sql = super()._group_by_sale() | ||
sql = f"{sql}, l.start_date, l.end_date, l.number_of_days" | ||
return sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2024 Akretion France (https://www.akretion.com/) | ||
@author: Alexis de Lattre <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
<record id="sale_report_view_tree" model="ir.ui.view"> | ||
<field name="model">sale.report</field> | ||
<field name="inherit_id" ref="sale.sale_report_view_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="product_uom_qty" position="before"> | ||
<field name="start_date" optional="hide" /> | ||
<field name="end_date" optional="hide" /> | ||
<field name="number_of_days" optional="hide" invisible="not start_date"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2024 Akretion France (https://www.akretion.com/) | ||
@author Alexis de Lattre <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
<record id="view_order_line_tree" model="ir.ui.view"> | ||
<field name="model">sale.order.line</field> | ||
<field name="inherit_id" ref="sale.view_order_line_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field | ||
name="start_date" | ||
required="must_have_dates" | ||
invisible="not must_have_dates" | ||
optional="show" | ||
/> | ||
<field | ||
name="end_date" | ||
required="must_have_dates" | ||
invisible="not must_have_dates" | ||
optional="show" | ||
/> | ||
<field | ||
name="number_of_days" | ||
required="must_have_dates" | ||
invisible="not must_have_dates" | ||
optional="hide" | ||
/> | ||
<field name="must_have_dates" column_invisible="1" /> | ||
</field> | ||
</field> | ||
</record> | ||
<record id="sale_order_line_view_form_readonly" model="ir.ui.view"> | ||
<field name="model">sale.order.line</field> | ||
<field name="inherit_id" ref="sale.sale_order_line_view_form_readonly" /> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field | ||
name="start_date" | ||
required="must_have_dates" | ||
invisible="not must_have_dates" | ||
/> | ||
<field | ||
name="end_date" | ||
required="must_have_dates" | ||
invisible="not must_have_dates" | ||
/> | ||
<field | ||
name="number_of_days" | ||
required="must_have_dates" | ||
invisible="not must_have_dates" | ||
/> | ||
<field name="must_have_dates" column_invisible="1" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |