diff --git a/__manifest__.py b/__manifest__.py index de4502e6bba38733b389fd410341f91440bde197..693799cf031fe317bc1e7f537383ca65a308513c 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -14,6 +14,7 @@ "templates/invoice_allocation_templates.xml", # templates "report/account_invoice_employee_report.xml", + "report/account_invoice_report.xml", # views "views/assets.xml", "views/account_invoice_views.xml", diff --git a/models/account_invoice.py b/models/account_invoice.py index db70cc1f93ce4da9bd440be2d6c737b4398f9828..dfebfad84ba14eec597e0ff9c3be62c511d69bc2 100644 --- a/models/account_invoice.py +++ b/models/account_invoice.py @@ -8,8 +8,14 @@ class AccountInvoice(models.Model): _inherit = "account.invoice" with_detail = fields.Boolean("Facture avec détail", default=False) - subcontracting_amount = fields.Monetary("Montant sous-traitance (HT)", track_visibility=True,) - expense_amount = fields.Monetary("Montant frais (HT)", track_visibility=True,) + subcontracting_amount = fields.Monetary( + "Montant sous-traitance (HT)", + track_visibility=True, + ) + expense_amount = fields.Monetary( + "Montant frais (HT)", + track_visibility=True, + ) production_amount = fields.Monetary( string="CA production", compute="_compute_production_amount", diff --git a/models/account_journal_dashboard.py b/models/account_journal_dashboard.py index 6564e78ffcffc9adfe19920b6c8ff8dd73713dcf..d347bf821312745cfa45e12beb6195765bfc7e64 100644 --- a/models/account_journal_dashboard.py +++ b/models/account_journal_dashboard.py @@ -1,7 +1,7 @@ # Copyright 2022 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models +from odoo import api, models class AccountJournal(models.Model): @@ -26,3 +26,14 @@ class AccountJournal(models.Model): WHERE journal_id = %(journal_id)s AND state = 'draft';""", {"journal_id": self.id}, ) + + @api.multi + def open_action(self): + """ + Surcharge la fonction parente pour modifier le contexte de + l'action sur les factures clients + """ + action = super(AccountJournal, self).open_action() + if action["xml_id"] == "account.action_invoice_tree1": + action["context"].update({"search_default_this_year": 1}) + return action diff --git a/report/account_invoice_employee_report.xml b/report/account_invoice_employee_report.xml index 1acf2362ec4e30517ddff050fc2bce1974aa6ef0..df954e3daa975da742b920512496bcd9503e69af 100644 --- a/report/account_invoice_employee_report.xml +++ b/report/account_invoice_employee_report.xml @@ -10,6 +10,11 @@ <field name="partner_id" /> <field name="invoice_id" /> <field name="user_id" /> + <filter + string="Cette année" + name="this_year" + domain="['|', ('date_invoice', '>=', context_today().strftime('%Y-01-01')), ('date_invoice', '=', False)]" + /> <group expand="0" string="Group By"> <filter name="group_by_date" @@ -86,6 +91,7 @@ <field name="type">ir.actions.act_window</field> <field name="res_model">account.invoice.employee.report</field> <field name="view_mode">pivot,graph,tree</field> + <field name="context">{'search_default_this_year': 1}</field> </record> <!-- Menu --> diff --git a/report/account_invoice_report.xml b/report/account_invoice_report.xml new file mode 100644 index 0000000000000000000000000000000000000000..45f5a81b2c9707e30d6ff08790443b4a2c0522e5 --- /dev/null +++ b/report/account_invoice_report.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <data> + <!-- SEARCH VIEW --> + <record model="ir.ui.view" id="view_account_invoice_report_search"> + <field name="name">account.invoice.report.search</field> + <field name="model">account.invoice.report</field> + <field name="inherit_id" ref="account.view_account_invoice_report_search" /> + <field name="arch" type="xml"> + <xpath expr="//field[@name='date']" position="before"> + <filter + string="Cette année" + name="this_year" + domain="['|', ('date', '>=', context_today().strftime('%Y-01-01')), ('date', '=', False)]" + /> + </xpath> + </field> + </record> + + <!-- ACTION --> + <record + id="account_invoice_employee_report_action" + model="ir.actions.act_window" + > + <field name="context">{'search_default_current':1, 'search_default_customer':1, 'group_by':[], 'group_by_no_leaf':1,'search_default_this_year': 1}</field> + </record> + </data> +</odoo> diff --git a/views/account_invoice_views.xml b/views/account_invoice_views.xml index b6db5c00a70138ec3d33f321b84f13194c115d63..5bd9e0710ea796281798064c2f09f1fe583b3db7 100644 --- a/views/account_invoice_views.xml +++ b/views/account_invoice_views.xml @@ -103,9 +103,26 @@ name="assign_error" domain="[('is_allocation_error', '=', True)]" /> + <separator /> + <filter + string="Cette année" + name="this_year" + domain="['|', ('date_invoice', '>=', context_today().strftime('%Y-01-01')), ('date_invoice', '=', False)]" + /> </xpath> </field> </record> + <!-- Inherit action --> + <record id="account.action_invoice_tree1" model="ir.actions.act_window"> + <field + name="context" + >{'type':'out_invoice', 'journal_type': 'sale', 'search_default_this_year': 1}</field> + </record> + <record id="account.action_invoice_out_refund" model="ir.actions.act_window"> + <field + name="context" + >{'default_type': 'out_refund', 'type': 'out_refund', 'journal_type': 'sale', 'search_default_this_year': 1}</field> + </record> </data> </odoo>