← Back to team overview

openerp-dev-web team mailing list archive

Re: [Merge] lp:~openerp-dev/openobject-addons/trunk-bug-744789-qdp into lp:openobject-addons

 

On 04. 05. 11 17:09, qdp (OpenERP) wrote:
> while testing i found out that there was another bug: if i select the periods from 01/2011 -> 05/2011 it was displaying also the opening entries though it should have been added in the initial balance. 
>
> So i used this branch to fix that too. ;-)
>
> It will be merged into the trunk as soon as the errors in yaml will be fixed.
>
> Thanks
having a look at this code:

    def build_ctx_periods(self, cr, uid, period_from_id, period_to_id):
        period_from = self.browse(cr, uid, period_from_id)
        period_date_start = period_from.date_start
        company1_id = period_from.company_id.id
        period_to = self.browse(cr, uid, period_to_id)
        period_date_stop = period_to.date_stop
        company2_id = period_to.company_id.id
        if company1_id != company2_id:
            raise osv.except_osv(_('Error'), _('You should have chosen
periods that belongs to the same company'))
        if period_date_start > period_date_stop:
            raise osv.except_osv(_('Error'), _('Start period should be
smaller then End period'))
        return self.search(cr, uid, [('date_start', '>=',
period_date_start), ('date_stop', '<=', period_date_stop),
('company_id', '=', company1_id)])

i would say that it's a pitty that we start with precisely identified
periods (period_fom_id, period_to_id) to get lost in this "date" check.
but maybe this is the only way to get the result...

however, I do not understand how this check works, as there is no loop,
therefore, how the period_from.special gets [re]initialised.


	- return self.search(cr, uid, [('date_start', '>=', period_date_start),
('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)])
18 	+ #for period from = january, we want to exclude the opening period
(but it has same date_from, so we have to check if period_from is
special or not to include that clause or not in the search).
19 	+ if period_from.special:
20 	+ return self.search(cr, uid, [('date_start', '>=',
period_date_start), ('date_stop', '<=', period_date_stop),
('company_id', '=', company1_id)])
21 	+ return self.search(cr, uid, [('date_start', '>=',
period_date_start), ('date_stop', '<=', period_date_stop),
('company_id', '=', company1_id), ('special', '=', False)])



I think that the solution is NOT the best one, as you [want to] check
whether or not the period is "special". A proper identification

 of the period would be maybe better, as I might want to print a report
with or without the closing period, and the easiest way is to select the
proper periods.

additionally, I am not sure it works for a special period and the end of
the year, or in the middle (e.g. quarterly closings).

thank you for giving a thought at my remarks.

regards,
Bogdan

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-744789-qdp/+merge/58334
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-744789-qdp.


References