Re: [web2py] Re: Creating a batch using a loop

2016-09-26 Thread Oasis Agano
I solved it already using sqlform factory then if form accepted do the loops... and thanks for your help On Tuesday, September 27, 2016 at 5:48:14 AM UTC+3, Jim S wrote: > > You don't have to pass it. Just use the DAL to insert the records you > need. > > What fields are you having the user e

Re: [web2py] Re: Creating a batch using a loop

2016-09-26 Thread Jim Steil
You don't have to pass it. Just use the DAL to insert the records you need. What fields are you having the user enter data into when the form is displayed? You can just use SQLFORM.factory to gather them. Then in the 'if form.process().accepted:' put the code to insert the records into the data

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Dave S
On Monday, September 26, 2016 at 1:34:00 PM UTC-7, Oasis Agano wrote: > > Briefly what im trying to do is to create payslips for all contracts in > the db through a loop, > I don't understand. Is what is supposed to be done a response to a user? Is that user an employee logging the time spen

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Anthony
Note, you don't have to use SQLFORM.factory -- you can simply use SQLFORM and either call form.validate() or form.process(dbio=False) -- both of those options do the form validation but do not do any database insert. SQLFORM.factory is typically used when you need to create a form that is not b

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Oasis Agano
Well all the answers helped but the sqlform factory solved it On Monday, September 26, 2016 at 3:29:35 PM UTC+3, Oasis Agano wrote: > > Greetings > im creating a payroll app and i need a to create a batch of payslips > > i want to create payslips for all contracts in the database within the > run

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Oasis Agano
Briefly what im trying to do is to create payslips for all contracts in the db through a loop, i just checked sqlform factory but i have a question where do i pass the form(payslip table) to insert in into after if form.process().accepts: On Monday, September 26, 2016 at 11:09:52 PM UTC+3, Jim S

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Jim S
I think that is all that it should do. Your check_batch function is being called at the validation stage of processing your form. All your check_batch function does is reassign values to the form variables that you've captured. After it is done, the web2py form processing will insert the curr

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Oasis Agano
Well its progressing now, using form.vars.employee=contraa.employee form.vars.payslip_name=contraa.employee.fullname form.vars.contract=contraa.id Now it is inserting only one payslip(from one contract) but not inserting the other one On Monday, September 26, 2016 at 7:54:03 PM UTC+3, Jim S

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Jim S
You're setting form.vars.employee = contraa.employee.fullname It should be set to the employee id, not the name. Results in the same problem as with contract name/id. Should just be contraa.employee I believe... -Jim On Monday, September 26, 2016 at 10:23:15 AM UTC-5, Oasis Agano wrote: > >

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Oasis Agano
i changed it to form.vars.contract = contraa.id but still getting the same error On Monday, September 26, 2016 at 5:39:41 PM UTC+3, Anthony wrote: > > In your model, db.payslip.contract is a reference field, but in your code, > you attempt to assign a string value to it (form.vars.contract = > c

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Anthony
In your model, db.payslip.contract is a reference field, but in your code, you attempt to assign a string value to it (form.vars.contract = contraa.contract_name). Anthony On Monday, September 26, 2016 at 10:04:30 AM UTC-4, Oasis Agano wrote: > > Models are here, if this way cant work can you s

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Oasis Agano
Models are here, if this way cant work can you suggest another way of doing it MARITAL_SET = [ T('Single'), T('Married'), T('Divorced'), T('Widower') ] TIME_SET = [ T('Part time'), T('Full time'), ] STATE_SET = [ T('Trial'), T('Employed'), T('Fired'),

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Anthony
Well, you still haven't shown your models. My guess is one of your fields is a reference field, which stores long int values representing the record ID of the referenced record, but you are attempting to insert a string value. Anyway, your approach won't work because SQLFORM only does a single

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Oasis Agano
TRACEBACK Traceback (most recent call last): File "D:\lab\PycharmProjects\Smartwork\web2py\gluon\restricted.py", line 227, in restricted exec ccode in environment File "D:/lab/PycharmProjects/Smartwork/web2py/applications/smartwork/controllers/default.py"

Re: [web2py] Re: Creating a batch using a loop

2016-09-26 Thread Michele Comitini
Could be an issue with some reference field. Are you using a IS_IN_DB validator in your model? could be that you are passing a wrong parameter to the validator. But with so little info it is just a guess. 2016-09-26 15:21 GMT+02:00 Anthony : > Hard to say what the problem is without seeing t

[web2py] Re: Creating a batch using a loop

2016-09-26 Thread Anthony
Hard to say what the problem is without seeing the full traceback as well as your models. Also, what are you trying to do in the check_batch function? You are looping through some records and making assignments to form.vars, but only the final run of the loop will end up taking effect -- so wha