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.
 
 

56 lines
1.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_partnerphone(models.Model):
_name = 'opendons.partnerphone'
_description = 'telephones du contact'
_inherit = ['mail.thread']
phone = fields.Char()
active=fields.Boolean(string='active',default=True,track_visibility='always')
date_active=fields.Date(readonly=True,string='Date active',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_partnerphone, self).write(vals)
#Your code goes here
return res