El 28 de marzo de 2012 05:07, hynekcer <hy...@sdb.cz> escribió:

> "unit_price" is the simplest case _calculated_ from db values, not
> stored. You can have a price for 1 piece and a better price valid for
> 5 pieces and more and other better price valid only until tomorrow and
> you can have a complicated configurable product with adjustments for
> different options like the computer. :)
>

I figured out this after sending the e-mail


>
> You can do something more general like
>
>    for product in products:
>        for subproduct in product.get_subtype_with_attr('unit_price'):
>           for priceobj in subproduct.price_set.all():
>               priceobj.price = priceobj.price * CONST
>
>
> or for the easiest case you want, do simply
>

Well in my case was enough to apply the solution above



>
>    for priceobj in Price.objects.all():
>        priceobj.price = priceobj.price * CONST
>
> eventually
> python manage.py satchmo_rebuild_pricing for variants etc.
>
>
That did the trick!.

Thanks.



> -- Hyn
>
> On 27 bře, 21:31, Ángel Velásquez <an...@bixti.com> wrote:
> > Hello people,
> >
> > I was facing an issue increasing the unit_price of all products of the
> db.
> >
> > I need to do this because all the products got increased by 5% .. so I
> > wrote the following django command.
> >
> > [code]
> >
> > from django.core.management.base import BaseCommand, CommandError
> > from django.conf import settings
> > from django.core.exceptions import ValidationError
> >
> > from product.models import Product
> >
> > from decimal import Decimal
> >
> > INCREMENT_RATE = Decimal('0.10')
> >
> > class Command(BaseCommand):
> >     args = ''
> >     help = 'Increase products in 10%'
> >
> >     def handle(self, *args, **options):
> >         products = Product.objects.all()
> >
> >         for product in products:
> >             new_val = product.unit_price * CONVERSION_RATE
> >             product.unit_price = new_val
> >             product.save()
> > [/code]
> >
> > But I get this error:
> >
> > AttributeError: can't set attribute
> >
> > Could somebody give me a light?. I can't do this using the form because I
> > have to increase the value of all the products on the DB, and doing one
> by
> > one i'd by painful.
> >
> > Thanks in advance.
> >
> > --
> > github: angvp
> > Ángel Velásquez
>
> --
> You received this message because you are subscribed to the Google Groups
> "Satchmo users" group.
> To post to this group, send email to satchmo-users@googlegroups.com.
> To unsubscribe from this group, send email to
> satchmo-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/satchmo-users?hl=en.
>
>


-- 
Ángel Velásquez
Jedi Master CTO
Bixti.com <http://bixti.com/>
an...@bixti.com
(00549)11.5980.7308
skype: angelvelasquez_ve
github: angvp

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to satchmo-users@googlegroups.com.
To unsubscribe from this group, send email to 
satchmo-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to