Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3473 Zobrazení


 

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)

@api.one

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

Avatar
Zrušit

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

Autor

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

Related Posts Odpovědi Zobrazení Aktivita
3
čvn 25
1163
1
led 25
18023
1
led 20
3991
1
pro 19
6440
1
pro 19
17333