Example #1
0
 def read_group(self,
                cr,
                uid,
                domain,
                fields,
                groupby,
                offset=0,
                limit=None,
                context=None,
                orderby=False,
                lazy=True):
     fields_to_compute = []
     for field in ('commitment_amount', 'available_amount',
                   'practical_amount', 'theoritical_amount'):
         if field in fields:
             fields.remove(field)
             fields_to_compute.append(field)
     res = super(BudgetLine,
                 self).read_group(cr, uid, domain, fields, groupby, offset,
                                  limit, context, orderby, lazy)
     if fields_to_compute:
         for group in res:
             if group.get('__domain'):
                 line_infos = self.search_read(cr,
                                               uid,
                                               group['__domain'],
                                               fields_to_compute,
                                               context=context)
                 for field in fields_to_compute:
                     group[field] = sum([l[field] for l in line_infos])
     return res
Example #2
0
 def read(self,
          cr,
          user,
          ids,
          fields=None,
          context=None,
          load='_classic_read'):
     """
     Inherit this function to hide data of tab assets with user who is not
     user of employee or not in HR Manager
     """
     employee_env = self.pool['hr.employee']
     equip_benefit_fields = [
         'benefit_start', 'benefit_months', 'cred_benefit', 'debit_benefit',
         'balance_benefit', 'asset_ids', 'depreciate_line_ids',
         'it_equipment_bonus_ids'
     ]
     if len(ids) == 1:
         employee = employee_env.browse(cr, user, ids)
         if not self.can_read_equipment_benefit_info(
                 cr, user, employee.id, user):
             for field in equip_benefit_fields:
                 if field in fields:
                     fields.remove(field)
     res = super(hr_employee, self).read(cr,
                                         user,
                                         ids,
                                         fields=fields,
                                         context=context,
                                         load='_classic_read')
     return res
Example #3
0
 def _onchange_country_id(self):
     """Sensible values and domains for related fields."""
     fields = ['state_id', 'nuts1_id', 'nuts2_id', 'nuts3_id', 'nuts4_id']
     country_domain = ([('country_id', '=', self.country_id.id)]
                       if self.country_id else [])
     domain = dict()
     for field in fields:
         if self.country_id and self[field].country_id != self.country_id:
             self[field] = False
         domain[field] = list(country_domain)  # Using list() to copy
     fields.remove('state_id')
     for field in fields:
         level = int(field[:5][-1])
         if level:
             domain[field].append(('level', '=', level))
     if self.country_id:
         nuts1 = self.env['res.partner.nuts'].search([
             ('level', '=', 1),
             ('country_id', '=', self.country_id.id),
         ], limit=1)
         if self.nuts1_id.id != nuts1.id:
             self.nuts1_id = nuts1.id
     return {
         'domain': domain,
     }
Example #4
0
 def read_group(self,
                domain,
                fields,
                groupby,
                offset=0,
                limit=None,
                orderby=False,
                lazy=True):
     fields_to_compute = []
     for field in ('line_rate', 'branch_rate'):
         if field in fields:
             fields.remove(field)
             fields_to_compute.append(field)
     res = super(Coverage, self).read_group(domain, fields, groupby, offset,
                                            limit, orderby, lazy)
     if fields_to_compute:
         fields_to_read = [
             'line_count', 'branch_count', 'branch_rate', 'line_rate'
         ]
         for group in res:
             if group.get('__domain'):
                 line_infos = self.search_read(group['__domain'],
                                               fields_to_read)
                 line_counts = sum([l['line_count'] for l in line_infos])
                 branch_counts = sum(
                     [l['branch_count'] for l in line_infos])
                 group['line_rate'] = line_counts and \
                     sum([l['line_rate'] * l['line_count'] for l in line_infos]) / line_counts or 0
                 group['branch_rate'] = branch_counts and \
                     sum([l['branch_rate'] * l['branch_count'] for l in line_infos]) / branch_counts or 0
     return res
Example #5
0
    def generate_sip_peers(self):
        self.ensure_one()
        found_include = False
        sip_auto_conf = self.env['asterisk.conf'].search(['&',
            ('name', '=', 'sip_auto_peers.conf'),
            ('server', '=', self.server.id)])
        if not sip_auto_conf:
            sip_auto_conf = self.env['asterisk.conf'].create({
                'server': self.server.id,
                'name': 'sip_auto_peers.conf',
            })
        # Now let see if sip.conf includes sip_auto_peers
        sip_conf = self.env['asterisk.conf'].search(['&',
            ('server', '=', self.server.id),
            ('name', '=', 'sip.conf')])
        for line in sip_conf.content.split('\n'):
            if line.find('#tryinclude sip_auto_peers.conf') != -1:
                found_include = True
                break
        if not found_include:
            sip_conf.content += '\n\n#tryinclude sip_auto_peers.conf\n'

        peers = []
        content = u''
        # Now do some sorting. We want extensins first, then agents, providers and gws.
        peer_type_order = ['user', 'trunk']
        for pto in peer_type_order:
            found_peers = self.env['asterisk.sip_peer'].search(
                [('peer_type', '=', pto)], order='name')
            for p in found_peers:
                peers.append(p)
        # Now let proceed peer fields
        for peer in peers:
            fields =  peer.fields_get_keys()
            # Cleanup fields list to have only Asterisk options
            fields_to_remove = ['create_date', 'create_uid', 'display_name',
                                '__last_update', 'id', 'peer_type', 'server',
                                'regseconds_human', 'peer_statuses', 'peer_status_count',
                                'write_uid', 'write_date', 'note', 'name']
            # Sort!
            fields.sort()
            for f in fields_to_remove:
                fields.remove(f)
            # Create section
            content += u'[{}] ;{}\n'.format(peer.name, peer.note) if peer.note \
                else u'[{}]\n'.format(peer.name)
            gen = [f for f in fields if getattr(peer, f) != False]
            for f in gen:
                content += u'{} = {}\n'.format(f, getattr(peer, f))
            content += '\n'
        # Save config
        sip_auto_conf.content = content
        if found_include:
            sip_auto_conf.upload_conf()
        else:
            sip_auto_conf.server.upload_all_conf()
Example #6
0
    def read_group(self,cr,uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False,lazy=True):
        if 'customer_lead' in fields:
            fields.remove('customer_lead')
	if 'price_unit' in fields:
	    fields.remove('price_unit')
	#if 'reserved_qty' in fields:
	#	fields.remove('reserved_qty')
	#if 'pending_qty' in fields:
	#	fields.remove('pending_qty')
	#if 'n_extra_qty' in fields:
	#	fields.remove('n_extra_qty')
        return super(SaleOrderLine, self).read_group(cr,uid,domain,fields, groupby, offset, limit=limit, context=context, orderby=orderby,lazy=lazy)
    def read_group(self,
                   cr,
                   uid,
                   domain,
                   fields,
                   groupby,
                   offset=0,
                   limit=None,
                   context=None,
                   orderby=False,
                   lazy=True):
        """Remove sum of .
        """

        # No need to sum time_start, time_end, sign_in and sign_out
        if 'time_start' in fields:
            fields.remove('time_start')

        if 'time_end' in fields:
            fields.remove('time_end')

        if 'sign_in' in fields:
            fields.remove('sign_in')

        if 'sign_out' in fields:
            fields.remove('sign_out')

        return super(FingerAttendance,
                     self).read_group(cr, uid, domain, fields, groupby, offset,
                                      limit, context, orderby, lazy)
Example #8
0
 def read(self,
          cr,
          uid,
          ids,
          fields=None,
          context=None,
          load='_classic_read'):
     # Hack for binary compatibility
     add_datas_size = False
     if context.get('bin_size') and 'datas' in fields:
         fields.remove('datas')
         fields.append('human_file_size')
         add_datas_size = True
     res = super(ProductMedia, self).read(cr,
                                          uid,
                                          ids,
                                          fields=fields,
                                          context=context,
                                          load=load)
     if add_datas_size:
         for record in res:
             record['datas'] = record['human_file_size']
     return res
Example #9
0
    def read_group(self,
                   cr,
                   uid,
                   domain,
                   fields,
                   groupby,
                   offset=0,
                   limit=None,
                   context=None,
                   orderby=False,
                   lazy=True):
        if 'estimated_annual_volume' in fields:
            fields.remove('estimated_annual_volume')
        if 'purchase_undelivered_limit' in fields:
            fields.remove('purchase_undelivered_limit')
        if 'property_evaluation' in fields:
            fields.remove('property_evaluation')
        if 'ppkg' in fields:
            fields.remove('ppkg')

        if 'm2mlimit' in fields:
            fields.remove('m2mlimit')

        if 'negative_m2m_loss_limit' in fields:
            fields.remove('negative_m2m_loss_limit')

        if 'realizable' in fields:
            fields.remove('realizable')

        if 'marked_to_marke' in fields:
            fields.remove('marked_to_marke')

        if 'limit_qty' in fields:
            fields.remove('limit_qty')

        if 'limit_value' in fields:
            fields.remove('limit_value')

        if 'ttl_m2m' in fields:
            fields.remove('ttl_m2m')

        if 'negative_m2m' in fields:
            fields.remove('negative_m2m')

        res = super(SupplierManagementLine, self).read_group(cr,
                                                             uid,
                                                             domain,
                                                             fields,
                                                             groupby,
                                                             offset=offset,
                                                             limit=limit,
                                                             context=context,
                                                             orderby=orderby,
                                                             lazy=lazy)
        return res
Example #10
0
 def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
     if 'periodo' in fields:
         fields.remove('periodo')
     return super(grp_pep_movimiento_ejecucion, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
Example #11
0
    def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
        """ Update aggregate number"""

        obj = self.env['estate_rainfall.rainfall']

        if 'time_start' in fields:
            fields.remove('time_start')

        if 'time_end' in fields:
            fields.remove('time_end')

        # remove total value
        if 'date:year' in groupby and 'date_month' not in groupby:
            fields.remove('day')
            fields.remove('volume')

        # remove monthly value
        if 'date_month' in groupby and 'block_id' not in groupby:
            fields.remove('day')
            fields.remove('volume')

        # remove monthly grand total
        # if 'date_month' in groupby and 'block_id' in groupby and 'date:year' not in groupby:
        #     fields.remove('day')
        #     fields.remove('volume')

        res = super(Rainfall, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)

        return res