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.
 
 

70 lines
2.5 KiB

# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError
from psycopg2 import sql, DatabaseError
from odoo.tools.safe_eval import safe_eval, datetime
from werkzeug import utils
class opendons_partneraddress(models.Model):
_name = 'opendons.partneraddress'
_description = 'adresses du contact'
_inherit = ['mail.thread']
#Complément d’identification du destinataire ou point de remise à l’intérieur du bâtiment : N° appartement, boite aux lettres, étage, couloir
complement_ident = fields.Char(string='N° appartment,floor',track_visibility='always')
#Complément d’identification du point géographique – extérieur du bâtiment : entrée, tour, bâtiment, immeuble, résidence
complement_geo = fields.Char(string='entry,tower,bat',track_visibility='always')
#Numéro et libellé de la voie
street1 = fields.Char(string='street1', track_visibility='always')
#Lieu dit ou service particulier de distribution – Poste restante, boite postale, etc.
street2 = fields.Char(string='street2',track_visibility='always')
#Code postal
postalcode = fields.Char(string='Postal code',track_visibility='always')
#Ville
city = fields.Char(string='City', track_visibility='always')
#Pays
country = fields.Char(string='Country', track_visibility='always')
#Compteur NPAI
npai=fields.Integer(readonly=True,string='NPAI counter',default=0,track_visibility='always')
#active
active=fields.Boolean(string='active',default=False,track_visibility='always')
date_inactive=fields.Date(readonly=True,string='Date inactive',track_visibility='always')
partner_id = fields.Many2one(
'res.partner',
string='partner',
required=True,
index=True,
readonly=True,
track_visibility='onchange',
ondelete='restrict'
)
def write(self,vals):
date_active=False
date_inactive=False
for val in vals:
if val=='active' and not vals['active']:
date_inactive=fields.Date.context_today(self)
if val=='active' and vals['active']:
date_inactive=False
date_active=fields.Date.context_today(self)
vals['date_inactive']=date_inactive
vals['date_active']=date_active
res = super(opendons_partneraddress, self).write(vals)
#Your code goes here
return res