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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# © 2020 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class ScopAccountMove(models.Model):
_inherit = "account.move"
@api.model
def default_get(self, fields):
"""
Attribue la valeur du journal des cotisations par défaut si la facture
est de type 'is_contribution'
Affecte le type 'is_contribution' par défaut si la facture est sur le
journal des cotisations
:param fields:
:return:
"""
res = super(ScopAccountMove, self).default_get(fields)
if res.get("is_contribution"):
res["journal_id"] = self.env.user.company_id.contribution_journal_id.id
else:
if (
res.get("journal_id")
== self.env.user.company_id.contribution_journal_id.id
):
res["is_contribution"] = True
return res
liasse_fiscale_id = fields.Many2one(
comodel_name="scop.liasse.fiscale", string="Liasse Fiscale"
)
year = fields.Integer("Année de cotisation")
is_contribution = fields.Boolean("Cotisation", default=False)
type_contribution_id = fields.Many2one(
comodel_name="scop.contribution.type",
string="Type de cotisation",
readonly=True,
)
partner_ur_id = fields.Many2one(
comodel_name="union.regionale",
string="UR Adhérent",
related="partner_id.ur_id",
store=True,
)
partner_member_number = fields.Char(
string="N° Adhérent",
related="partner_id.member_number",
)
is_sdd = fields.Boolean(
"Au prélèvement", compute="_compute_is_sdd", search="_search_is_sdd"
)
# ------------------------------------------------------
# Computed field
# ------------------------------------------------------
def _compute_is_sdd(self):
sdd_id = self.env.ref("account_banking_sepa_direct_debit.sepa_direct_debit").id
for invoice in self:
if (
invoice.payment_mode_id
and invoice.payment_mode_id.payment_method_id.id == sdd_id
):
invoice.is_sdd = True
else:
invoice.is_sdd = False
def _search_is_sdd(self, operator, value):
recs = self.search([]).filtered(lambda x: x.is_sdd is True)
if recs:
return [("id", "in", [x.id for x in recs])]
# ------------------------------------------------------
# Override Parent
# ------------------------------------------------------
# TODO: check if necessary
# def _get_outstanding_info_JSON(self):
# super(ScopAccountMove, self)._get_outstanding_info_JSON()
# info = json.loads(self.outstanding_credits_debits_widget)
# if info:
# values = info.get("content", False)
# if self.state == "open" and values:
# domain = [
# ("account_id", "=", self.account_id.id),
# (
# "partner_id",
# "=",
# self.env["res.partner"]
# ._find_accounting_partner(self.partner_id)
# .id,
# ),
# ("reconciled", "=", False),
# ("move_id.state", "=", "posted"),
# "|",
# "&",
# ("amount_residual_currency", "!=", 0.0),
# ("currency_id", "!=", None),
# "&",
# ("amount_residual_currency", "=", 0.0),
# "&",
# ("currency_id", "=", None),
# ("amount_residual", "!=", 0.0),
# ]
# if self.type in ("out_invoice", "in_refund"):
# domain.extend([("credit", ">", 0), ("debit", "=", 0)])
# else:
# domain.extend([("credit", "=", 0), ("debit", ">", 0)])
# lines = self.env["account.move.line"].search(domain)
# for value in values:
# for line in lines:
# if value.get("id") == line.id:
# value.update(
# {
# "date_maturity": datetime.strftime(
# line.date_maturity, "%d/%m/%Y"
# ),
# "invoice": line.invoice_id.number,
# }
# )
# self.outstanding_credits_debits_widget = json.dumps(info)