Slink/sos_inventory/models/sos_service_providers.py

59 lines
2.5 KiB
Python
Executable File

# -*- coding: utf-8 -*-
from odoo import models, fields, api
class SOS_Service_Providers(models.Model):
_name = 'sos_service_providers'
_description = 'Service Providers of Sosaley'
_rec_name="service_provider_name"
service_provider_code = fields.Char(string="Service Provider Code", required=True, readonly=True,
default=lambda self: self._generate_id())
service_provider_name = fields.Char(string="Service Provider Name", required=True)
qp_no= fields.Char(string="QP No")
address = fields.Char(string="Registered Address")
shipped_from_address = fields.Char(string="Shipped From")
contact_person = fields.Char(string="Contact Person")
contact_no = fields.Char(string="Contact no")
email = fields.Char(string="Email")
gst_no = fields.Char(string="GST No")
pan_no = fields.Char(string="PAN No")
cin_no = fields.Char(string="CIN No")
msme_no = fields.Char(string="MSME Certificate No")
bank_details = fields.Text(string="Bank Details")
iso_no = fields.Char(string="ISO Certificate No")
iso_date = fields.Date(string="ISO Certificate Validity Date")
scope = fields.Char(string="Scope of Service")
approval=fields.Date(string="Approved On")
last_evaluation_date=fields.Date(string="Last Evaluated On")
re_evaluation_due_date=fields.Date(string="Re-Evaluation Due on")
re_evaluation_method=fields.Char(string="Re-Evaluation Method")
credit_period = fields.Integer(string="Credit period(In days)")
other_terms = fields.Text(string="Other Terms & Conditions")
quality_policy = fields.Binary(string="Quality policy")
quality_policy_filename=fields.Char(string="Quality Policy File Name")
sarf_doc = fields.Binary(string="SARF Document")
sarf_doc_filename=fields.Char(string="SARF Document File Name")
iso_certificate = fields.Binary(string="ISO Certificate")
iso_certificate_filename=fields.Char(string="ISO Certificate File Name")
_sql_constraints = [
('name_unique', 'UNIQUE(service_provider_name)', 'This Service Provider is Already In Our Records')
]
def _generate_id(self):
prefix = "SOS/SARF/SER/"
last_record = self.search([
('service_provider_code', 'like', prefix + '%')
], order='service_provider_code desc', limit=1)
if last_record:
last_code = last_record.service_provider_code
next_number = int(last_code[len(prefix):]) + 1
else:
next_number = 1
return f"{prefix}{next_number:03d}"