Newer
Older
# Copyright 2020 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models, api
class ModelName(models.Model):
_inherit = 'account.payment.order'

Benjamin - Le Filament
a validé
payment_line_amount = fields.Float(
string='Total Transactions',
compute='_compute_payment_line_amount'
)
bank_line_amount = fields.Float(
string='Total Lignes de paiement',
compute='_compute_bank_line_amount'
)
attachment_ids = fields.One2many(
comodel_name='ir.attachment',
compute='_compute_attachment_ids'
)

Benjamin - Le Filament
a validé
# ------------------------------------------------------
# Compute fields
# ------------------------------------------------------
@api.multi
def _compute_payment_line_amount(self):
for po in self:
po.payment_line_amount = sum(
po.payment_line_ids.mapped('amount_currency')
)
@api.multi
def _compute_bank_line_amount(self):
for po in self:
po.bank_line_amount = sum(
po.bank_line_ids.mapped('amount_currency')
)
@api.multi
def _compute_attachment_ids(self):
Attachment = self.env['ir.attachment']
for po in self:
po.attachment_ids = Attachment.search([
('res_model', '=', 'account.payment.order'),
('res_id', '=', po.id)
])

Benjamin - Le Filament
a validé
# ------------------------------------------------------
# Button function
# ------------------------------------------------------
def view_payment_line(self):
tree_id = self.env.ref(
'cgscop_cotisation.scop_account_payment_line_tree').id
search_id = self.env.ref(
'cgscop_cotisation.scop_account_payment_line_search').id
return {
'type': 'ir.actions.act_window',
'name': 'Lignes dde transaction',
'res_model': 'account.payment.line',
'views': [[tree_id, 'tree']],
'search_view_id': [search_id, 'search'],
'domain': [['order_id', '=', self.id]],
}