Odoo Help


getting users in a month

Segun Adesanya
on 12/15/15, 9:25 AM 507 views


from openerp import api, fields, models

import date

class fido_bagging(models.Model):

_name = "fido.bagger"

name = fields.Many2one('hr.employee',string='Bagger', size=32, required=True)

fido_date = fields.Datetime(string='Date')

x_quantity = fields.Integer(string="No of Bags")

class fido_bagging_inherit(models.Model):

_inherit = "hr.employee"

dummy_object = fields.One2many('fido.bagger', 'name', size=32)


def compute_bag_total(self):

cursor = self._cr

user = self._uid

for employees in self:

today = datetime.datetime.today()

start_date = str(today.replace(day=1).strftime('%m/%d/%Y'))

next_month = today.replace(day=28) + datetime.timedelta(days=4)

end_date = str(next_month - datetime.timedelta(days=next_month.day-1))

print ("########START DATE", start_date)

print ("######## END DATE", end_date)

#look up the bagging records

fido_bagger_obj = self.pool.get('fido.bagger')

bagger_ids = fido_bagger_obj.search(cursor, user,[('fido_date','>=',start_date),('fido_date','<=',end_date),('name','=',employees.name)])

# bagger_ids = fido_bagger_obj.search(cursor, user, [('name','=',employees.id)])

total = 0.0

for fido_bagger in fido_bagger_obj.browse(cursor, user, bagger_ids):

total += fido_bagger.x_quantity

employees.mtd_bag = total

mtd_bag = fields.Float(compute='compute_bag_total',string="Month Bag")


 im trying to get the total amount of bags sold in each month for all the employees that are baggers

I'm going to watch this subject, need something similar to this but in products :)

Dr Obx
on 12/15/15, 10:52 AM

i solved it eventually. i changed my strftime format to (%Y-%m-%d)

Segun Adesanya
on 12/16/15, 6:22 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 12/15/15, 9:25 AM
Seen: 507 times
Last updated: 12/15/15, 10:08 AM