You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
4.0 KiB
84 lines
4.0 KiB
# -*- coding: utf-8 -*-
|
|
#############################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
#
|
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
|
|
# Author: Gayathri V @cybrosys (odoo@cybrosys.com)
|
|
#
|
|
# You can modify it under the terms of the GNU AFFERO
|
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
|
|
#
|
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
# (AGPL v3) along with this program.
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
#############################################################################
|
|
from odoo import api, fields, models, _
|
|
|
|
|
|
class ClaimDetails(models.Model):
|
|
"""This class creates a model 'claim.details' and added fields """
|
|
_name = 'claim.details'
|
|
_description = "Claim Details"
|
|
|
|
name = fields.Char(string='Name', copy=False,
|
|
readonly=True, index=True, default=lambda self: _('New'),
|
|
help="Sequence for claim details")
|
|
insurance_id = fields.Many2one('insurance.details', required=True,
|
|
domain=[('state', '=', 'confirmed')],
|
|
string="Insurance",
|
|
help="Confirmed orders can be selected")
|
|
partner_id = fields.Many2one(related='insurance_id.partner_id',
|
|
string='Customer',
|
|
help="Partner related to insurance")
|
|
policy_id = fields.Many2one(related='insurance_id.policy_id',
|
|
string='Policy',
|
|
help="Policy related to insurance")
|
|
employee_id = fields.Many2one(related='insurance_id.employee_id',
|
|
string='Agent',
|
|
help="Employee related to insurance")
|
|
currency_id = fields.Many2one('res.currency', string='Currency',
|
|
required=True, default=lambda
|
|
self: self.env.user.company_id.currency_id.id,
|
|
help="Default currency of the claim")
|
|
amount = fields.Monetary(related='insurance_id.amount', string='Amount',
|
|
help="Amount related to insurance")
|
|
date_claimed = fields.Date(string='Date Applied',
|
|
default=fields.Date.today(),
|
|
help="Date of apply of claim details")
|
|
invoice_id = fields.Many2one('account.move', string='Invoiced',
|
|
readonly=True, copy=False,
|
|
help="Invoice related to the claim")
|
|
note_field = fields.Html(string='Comment', help="Extra notes for the claim")
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
"""Function to create sequence"""
|
|
if vals_list[0].get('name', 'New') == 'New':
|
|
vals_list[0]['name'] = self.env['ir.sequence'].next_by_code(
|
|
'claim.details') or 'New'
|
|
return super(ClaimDetails, self).create(vals_list)
|
|
|
|
def action_create_bill(self):
|
|
"""Function to create bill with corresponding details"""
|
|
if not self.invoice_id:
|
|
invoice_val = self.env['account.move'].sudo().create({
|
|
'move_type': 'in_invoice',
|
|
'invoice_date': fields.Date.today(),
|
|
'partner_id': self.partner_id.id,
|
|
'invoice_user_id': self.env.user.id,
|
|
'claim_id': self.id,
|
|
'invoice_origin': self.name,
|
|
'invoice_line_ids': [(fields.Command.create({
|
|
'name': 'Invoice For Insurance Claim',
|
|
'quantity': 1,
|
|
'price_unit': self.amount
|
|
}))],
|
|
})
|
|
self.invoice_id = invoice_val
|
|
|