• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python float_utils.float_round函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中odoo.tools.float_utils.float_round函数的典型用法代码示例。如果您正苦于以下问题:Python float_round函数的具体用法?Python float_round怎么用?Python float_round使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了float_round函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _compute_duration_display

 def _compute_duration_display(self):
     for allocation in self:
         allocation.duration_display = '%g %s' % (
             (float_round(allocation.number_of_hours_display, precision_digits=2)
             if allocation.type_request_unit == 'hour'
             else float_round(allocation.number_of_days_display, precision_digits=2)),
             _('hours') if allocation.type_request_unit == 'hour' else _('days'))
开发者ID:Vauxoo,项目名称:odoo,代码行数:7,代码来源:hr_leave_allocation.py


示例2: _compute_quantities_dict

    def _compute_quantities_dict(self, lot_id, owner_id, package_id, from_date=False, to_date=False):
        domain_quant_loc, domain_move_in_loc, domain_move_out_loc = self._get_domain_locations()
        domain_quant = [('product_id', 'in', self.ids)] + domain_quant_loc
        dates_in_the_past = False
        # only to_date as to_date will correspond to qty_available
        to_date = fields.Datetime.to_datetime(to_date)
        if to_date and to_date < fields.Datetime.now():
            dates_in_the_past = True

        domain_move_in = [('product_id', 'in', self.ids)] + domain_move_in_loc
        domain_move_out = [('product_id', 'in', self.ids)] + domain_move_out_loc
        if lot_id is not None:
            domain_quant += [('lot_id', '=', lot_id)]
        if owner_id is not None:
            domain_quant += [('owner_id', '=', owner_id)]
            domain_move_in += [('restrict_partner_id', '=', owner_id)]
            domain_move_out += [('restrict_partner_id', '=', owner_id)]
        if package_id is not None:
            domain_quant += [('package_id', '=', package_id)]
        if dates_in_the_past:
            domain_move_in_done = list(domain_move_in)
            domain_move_out_done = list(domain_move_out)
        if from_date:
            domain_move_in += [('date', '>=', from_date)]
            domain_move_out += [('date', '>=', from_date)]
        if to_date:
            domain_move_in += [('date', '<=', to_date)]
            domain_move_out += [('date', '<=', to_date)]

        Move = self.env['stock.move']
        Quant = self.env['stock.quant']
        domain_move_in_todo = [('state', 'in', ('waiting', 'confirmed', 'assigned', 'partially_available'))] + domain_move_in
        domain_move_out_todo = [('state', 'in', ('waiting', 'confirmed', 'assigned', 'partially_available'))] + domain_move_out
        moves_in_res = dict((item['product_id'][0], item['product_qty']) for item in Move.read_group(domain_move_in_todo, ['product_id', 'product_qty'], ['product_id'], orderby='id'))
        moves_out_res = dict((item['product_id'][0], item['product_qty']) for item in Move.read_group(domain_move_out_todo, ['product_id', 'product_qty'], ['product_id'], orderby='id'))
        quants_res = dict((item['product_id'][0], item['quantity']) for item in Quant.read_group(domain_quant, ['product_id', 'quantity'], ['product_id'], orderby='id'))
        if dates_in_the_past:
            # Calculate the moves that were done before now to calculate back in time (as most questions will be recent ones)
            domain_move_in_done = [('state', '=', 'done'), ('date', '>', to_date)] + domain_move_in_done
            domain_move_out_done = [('state', '=', 'done'), ('date', '>', to_date)] + domain_move_out_done
            moves_in_res_past = dict((item['product_id'][0], item['product_qty']) for item in Move.read_group(domain_move_in_done, ['product_id', 'product_qty'], ['product_id'], orderby='id'))
            moves_out_res_past = dict((item['product_id'][0], item['product_qty']) for item in Move.read_group(domain_move_out_done, ['product_id', 'product_qty'], ['product_id'], orderby='id'))

        res = dict()
        for product in self.with_context(prefetch_fields=False):
            product_id = product.id
            rounding = product.uom_id.rounding
            res[product_id] = {}
            if dates_in_the_past:
                qty_available = quants_res.get(product_id, 0.0) - moves_in_res_past.get(product_id, 0.0) + moves_out_res_past.get(product_id, 0.0)
            else:
                qty_available = quants_res.get(product_id, 0.0)
            res[product_id]['qty_available'] = float_round(qty_available, precision_rounding=rounding)
            res[product_id]['incoming_qty'] = float_round(moves_in_res.get(product_id, 0.0), precision_rounding=rounding)
            res[product_id]['outgoing_qty'] = float_round(moves_out_res.get(product_id, 0.0), precision_rounding=rounding)
            res[product_id]['virtual_available'] = float_round(
                qty_available + res[product_id]['incoming_qty'] - res[product_id]['outgoing_qty'],
                precision_rounding=rounding)

        return res
开发者ID:datenbetrieb,项目名称:odoo,代码行数:60,代码来源:product.py


示例3: trans_rec_get

 def trans_rec_get(self):
     context = self._context or {}
     credit = debit = 0
     lines = self.env['account.move.line'].browse(context.get('active_ids', []))
     for line in lines:
         if not line.reconciled:
             credit += line.credit
             debit += line.debit
     precision = self.env.user.company_id.currency_id.decimal_places
     writeoff = float_round(debit - credit, precision_digits=precision)
     credit = float_round(credit, precision_digits=precision)
     debit = float_round(debit, precision_digits=precision)
     return {'trans_nbr': len(lines), 'credit': credit, 'debit': debit, 'writeoff': writeoff}
开发者ID:ADS101,项目名称:odoo,代码行数:13,代码来源:account_reconcile.py


示例4: _quant_split

 def _quant_split(self, qty):
     self.ensure_one()
     rounding = self.product_id.uom_id.rounding
     if float_compare(abs(self.qty), abs(qty), precision_rounding=rounding) <= 0: # if quant <= qty in abs, take it entirely
         return False
     qty_round = float_round(qty, precision_rounding=rounding)
     new_qty_round = float_round(self.qty - qty, precision_rounding=rounding)
     # Fetch the history_ids manually as it will not do a join with the stock moves then (=> a lot faster)
     self._cr.execute("""SELECT move_id FROM stock_quant_move_rel WHERE quant_id = %s""", (self.id,))
     res = self._cr.fetchall()
     new_quant = self.sudo().copy(default={'qty': new_qty_round, 'history_ids': [(4, x[0]) for x in res]})
     self.sudo().write({'qty': qty_round})
     return new_quant
开发者ID:befks,项目名称:odoo,代码行数:13,代码来源:stock_quant.py


示例5: _quant_create_from_move

    def _quant_create_from_move(
        self,
        qty,
        move,
        lot_id=False,
        owner_id=False,
        src_package_id=False,
        dest_package_id=False,
        force_location_from=False,
        force_location_to=False,
    ):
        """Create a quant in the destination location and create a negative
        quant in the source location if it's an internal location. """
        price_unit = move.get_price_unit()
        location = force_location_to or move.location_dest_id
        rounding = move.product_id.uom_id.rounding
        vals = {
            "product_id": move.product_id.id,
            "location_id": location.id,
            "qty": float_round(qty, precision_rounding=rounding),
            "cost": price_unit,
            "history_ids": [(4, move.id)],
            "in_date": datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
            "company_id": move.company_id.id,
            "lot_id": lot_id,
            "owner_id": owner_id,
            "package_id": dest_package_id,
        }
        if move.location_id.usage == "internal":
            # if we were trying to move something from an internal location and reach here (quant creation),
            # it means that a negative quant has to be created as well.
            negative_vals = vals.copy()
            negative_vals["location_id"] = force_location_from and force_location_from.id or move.location_id.id
            negative_vals["qty"] = float_round(-qty, precision_rounding=rounding)
            negative_vals["cost"] = price_unit
            negative_vals["negative_move_id"] = move.id
            negative_vals["package_id"] = src_package_id
            negative_quant_id = self.sudo().create(negative_vals)
            vals.update({"propagated_from_id": negative_quant_id.id})

        picking_type = move.picking_id and move.picking_id.picking_type_id or False
        if (
            lot_id
            and move.product_id.tracking == "serial"
            and (not picking_type or (picking_type.use_create_lots or picking_type.use_existing_lots))
        ):
            if qty != 1.0:
                raise UserError(_("You should only receive by the piece with the same serial number"))

        # create the quant as superuser, because we want to restrict the creation of quant manually: we should always use this method to create quants
        return self.sudo().create(vals)
开发者ID:GabbasovDinar,项目名称:odoo,代码行数:51,代码来源:stock_quant.py


示例6: get_opening_move_differences

    def get_opening_move_differences(self, opening_move_lines):
        currency = self.currency_id
        balancing_move_line = opening_move_lines.filtered(lambda x: x.account_id == self.get_unaffected_earnings_account())

        debits_sum = credits_sum = 0.0
        for line in opening_move_lines:
            if line != balancing_move_line:
                #skip the autobalancing move line
                debits_sum += line.debit
                credits_sum += line.credit

        difference = abs(debits_sum - credits_sum)
        debit_diff = (debits_sum > credits_sum) and float_round(difference, precision_rounding=currency.rounding) or 0.0
        credit_diff = (debits_sum < credits_sum) and float_round(difference, precision_rounding=currency.rounding) or 0.0
        return debit_diff, credit_diff
开发者ID:ovnicraft,项目名称:odoo,代码行数:15,代码来源:company.py


示例7: _inverse_remaining_leaves

 def _inverse_remaining_leaves(self):
     status_list = self.env['hr.leave.type'].search([('limit', '=', False)])
     # Create leaves (adding remaining leaves) or raise (reducing remaining leaves)
     actual_remaining = self._get_remaining_leaves()
     for employee in self.filtered(lambda employee: employee.remaining_leaves):
         # check the status list. This is done here and not before the loop to avoid raising
         # exception on employee creation (since we are in a computed field).
         if len(status_list) != 1:
             raise UserError(_("The feature behind the field 'Remaining Legal Leaves' can only be used when there is only one "
                 "leave type with the option 'Allow to Override Limit' unchecked. (%s Found). "
                 "Otherwise, the update is ambiguous as we cannot decide on which leave type the update has to be done. "
                 "\n You may prefer to use the classic menus 'Leave Requests' and 'Allocation Requests' located in Leaves Application "
                 "to manage the leave days of the employees if the configuration does not allow to use this field.") % (len(status_list)))
         status = status_list[0] if status_list else None
         if not status:
             continue
         # if a status is found, then compute remaing leave for current employee
         difference = float_round(employee.remaining_leaves - actual_remaining.get(employee.id, 0), precision_digits=2)
         if difference > 0:
             leave = self.env['hr.leave.allocation'].create({
                 'name': _('Allocation for %s') % employee.name,
                 'employee_id': employee.id,
                 'holiday_status_id': status.id,
                 'holiday_type': 'employee',
                 'number_of_days_temp': difference
             })
             leave.action_approve()
             if leave.validation_type == 'both':
                 leave.action_validate()
         elif difference < 0:
             raise UserError(_('You cannot reduce validated allocation requests.'))
开发者ID:bitctrl,项目名称:odoo,代码行数:31,代码来源:hr.py


示例8: _onchange_hours_per_day

 def _onchange_hours_per_day(self):
     attendances = self._get_global_attendances()
     hour_count = 0.0
     for attendance in attendances:
         hour_count += attendance.hour_to - attendance.hour_from
     if attendances:
         self.hours_per_day = float_round(hour_count / float(len(set(attendances.mapped('dayofweek')))), precision_digits=2)
开发者ID:fabianpc,项目名称:odoo,代码行数:7,代码来源:resource.py


示例9: ogone_form_generate_values

 def ogone_form_generate_values(self, values):
     base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
     ogone_tx_values = dict(values)
     param_plus = {
         'return_url': ogone_tx_values.pop('return_url', False)
     }
     temp_ogone_tx_values = {
         'PSPID': self.ogone_pspid,
         'ORDERID': values['reference'],
         'AMOUNT': float_repr(float_round(values['amount'], 2) * 100, 0),
         'CURRENCY': values['currency'] and values['currency'].name or '',
         'LANGUAGE': values.get('partner_lang'),
         'CN': values.get('partner_name'),
         'EMAIL': values.get('partner_email'),
         'OWNERZIP': values.get('partner_zip'),
         'OWNERADDRESS': values.get('partner_address'),
         'OWNERTOWN': values.get('partner_city'),
         'OWNERCTY': values.get('partner_country') and values.get('partner_country').code or '',
         'OWNERTELNO': values.get('partner_phone'),
         'ACCEPTURL': urls.url_join(base_url, OgoneController._accept_url),
         'DECLINEURL': urls.url_join(base_url, OgoneController._decline_url),
         'EXCEPTIONURL': urls.url_join(base_url, OgoneController._exception_url),
         'CANCELURL': urls.url_join(base_url, OgoneController._cancel_url),
         'PARAMPLUS': url_encode(param_plus),
     }
     if self.save_token in ['ask', 'always']:
         temp_ogone_tx_values.update({
             'ALIAS': 'ODOO-NEW-ALIAS-%s' % time.time(),    # something unique,
             'ALIASUSAGE': values.get('alias_usage') or self.ogone_alias_usage,
         })
     shasign = self._ogone_generate_shasign('in', temp_ogone_tx_values)
     temp_ogone_tx_values['SHASIGN'] = shasign
     ogone_tx_values.update(temp_ogone_tx_values)
     return ogone_tx_values
开发者ID:Vauxoo,项目名称:odoo,代码行数:34,代码来源:payment.py


示例10: _put_in_pack

    def _put_in_pack(self):
        package = False
        for pick in self:
            operations = pick.move_line_ids.filtered(lambda o: o.qty_done > 0 and not o.result_package_id)
            operation_ids = self.env['stock.move.line']
            if operations:
                package = self.env['stock.quant.package'].create({})
                for operation in operations:
                    if float_compare(operation.qty_done, operation.product_uom_qty, precision_rounding=operation.product_uom_id.rounding) >= 0:
                        operation_ids |= operation
                    else:
                        quantity_left_todo = float_round(
                            operation.product_uom_qty - operation.qty_done,
                            precision_rounding=operation.product_uom_id.rounding,
                            rounding_method='UP')
                        done_to_keep = operation.qty_done
                        new_operation = operation.copy(
                            default={'product_uom_qty': 0, 'qty_done': operation.qty_done})
                        operation.write({'product_uom_qty': quantity_left_todo, 'qty_done': 0.0})
                        new_operation.write({'product_uom_qty': done_to_keep})
                        operation_ids |= new_operation

                operation_ids.write({'result_package_id': package.id})
            else:
                raise UserError(_('Please process some quantities to put in the pack first!'))
        return package
开发者ID:nafex,项目名称:odoo,代码行数:26,代码来源:stock_picking.py


示例11: name_get

 def name_get(self):
     if not self._context.get('employee_id'):
         # leave counts is based on employee_id, would be inaccurate if not based on correct employee
         return super(HolidaysType, self).name_get()
     res = []
     for record in self:
         name = record.name
         if record.allocation_type != 'no':
             name = "%(name)s (%(count)s)" % {
                 'name': name,
                 'count': _('%g remaining out of %g') % (
                     float_round(record.virtual_remaining_leaves, precision_digits=2) or 0.0,
                     float_round(record.max_leaves, precision_digits=2) or 0.0,
                 )
             }
         res.append((record.id, name))
     return res
开发者ID:Tecnativa,项目名称:odoo,代码行数:17,代码来源:hr_leave_type.py


示例12: _compute_mrp_product_qty

 def _compute_mrp_product_qty(self):
     date_from = fields.Datetime.to_string(fields.datetime.now() - timedelta(days=365))
     #TODO: state = done?
     domain = [('state', '=', 'done'), ('product_id', 'in', self.ids), ('date_planned_start', '>', date_from)]
     read_group_res = self.env['mrp.production'].read_group(domain, ['product_id', 'product_uom_qty'], ['product_id'])
     mapped_data = dict([(data['product_id'][0], data['product_uom_qty']) for data in read_group_res])
     for product in self:
         product.mrp_product_qty = float_round(mapped_data.get(product.id, 0), precision_rounding=product.uom_id.rounding)
开发者ID:akretion,项目名称:odoo,代码行数:8,代码来源:product.py


示例13: _compute_leaves_count

 def _compute_leaves_count(self):
     all_leaves = self.env['hr.leave.report'].read_group([
         ('employee_id', 'in', self.ids),
         ('state', '=', 'validate')
     ], fields=['number_of_days', 'employee_id'], groupby=['employee_id'])
     mapping = dict([(leave['employee_id'][0], leave['number_of_days']) for leave in all_leaves])
     for employee in self:
         employee.leaves_count = float_round(mapping.get(employee.id, 0), precision_digits=2)
开发者ID:bud-e,项目名称:odoo,代码行数:8,代码来源:hr.py


示例14: _free_reservation

    def _free_reservation(self, product_id, location_id, quantity, lot_id=None, package_id=None, owner_id=None, ml_to_ignore=None):
        """ When editing a done move line or validating one with some forced quantities, it is
        possible to impact quants that were not reserved. It is therefore necessary to edit or
        unlink the move lines that reserved a quantity now unavailable.

        :param ml_to_ignore: recordset of `stock.move.line` that should NOT be unreserved
        """
        self.ensure_one()

        if ml_to_ignore is None:
            ml_to_ignore = self.env['stock.move.line']
        ml_to_ignore |= self

        # Check the available quantity, with the `strict` kw set to `True`. If the available
        # quantity is greather than the quantity now unavailable, there is nothing to do.
        available_quantity = self.env['stock.quant']._get_available_quantity(
            product_id, location_id, lot_id=lot_id, package_id=package_id, owner_id=owner_id, strict=True
        )
        if quantity > available_quantity:
            # We now have to find the move lines that reserved our now unavailable quantity. We
            # take care to exclude ourselves and the move lines were work had already been done.
            oudated_move_lines_domain = [
                ('move_id.state', 'not in', ['done', 'cancel']),
                ('product_id', '=', product_id.id),
                ('lot_id', '=', lot_id.id if lot_id else False),
                ('location_id', '=', location_id.id),
                ('owner_id', '=', owner_id.id if owner_id else False),
                ('package_id', '=', package_id.id if package_id else False),
                ('product_qty', '>', 0.0),
                ('id', 'not in', ml_to_ignore.ids),
            ]
            oudated_candidates = self.env['stock.move.line'].search(oudated_move_lines_domain)

            # As the move's state is not computed over the move lines, we'll have to manually
            # recompute the moves which we adapted their lines.
            move_to_recompute_state = self.env['stock.move']

            rounding = self.product_uom_id.rounding
            for candidate in oudated_candidates:
                if float_compare(candidate.product_qty, quantity, precision_rounding=rounding) <= 0:
                    quantity -= candidate.product_qty
                    move_to_recompute_state |= candidate.move_id
                    if candidate.qty_done:
                        candidate.product_uom_qty = 0.0
                    else:
                        candidate.unlink()
                else:
                    # split this move line and assign the new part to our extra move
                    quantity_split = float_round(
                        candidate.product_qty - quantity,
                        precision_rounding=self.product_uom_id.rounding,
                        rounding_method='UP')
                    candidate.product_uom_qty = self.product_id.uom_id._compute_quantity(quantity_split, candidate.product_uom_id, rounding_method='HALF-UP')
                    quantity -= quantity_split
                    move_to_recompute_state |= candidate.move_id
                if quantity == 0.0:
                    break
            move_to_recompute_state._recompute_state()
开发者ID:rmoorman,项目名称:odoo,代码行数:58,代码来源:stock_move_line.py


示例15: _quant_create_from_move

    def _quant_create_from_move(self, qty, move, lot_id=False, owner_id=False,
                                src_package_id=False, dest_package_id=False,
                                force_location_from=False, force_location_to=False):
        '''Create a quant in the destination location and create a negative
        quant in the source location if it's an internal location. '''
        price_unit = move.get_price_unit()
        location = force_location_to or move.location_dest_id
        rounding = move.product_id.uom_id.rounding
        vals = {
            'product_id': move.product_id.id,
            'location_id': location.id,
            'qty': float_round(qty, precision_rounding=rounding),
            'cost': price_unit,
            'history_ids': [(4, move.id)],
            'in_date': datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
            'company_id': move.company_id.id,
            'lot_id': lot_id,
            'owner_id': owner_id,
            'package_id': dest_package_id,
        }
        if move.location_id.usage == 'internal':
            # if we were trying to move something from an internal location and reach here (quant creation),
            # it means that a negative quant has to be created as well.
            negative_vals = vals.copy()
            negative_vals['location_id'] = force_location_from and force_location_from.id or move.location_id.id
            negative_vals['qty'] = float_round(-qty, precision_rounding=rounding)
            negative_vals['cost'] = price_unit
            negative_vals['negative_move_id'] = move.id
            negative_vals['package_id'] = src_package_id
            negative_quant_id = self.sudo().create(negative_vals)
            vals.update({'propagated_from_id': negative_quant_id.id})

        # In case of serial tracking, check if the product does not exist somewhere internally already
        picking_type = move.picking_id and move.picking_id.picking_type_id or False
        if lot_id and move.product_id.tracking == 'serial' and (not picking_type or (picking_type.use_create_lots or picking_type.use_existing_lots)):
            if qty != 1.0:
                raise UserError(_('You should only receive by the piece with the same serial number'))
            other_quants = self.search([('product_id', '=', move.product_id.id), ('lot_id', '=', lot_id),
                                        ('qty', '>', 0.0), ('location_id.usage', '=', 'internal')])
            if other_quants:
                lot_name = self.env['stock.production.lot'].browse(lot_id).name
                raise UserError(_('The serial number %s is already in stock.') % lot_name + _("Otherwise make sure the right stock/owner is set."))

        # create the quant as superuser, because we want to restrict the creation of quant manually: we should always use this method to create quants
        return self.sudo().create(vals)
开发者ID:Alex-Fan,项目名称:odoo,代码行数:45,代码来源:stock_quant.py


示例16: _compute_timesheet_revenue

    def _compute_timesheet_revenue(self):
        for invoice in self:
            for invoice_line in invoice.invoice_line_ids.filtered(lambda line: line.product_id.type == 'service'):
                uninvoiced_timesheet_lines = self.env['account.analytic.line'].sudo().search([
                    ('so_line', 'in', invoice_line.sale_line_ids.ids),
                    ('project_id', '!=', False),
                    ('timesheet_invoice_id', '=', False),
                    ('timesheet_invoice_type', 'in', ['billable_time', 'billable_fixed'])
                ]).with_context(create=True)  # context key required to avoid loop

                # NOTE JEM : changing quantity (or unit price) of invoice line does not impact the revenue calculation. (FP specs)
                if uninvoiced_timesheet_lines:
                    precision = invoice_line.currency_id.decimal_places
                    # delivered : update revenue with the prorata of number of hours on the timesheet line
                    if invoice_line.product_id.invoice_policy == 'delivery':
                        invoiced_price_per_hour = float_round(invoice_line.price_subtotal / float(sum(uninvoiced_timesheet_lines.mapped('unit_amount'))), precision)
                        # invoicing analytic lines of different currency
                        total_revenue_per_currency = dict.fromkeys(uninvoiced_timesheet_lines.mapped('company_currency_id').ids, 0.0)
                        for index, timesheet_line in enumerate(uninvoiced_timesheet_lines):
                            if index+1 != len(uninvoiced_timesheet_lines):
                                line_revenue = invoice_line.currency_id.compute(invoiced_price_per_hour, timesheet_line.company_currency_id) * timesheet_line.unit_amount
                                total_revenue_per_currency[timesheet_line.company_currency_id.id] += line_revenue
                            else:  # last line: add the difference to avoid rounding problem
                                total_revenue = sum([self.env['res.currency'].browse(currency_id).compute(amount, timesheet_line.company_currency_id) for currency_id, amount in total_revenue_per_currency.items()])
                                line_revenue = invoice_line.currency_id.compute(invoice_line.price_subtotal, timesheet_line.company_currency_id) - total_revenue
                            timesheet_line.write({
                                'timesheet_invoice_id': invoice.id,
                                'timesheet_revenue': timesheet_line.company_currency_id.round(line_revenue),
                            })

                    # ordered : update revenue with the prorata of theorical revenue
                    elif invoice_line.product_id.invoice_policy == 'order':
                        zero_timesheet_revenue = uninvoiced_timesheet_lines.filtered(lambda line: line.timesheet_revenue == 0.0)
                        no_zero_timesheet_revenue = uninvoiced_timesheet_lines.filtered(lambda line: line.timesheet_revenue != 0.0)

                        # timesheet with zero theorical revenue keep the same revenue, but become invoiced (invoice_id set)
                        zero_timesheet_revenue.write({'timesheet_invoice_id': invoice.id})

                        # invoicing analytic lines of different currency
                        total_revenue_per_currency = dict.fromkeys(no_zero_timesheet_revenue.mapped('company_currency_id').ids, 0.0)

                        for index, timesheet_line in enumerate(no_zero_timesheet_revenue):
                            if index+1 != len(no_zero_timesheet_revenue):
                                price_subtotal_inv = invoice_line.currency_id.compute(invoice_line.price_subtotal, timesheet_line.company_currency_id)
                                price_subtotal_sol = timesheet_line.so_line.currency_id.compute(timesheet_line.so_line.price_subtotal, timesheet_line.company_currency_id)
                                line_revenue = timesheet_line.timesheet_revenue * price_subtotal_inv / price_subtotal_sol
                                total_revenue_per_currency[timesheet_line.company_currency_id.id] += line_revenue
                            else:  # last line: add the difference to avoid rounding problem
                                last_price_subtotal_inv = invoice_line.currency_id.compute(invoice_line.price_subtotal, timesheet_line.company_currency_id)
                                total_revenue = sum([self.env['res.currency'].browse(currency_id).compute(amount, timesheet_line.company_currency_id) for currency_id, amount in total_revenue_per_currency.items()])
                                line_revenue = last_price_subtotal_inv - total_revenue

                            timesheet_line.write({
                                'timesheet_invoice_id': invoice.id,
                                'timesheet_revenue': timesheet_line.company_currency_id.round(line_revenue),
                            })
开发者ID:RoganW,项目名称:odoo,代码行数:56,代码来源:account_invoice.py


示例17: _compute_purchased_product_qty

 def _compute_purchased_product_qty(self):
     date_from = fields.Datetime.to_string(fields.datetime.now() - timedelta(days=365))
     domain = [
         ('state', 'in', ['purchase', 'done']),
         ('product_id', 'in', self.mapped('id')),
         ('date_order', '>', date_from)
     ]
     PurchaseOrderLines = self.env['purchase.order.line'].search(domain)
     order_lines = self.env['purchase.order.line'].read_group(domain, ['product_id', 'product_uom_qty'], ['product_id'])
     purchased_data = dict([(data['product_id'][0], data['product_uom_qty']) for data in order_lines])
     for product in self:
         product.purchased_product_qty = float_round(purchased_data.get(product.id, 0), precision_rounding=product.uom_id.rounding)
开发者ID:Vauxoo,项目名称:odoo,代码行数:12,代码来源:product.py


示例18: _prepare_stock_return_picking_line_vals_from_move

 def _prepare_stock_return_picking_line_vals_from_move(self, stock_move):
     quantity = stock_move.product_qty - sum(
         stock_move.move_dest_ids
         .filtered(lambda m: m.state in ['partially_available', 'assigned', 'done'])
         .mapped('move_line_ids.product_qty')
     )
     quantity = float_round(quantity, precision_rounding=stock_move.product_uom.rounding)
     return {
         'product_id': stock_move.product_id.id,
         'quantity': quantity,
         'move_id': stock_move.id,
         'uom_id': stock_move.product_id.uom_id.id,
     }
开发者ID:Vauxoo,项目名称:odoo,代码行数:13,代码来源:stock_picking_return.py


示例19: _get_remaining_qty

 def _get_remaining_qty(self):
     if self.package_id and not self.product_id:
         # dont try to compute the remaining quantity for packages because it's not relevant (a package could include different products).
         # should use _get_remaining_prod_quantities instead
         # TDE FIXME: actually resolve the comment hereabove
         self.remaining_qty = 0
     else:
         qty = self.product_qty
         if self.product_uom_id:
             qty = self.product_uom_id._compute_quantity(self.product_qty, self.product_id.uom_id)
         for record in self.linked_move_operation_ids:
             qty -= record.qty
         self.remaining_qty = float_round(qty, precision_rounding=self.product_id.uom_id.rounding)
开发者ID:Choumy,项目名称:odoo,代码行数:13,代码来源:stock_pack_operation.py


示例20: _compute_quantities_dict

    def _compute_quantities_dict(self, lot_id, owner_id, package_id, from_date=False, to_date=False):
        domain_quant_loc, domain_move_in_loc, domain_move_out_loc = self._get_domain_locations()

        domain_quant = [('product_id', 'in', self.ids)] + domain_quant_loc
        domain_move_in = [('state', 'not in', ('done', 'cancel', 'draft')), ('product_id', 'in', self.ids)] + domain_move_in_loc
        domain_move_out = [('state', 'not in', ('done', 'cancel', 'draft')), ('product_id', 'in', self.ids)] + domain_move_out_loc
        if from_date:
            domain_move_in += [('date', '>=', from_date)]
            domain_move_out += [('date', '>=', from_date)]
        if to_date:
            domain_move_in += [('date', '<=', to_date)]
            domain_move_out += [('date', '<=', to_date)]
        if lot_id:
            domain_quant += [('lot_id', '=', lot_id)]
        if owner_id:
            domain_quant += [('owner_id', '=', owner_id)]
            domain_move_in += [('restrict_partner_id', '=', owner_id)]
            domain_move_out += [('restrict_partner_id', '=', owner_id)]
        if package_id:
            domain_quant += [('package_id', '=', package_id)]

        Move = self.env['stock.move']
        Quant = self.env['stock.quant']
        moves_in_res = dict((item['product_id'][0], item['product_qty']) for item in Move.read_group(domain_move_in, ['product_id', 'product_qty'], ['product_id']))
        moves_out_res = dict((item['product_id'][0], item['product_qty']) for item in Move.read_group(domain_move_out, ['product_id', 'product_qty'], ['product_id']))
        quants_res = dict((item['product_id'][0], item['qty']) for item in Quant.read_group(domain_quant, ['product_id', 'qty'], ['product_id']))

        res = dict()
        for product in self.with_context(prefetch_fields=False):
            res[product.id] = {}
            res[product.id]['qty_available'] = float_round(quants_res.get(product.id, 0.0), precision_rounding=product.uom_id.rounding)
            res[product.id]['incoming_qty'] = float_round(moves_in_res.get(product.id, 0.0), precision_rounding=product.uom_id.rounding)
            res[product.id]['outgoing_qty'] = float_round(moves_out_res.get(product.id, 0.0), precision_rounding=product.uom_id.rounding)
            res[product.id]['virtual_available'] = float_round(
                res[product.id]['qty_available'] + res[product.id]['incoming_qty'] - res[product.id]['outgoing_qty'],
                precision_rounding=product.uom_id.rounding)
        return res
开发者ID:ArthurC07,项目名称:odoo-9,代码行数:37,代码来源:product.py



注:本文中的odoo.tools.float_utils.float_round函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python imaputil.imapsplit函数代码示例发布时间:2022-05-27
下一篇:
Python float_utils.float_is_zero函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap