« first day    last day (28 days later) » 

2:03 AM
@api.onchange('tipo_plan')
def _check_ tipo_plan(self):
if self. tipo_plan:
for rec in self:
if rec.tipo_plan=='Quarterly Student':
rec.duration = 3
elif rec.tipo_plan == 'Semestral Basic':
rec.duration= 6
elif rec.tipo_plan == 'Annual Full':
rec.duration = 12
 
2:21 AM
and erase , computer = "_ duration" after duration field
 
3:09 AM
tipo_plan = fields.Selection ([('Quarterly Student', 'Quarterly Student'), ('Basic Semester', 'Basic Semester'), ('Annual Full', 'Annual Full')])
duration = fields.Integer (string = "Duration (month)")

@api.onchange ('type_plan')
def _check_tipo_plan (self):
if self.tipo_plan:
for rec in self:
if rec.type_plan == 'Quarterly Student':
rec.duration = 3
elif rec.type_plan == 'Semestral Basic':
rec.duration = 6
elif rec.type_plan == 'Annual Full':
rec.duration = 12
edit the code that said but I see the same error yesterday "gimansio.profesor" that appeared when the code was bad
 
 
1 hour later…
4:21 AM
let me connect
 
4:36 AM
wait a minute
 
turn of translator
 
4:51 AM
it's wired
i need to think
you takeover you pc
while i found solution i'll tell you
do you use github
 
I do not think that is the problem because when you delete the code it works without problem, it must be a code error
let's see later that code then, you could help me in another one that I have little to solve
 
what problem you got
 
I want to validate the ID of my country
I have a code but I get an error
look
 
what does the pop up window says
 
local variable 'Profesor' referenced before assignment
error
i want the structure of my DNI to be warm
 
5:05 AM
I have seen you post in stackoverflow
 
which is xx.xxx.xxx-k or xx.xxx.xxx-0
 
the question i have never meet, i need to research this issue
do you post all the code in stackoverflow?
 
@api.constrains('rut')
def _rut_unique(self):
for r in self:
#
if not r.rut:
continue
Profesor = self.env['gimnasio.profesor'].search(
[
('rut', '=', r.rut),
('id', '!=', r.id),
])
if r.rut != "55.555.555-5" and Profesor:
raise ValidationError(u'El Rut debe ser único')
 
do you know if not r.rut actual means?
 
here i want the dni not to be repeated
 
5:13 AM
# look the scope that the variable Profsor you assign
# and look L#69 variable Profesor
# if r.rut == True what will happen in L#69?
you need to realize what does error says
local variable 'Profesor' referenced before assignment
Can you get it?
I think you need to realize this.
because this is a basic concept for programming
let me do an example
 
5:31 AM
tipo_plan = fields.Selection([('Quarterly Student', 'Quarterly Student'), ('Basic Semester', 'Basic Semester'),
('Annual Full', 'Annual Full')])
duration = fields.Integer(string="Duration (month)")

@api.onchange('tipo_plan')
def _check_tipo_plan(self):
if self.tipo_plan:
for rec in self:
if rec.tipo_plan == 'Quarterly Student':
rec.duration = 3

elif rec.tipo_plan == 'Semestral Basic':
rec.duration = 6
elif rec.tipo_plan == 'Annual Full':
rec.duration = 12
this is work for me
you try to fix it
you can try to fix the issue I mention
 
6:12 AM
I am confused, because other code is easier but in this i confuse myself, how could I put the second if first?
 
what do you want to do in _rut_unique()
list down your idea
 
i want a dni can not be repeated
for example : 18.575.634-3 this can be same of other user
 
so field rut cloud store in db as identity of user?
* could
 
6:29 AM
it is not the foreign key because it is the id
but it is unique for each person
 
so you want to check field rut's value whether it exist in db or not?
 
yes
if there is a rut in bd that a message comes out saying that thist rut is used
 
do you remember how i check reservation in db?
I user search(domian)
and len(search(domian)) to check if there any one record exist
same way in this issue
self.env['profesor'].search([domain])
 
6:45 AM
look mi code please
my
@api.constrains('rut')
def _check(self):
records = self.env["gimnasio.profesor"].search(['rut','=',self.rut),
('id', '!=', self.id)])
if len(records) > 0:
raise ValidationError('El Rut debe ser único')
 
ok
try it
run sever
rename function
if you mute this function will it work?
 
yes
but look
when i put any other letter that is not "k" it change all the rut
 
what do you mean 'is not k'
 
in chile the only letter that can go after the script in the rut is "K"
 
do you mean last letter must be k?
got it
mute it
try to type and save
not save yet
save and restart
name error tryit again
 
7:31 AM
ok ?
 
the error you got in profesor this morning
is because
wrong name of mthod
for example
I use @api.onchage()
correct name is onchange
can you got it?
 
so you should check every detail
and do you got the issue of 'local variable 'Profesor' referenced before assignment'
 
i do not have taht problem anymore because we change the method
 
7:36 AM
but you should realize what it happen
you will meet that someday
 
YOU have reason
 
you should learn how to use python by yourself
 
yes because in my school do not teacj python :(
 
there are a lot of resources in internt
 
def check():
if b==3:
a=1
if b==3 and a==1:
print('succes')
how would it be the correcr way?
 
7:40 AM
no origin version is
def check():
if a!=1:
b=3
if b==3 and a==1:
print('succes')
I just want to tell you
local variable can't not get in other scope
in this case local variable b is in the scope if a!=1
but we never enter there since a = 1
unless we change a's value
 
yeah
 
in my code of rut, you know how to write 7 or 8 numer in my rut before the script?
 
you should know the priority of programming
what do you mean
describe clearly
 
for example:
18565734
18575634-3
and
1857563-3
whit 7 and 8 number
 
7:52 AM
and then?
 
with
only wish taht you could put 6 or 7 before the script
 
you mean before '-' should contain 6 or 7 letter?
 
pat = re.compile('^\d{7,8}-[0-9k]')
does not work for you?
last word should be k
 
after '-' may go 1,2,3,4,5,6,7,8,9,0,k
 
8:05 AM
I'm not familiar with regex,
so it takes time to study
there a way in python but complicate.
 
oh I understand
 
you try youself , If i get way let have a disscuss.
 
then the code performed only works with k?
 
yeah
you can try to fix by list
put [1,2,3,4,5,6,7,8,9,0,k] in list
if self.rut[le-1:le] in list:
 
for i in range(len(rut)):
print(i)


0
1
2
3
4
5
6
7
8
why did he do this??
rut[8:9]= 5
 
8:24 AM
find last word
[x:y] extract form x to y position
 
oooh very good
 
8:39 AM
you know how to add this code
pat = re.compile ('^ \ d {7,8} - [0-9k]')
here
domain = [('rut', '=', self.rut), ('id', '! =', self.id)]
record = self.env ['gym.professor']. search (domain)
le = len (self.rut)
# if any record exist same rut name or
# last letter is not 'k' return warning
if len (record)> 0 or self.rut [le-1: le]! = 'k'or self.rut [le-1: le]! =' k ':
raise ValidationError ('repeated rut or last letter should be k')
 
but that do not match what you want
 
yes I know, but to have an idea where the code would go
 
8:58 AM
pat.search(self.rut)
if match pattern it will return true
 
could you add it to this code?
domain = [('rut', '=', self.rut), ('id', '! =', self.id)]
record = self.env ['gym.professor']. search (domain)
le = len (self.rut)
# if any record exist same rut name or
# last letter is not 'k' return warning
if len (record)> 0 or self.rut [le-1: le]! = 'k'or self.rut [le-1: le]! =' k ':
raise ValidationError ('repeated rut or last letter should be k')
 
just add pat = ... this line before if-condition
and in if-condition pat.search(self.rut):
if len(record)>0 or pat.search(self.rut):
you should try by yourself
pat = re.compile(r"^\d{7,8}-[0-9k]",re.M)
this work for me
you try and if any issue let's discuss
after '-' constraint only one letter?
 
9:18 AM
yes
only K
and 0,1,2,3,4,5,6,7,8,9
 
if xxxxxxx-xx is not availiable
 
and how about 1234567-k0?
 
then this can't work
pat = re.compile(r"^\d{7,8}-[0-9k]",re.M)
 
9:21 AM
I use that code but could only type 6 numbers, not 7 or 8
before '-'
 
which code
 
@api.constrains('rut')
def _cons(self):

domain = [('rut','=', self.rut),('id','!=', self.id)]
record = self.env['gimnasio.profesor'].search(domain)
le = len(self.rut)

pat = re.compile(r"^\d{7,8}-[0-9k]",re.M)
if len(record)>0 or pat.search(self.rut):
raise ValidationError('error')
 
because you contain '.', right?
dot
 
no
only '-'
I delete '.'
 
9:45 AM
I need to test in debug mode
your editor do not have that function
I'll test later
 
i have other editor
pycharm¡
?
 
pycharm is ok
but have to set conifgur
take a break
 
10:44 AM
ready bro?
 
setting take a lot of time
I test it in my env
 
11:07 AM
do you modified anything
 
in pycharm do you modified anything?
 
pychar modified
 
I need afk for one hour
can you find it?
 
already solve the error
new error
object of type 'bool' has no len()
now the friend code works, thank you very much
tomorrow we continue talking, now I will go to sleep because in Chile it is 7:30 A.M.
If you have time, could you fix this code? #@api.onchange ('type_plan')
#def _check_tipo_plan (self):
#if self.tipo_plan:
#for rec in self:
#if rec.type_plan == 'Quarterly Student':
# rec.duration = 3
#elif rec.tipo_plan == 'Semiannual Basic':
# rec.duration = 6
#elif rec.type_plan == 'Annual Full':
# rec.duration = 12
tipo_plan = fields.Selection ([('Quarterly Student', 'Quarterly Student'), ('Basic Semester', 'Basic Semester'), ('Annual Full', 'Annual Full')])
duration = fields.Integer (string = "Duration (month)")
 
11:50 AM
ok, tommor I have work
i reply, If i am free
 
 
7 hours later…
7:08 PM
Thank you very much for all the help that my friend has given me.
 

« first day    last day (28 days later) »