Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import api, fields, models
class AccountInvoiceReport(models.Model):
_inherit = "account.invoice.report"
# ==== Invoice fields ====
contract_id = fields.Many2one(
comodel_name="hall.contract",
string="Contrat",
readonly=True,
)
period_start = fields.Date("Date loyer", readonly=True)
month_revenue = fields.Float(
"CA Mensuel (HT)",
readonly=True,
)
month_b2b_revenue = fields.Float(
"CA Mensuel B2B (HT)",
readonly=True,
)
month_ref_revenue = fields.Float(
string="CA Mensuel de référence (HT)",
readonly=True,
)
# ==== Invoice line fields ====
virtuous_discount_id = fields.Many2one(
comodel_name="hall.contract.discount",
string="Loyer vertueux",
readonly=True,
)
# ==== Contract fields ====
hall_id = fields.Many2one(
comodel_name="hall.hall",
string="Site",
readonly=True,
)
commercial_name = fields.Char("Enseigne", readonly=True)
type_job = fields.Selection(
selection=[
("food", "Restauration"),
("bar", "Bar"),
("hybrid", "Hybride"),
("food_scholl", "Food school"),
("pop_up", "Pop up"),
],
string="Type d'enseigne",
readonly=True,
)
# ==== Discount fields ====
date_discount = fields.Date("Date loyer vertueux", readonly=True)
discount = fields.Float("Réduction", readonly=True)
_depends = {
"account.move": [
"contract_id", "period_start", "month_revenue", "month_b2b_revenue",
"month_ref_revenue",
],
"account.move.line": ["virtuous_discount_id",],
"hall.contract": ["hall_id", "commercial_name", "type_job"],
"hall.contract.discount": ["date_discount", "date_discount"],
}
@api.model
def _select(self):
query_select = super(AccountInvoiceReport, self)._select()
query_select += """
,
move.contract_id as contract_id,
move.period_start as period_start,
move.month_revenue as month_revenue,
move.month_b2b_revenue as month_b2b_revenue,
move.month_ref_revenue as month_ref_revenue,
line.virtuous_discount_id as virtuous_discount_id,
contract.hall_id as hall_id,
contract.commercial_name as commercial_name,
contract.type_job as type_job,
discount.date_discount as date_discount,
discount.discount as discount
"""
return query_select
@api.model
def _from(self):
query_from = super(AccountInvoiceReport, self)._from()
query_from += """
LEFT JOIN hall_contract contract ON contract.id = move.contract_id
LEFT JOIN hall_contract_discount discount
ON discount.id = line.virtuous_discount_id
"""
return query_from