Skip to content

Commit

Permalink
[IMP] add dates in sale order
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Dec 11, 2024
1 parent e2fcd28 commit 61a5d65
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 11 deletions.
1 change: 1 addition & 0 deletions sale_report_usability/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import report
3 changes: 2 additions & 1 deletion sale_report_usability/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"category": "other",
"depends": [
"sale",
"sale_order_confirmation_date",
],
"data": [
"report/sale_report.xml",
"views/sale_report.xml",
],
"summary": "Add generic date to compare",
"installable": True,
Expand Down
28 changes: 22 additions & 6 deletions sale_report_usability/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-11 10:45+0000\n"
"PO-Revision-Date: 2024-12-11 10:45+0000\n"
"POT-Creation-Date: 2024-12-11 11:25+0000\n"
"PO-Revision-Date: 2024-12-11 11:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -16,38 +16,54 @@ msgstr ""
"Plural-Forms: \n"

#. module: sale_report_usability
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_order__assigned_attachment_ids
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_report__assigned_attachment_ids
msgid "Assigned Attachments"
msgstr "Allegati assegnati"

#. module: sale_report_usability
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_order__generic_confirmation_date
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_report__generic_confirmation_date
#: model_terms:ir.ui.view,arch_db:sale_report_usability.view_order_product_search
msgid "Confirmation Date (without year)"
msgstr "Data di conferma (senza anno)"
msgid "Confirmation Date (with current year)"
msgstr "Data di conferma (per report comparativo)"

#. module: sale_report_usability
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_order__display_name
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_report__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: sale_report_usability
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_order__id
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_report__id
msgid "ID"
msgstr ""

#. module: sale_report_usability
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_order____last_update
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_report____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: sale_report_usability
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_order__generic_date
#: model:ir.model.fields,field_description:sale_report_usability.field_sale_report__generic_date
#: model_terms:ir.ui.view,arch_db:sale_report_usability.view_order_product_search
msgid "Order Date (without year)"
msgstr "Data ordine (senza anno)"
msgid "Order Date (with current year)"
msgstr "Data ordine (per report comparativo)"

#. module: sale_report_usability
#: model:ir.model,name:sale_report_usability.model_sale_report
msgid "Sales Analysis Report"
msgstr "Resoconto di analisi vendite"

#. module: sale_report_usability
#: model:ir.model,name:sale_report_usability.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"

#. module: sale_report_usability
#: model:ir.model.fields,help:sale_report_usability.field_sale_report__generic_date
msgid "Used to compare dates on multiple years"
msgstr "Per comparazione date su diversi anni"
1 change: 1 addition & 0 deletions sale_report_usability/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
30 changes: 30 additions & 0 deletions sale_report_usability/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

generic_date = fields.Date(
"Order Date (with current year)",
compute="_compute_generic_date",
store=True,
)
generic_confirmation_date = fields.Date(
"Confirmation Date (with current year)",
compute="_compute_generic_confirmation_date",
store=True,
)

@api.depends("date_order")
def _compute_generic_date(self):
for order in self:
order.generic_date = (order.date_order or fields.Date.today()).replace(
year=2000
)

@api.depends("confirmation_date")
def _compute_generic_confirmation_date(self):
for order in self:
order.generic_confirmation_date = (
order.confirmation_date or order.date_order or fields.Date.today()
).replace(year=2000)
10 changes: 8 additions & 2 deletions sale_report_usability/report/sale_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
class SaleReport(models.Model):
_inherit = "sale.report"

generic_date = fields.Date("Order Date (without year)", readonly=True)
generic_date = fields.Date(
"Order Date (with current year)",
help="Used to compare dates on multiple years",
readonly=True,
)
generic_confirmation_date = fields.Date(
"Confirmation Date (without year)", readonly=True
"Confirmation Date (with current year)",
help="Used to compare dates on multiple years",
readonly=True,
)

def _query(self, with_clause="", fields=None, groupby="", from_clause=""):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</xpath>
<xpath expr="/search/group/filter[@name='date']" position="after">
<filter
string="Order Date (without year)"
string="Order Date (with current year)"
name="generic_date"
context="{'group_by': 'generic_date'}"
/>
<filter
string="Confirmation Date (without year)"
string="Confirmation Date (with current year)"
name="generic_confirmation_date"
context="{'group_by': 'generic_confirmation_date'}"
/>
Expand Down

0 comments on commit 61a5d65

Please sign in to comment.