from odoo import models, fields, api from odoo.exceptions import UserError, ValidationError, Warning from psycopg2 import sql, DatabaseError import logging from werkzeug import utils import re _logger = logging.getLogger(__name__) import json class AccountMove(models.Model): _inherit = 'account.move' description=fields.Char(compute='_compute_description') transaction_date=fields.Datetime(compute='_compute_transaction_date') transaction_amount=fields.Float(compute='_compute_transaction_amount') systempay_ref=fields.Text(compute='_compute_systempay_ref') def _compute_description(self): for a in self: description='' for line in a.line_ids: a.description=line.product_id.name break def _compute_transaction_date(self): for a in self: a.transaction_date=False for t in a.transaction_ids: a.transaction_date=t.date break def _compute_transaction_amount(self): for a in self: a.transaction_amount=False for t in a.transaction_ids: a.transaction_amount=t.amount break def _compute_systempay_ref(self): for a in self: a.systempay_ref=False for t in a.transaction_ids: if t.systempay_raw_data: raw1=t.systempay_raw_data.split(",") vads_order_id_s=raw1[21].split(":") # raw1=raw1.replace("\r", "") # raw1=raw1.replace("'","\"") # raise Warning(raw1) # raw=json.loads(raw1) a.systempay_ref=vads_order_id_s[1].replace("'","") break