On 07/06/12 08:02 -0700, oscar_andres_col wrote:
> Hello, Developers
> 
> I am making a module with a Report about products in location for to
> see something this in report:
> 
> location: MyLocation
> 
>   product      quantity
> product A          5
> product B          3
> product C          10
> 
> 
> I get the view with path >Inventory &
> Stock>Locations>MyLocation>Wizard (date_end)>Products (MyLocation),
> 
> but I can't get data of this view because this data is computed with a
> context, so then the report .odt show this:
> 
>   product      quantity
> product A          0
> product B          0
> product C          0
> 
> I need get the context in my class report something like:
> 
> context = {'stock_date_end': datetime.date(2012, 6, 7), 'locations':
> [4], ... }
> 
> But I can't  get context, I tried this but did'nt work:
> 
> class StockProductReport(Report):
>     _name = 'product.product'
> 
>     def __init__(self):
>         super(StockProductReport, self).__init__()
> 
>     def parse(self, report, objects, datas, localcontext=None):
>         location_obj = Pool().get('stock.location')
>         uom_obj = Pool().get('product.uom')
> 
>         localcontext['stock_date_end'] =
> Transaction().context.get('stock_date_end'):
>         localcontext['locations'] =
> Transaction().context.get('locations'):
> 
>         with Transaction().set_context(localcontext):
>             for obj in objects:
>                  <<to do something>>
> 
>         return super(StockProductReport, self).parse(report,
>                 objects, datas, localcontext)
> 
> StockProductReport()

You must setup the context via a wizard.
You can find an example in
http://hg.tryton.org/modules/account/file/5a1c2d24c1af/account.py#l1155

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgp5i2iCw83El.pgp
Description: PGP signature

Reply via email to