in odoo 15
i made a new module
inside it i made
__init__.py
from . import models
__manifest__.py
# -*- coding: utf-8 -*-
{
'name': "Devis Sub_credit_tot",
'summary': """add subvention and credit steg and total à payer à devis
""",
'description': """
add subvention and credit steg and total à payer à devis
""",
'author': "jamel mharsi",
'website': "http://test.com",
'category': 'account',
'version': '1.0.0',
'data': [
'views/devis.xml',
],
'installable': True,
'auto_install': False,
}
**folder models
# __init__.py
from . import devis
#devis.py
from odoo import fields, models, api
class SaleOrder(models.Model):
_inherit = 'sale.order'
x_subvention_anme = fields.Float(string='Subvention Anme')
x_credit_steg = fields.Float(string='Credit Steg')
x_total_pay = fields.Float(string='Total à Payer', compute='_compute_total_pay', store=True)
@api.depends('amount_total', 'x_subvention_anme', 'x_credit_steg')
def _compute_total_pay(self):
for order in self:
order.x_total_pay = order.amount_total - order.x_subvention_anme - order.x_credit_steg
def write(self, vals):
if 'x_subvention_anme' in vals or 'x_credit_steg' in vals:
for order in self:
order.x_total_pay = order.amount_total - vals.get('x_subvention_anme', order.x_subvention_anme) - vals.get('x_credit_steg', order.x_credit_steg)
return super(SaleOrder, self).write(vals)
@api.model
def create(self, vals):
if 'x_subvention_anme' in vals or 'x_credit_steg' in vals:
total_pay = vals.get('amount_total', 0) - vals.get('x_subvention_anme', 0) - vals.get('x_credit_steg', 0)
vals['x_total_pay'] = total_pay
return super(SaleOrder, self).create(vals)
**folder static
image
**folder views
#devis.xml
steg_anme
sale.order
why got error 500