Got it working by adding float to the compute..thanks
On Tuesday, August 27, 2013 2:14:17 PM UTC-7, greenpoise wrote:
>
> I fixed the typo. No error though! I just get None as my value.
>
>
>
>
> On Tuesday, August 27, 2013 2:08:45 PM UTC-7, Anthony wrote:
>>
>> I would think you would get an error since both price and
>> pricecoefficient appear to be strings rather than numeric types (also,
>> pricecoefficient is misspelled in the table definition).
>>
>> Anthony
>>
>> On Tuesday, August 27, 2013 1:37:51 PM UTC-7, greenpoise wrote:
>>>
>>> I get NONE. I have these:
>>>
>>> db.define_table('supplier',
>>> Field('suppliercode'),
>>> Field('suppliername'),
>>> Field('pricecoeficient'),
>>> format='%(suppliercode)s')
>>>
>>> db.define_table('product',
>>> Field('series', 'reference series'),
>>> Field('suppliercode','reference supplier'),
>>> Field('price'),
>>> Field('cost',compute=lambda r: r['price']*db.supplier[r.supplier_id
>>> ].pricecoefficient))
>>>
>>> and I am using SQLFORM.grid which automatically assigns a supplier to
>>> the record. I assumed it would pick up the pricecoefficient and do the
>>> calculation but I think I am missing something.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Tuesday, August 27, 2013 1:13:58 PM UTC-7, Massimo Di Pierro wrote:
>>>>
>>>> I do not know the model but looks plausible. does it not work?
>>>>
>>>> On Tuesday, 27 August 2013 13:02:08 UTC-5, greenpoise wrote:
>>>>>
>>>>> Is this correct?
>>>>>
>>>>> Field('cost',compute=lambda r: r['price']*db.supplier[r.supplier_id].
>>>>> pricecoefficient)
>>>>>
>>>>>
>>>>>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.