当前位置: 首页>>代码示例>>Python>>正文


Python translate._函数代码示例

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


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

示例1: action_move

    def action_move(self, cr, uid, ids, context={}):
        for picking in self.browse(cr, uid, ids):
            if picking.invoice_state == "2binvoiced":
                cr.commit() #ensure that picking has been eventually split
                so = picking.sale_id
                
                #eventually block the picking:
                so_lines_total_price = 0
                for move in picking.move_lines:
                    so_line = self.pool.get('sale.order.line').browse(cr, uid, move.sale_line_id.id)
                    sale_shop = so_line.order_id.shop_id
                    print "so_line.price_subtotal * move.product_qty / so_line.product_uos_qty", so_line.price_subtotal_incl, move.product_qty, so_line.product_uos_qty
                    if so_line.price_subtotal_incl:
                        so_lines_total_price += so_line.price_subtotal_incl * move.product_qty / so_line.product_uos_qty
                    else:
                        so_lines_total_price += so_line.price_subtotal * move.product_qty / so_line.product_uos_qty
                
                print "so_lines_total_price", so_lines_total_price
                if (- so.partner_id.credit) * 1.001 < so_lines_total_price * float(sale_shop.picking_blocking_deposit_percent) / 100.0:
                    raise osv.except_osv(_('Error !'), _("Not enough deposits amount! Sale Shop is configured to block picking if paid amount is below %s percent, that is %s") % (sale_shop.picking_blocking_deposit_percent, so_lines_total_price * float(sale_shop.picking_blocking_deposit_percent) / 100.0))

                
                #then invoice picking:
                data2 ={'form':{'group': 0, 'type':'out_invoice', 'journal_id': sale_shop.picking_invoicing_journal_id.id}, 'ids':[picking.id], 'id': picking.id}
                self._create_invoice(cr, uid, data2, {}) #TODO real context


            super(stock_picking, self).action_move(cr, uid, ids, context) #actually perform the move
开发者ID:kevin-garnett,项目名称:openerp-from-oneyoung,代码行数:28,代码来源:stock.py

示例2: initialize

 def initialize(self):
     #login
     PortType,sessionid = sugar.login(self.context.get('username',''), self.context.get('password',''), self.context.get('url',''))
     if sessionid == '-1':
         raise osv.except_osv(_('Error !'), _('Authentication error !\nBad Username or Password or bad SugarSoap Api url !'))
     self.context['port'] = PortType
     self.context['session_id'] = sessionid
开发者ID:CloudWareChile,项目名称:OpenChile,代码行数:7,代码来源:import_sugarcrm.py

示例3: select_product

 def select_product(self, cr, uid, ids, context=None):
     """
          To get the product and quantity and add in order .
          @param self: The object pointer.
          @param cr: A database cursor
          @param uid: ID of the user currently logged in
          @param context: A standard dictionary
          @return : Return the add product form again for adding more product
     """
     if context is None:
         context = {}
     this = self.browse(cr, uid, ids[0], context=context)
     record_id = context and context.get('active_id', False)
     assert record_id, _('Active ID is not found')
     if record_id:
         order_obj = self.pool.get('pos.order')
         order_obj.add_product(cr, uid, record_id, this.product_id.id, this.quantity, context=context)
     return {
         'name': _('Add Product'),
         'view_type': 'form',
         'view_mode': 'form',
         'res_model': 'pos.add.product',
         'view_id': False,
         'target': 'new',
         'views': False,
         'type': 'ir.actions.act_window',
     }
开发者ID:davgit,项目名称:Xero-2,代码行数:27,代码来源:pos_add_product.py

示例4: _repair_action

    def _repair_action(self, cr, uid, data, context):
        """
        Action that repairs the invoice numbers 
        """
        logger = netsvc.Logger()

        logger.notifyChannel("l10n_es_account_invoice_sequence_fix", netsvc.LOG_DEBUG, "Searching for invoices.")

        invoice_facade = pooler.get_pool(cr.dbname).get('account.invoice')
        invoice_ids = invoice_facade.search(cr, uid, [('move_id','<>','')], limit=0, order='id', context=context)

        if len(invoice_ids) == 0:
            raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))

        logger.notifyChannel("l10n_es_account_invoice_sequence_fix", netsvc.LOG_DEBUG, "Repairing %d invoices." % len(invoice_ids))

        for invoice in invoice_facade.browse(cr, uid, invoice_ids):
            move_id = invoice.move_id or False
            if move_id:
                cr.execute('UPDATE account_invoice SET invoice_number=%s WHERE id=%s', (move_id.id, invoice.id))

        logger.notifyChannel("l10n_es_account_invoice_sequence_fix", netsvc.LOG_DEBUG, "%d invoices repaired." % len(invoice_ids))

        vals = {
        }
        return vals
开发者ID:Mlayns,项目名称:openerp-spain,代码行数:26,代码来源:wizard_invoice_number_repair.py

示例5: account_move_get

    def account_move_get(self, cr, uid, voucher_id, context=None):
     
      
        seq_obj = self.pool.get('ir.sequence')
        voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)
        if voucher_brw.number:
            name = voucher_brw.number
        elif voucher_brw.journal_id.sequence_id:
            name = seq_obj.next_by_id(cr, uid, voucher_brw.journal_id.sequence_id.id)
        else:
            raise osv.except_osv(_('Error !'),
                        _('Please define a sequence on the journal !'))
        if not voucher_brw.reference:
            ref = name.replace('/','')
        else:
            ref = voucher_brw.reference

        print ' voucher_brw.fecha     '+str( voucher_brw.fecha)+'    '+str(voucher_brw.date)

        move = {
            'name': name,
            'journal_id': voucher_brw.journal_id.id,
            'narration': voucher_brw.narration,
            'date': voucher_brw.fecha or voucher_brw.date,
            'ref': ref,
            'period_id': voucher_brw.period_id and voucher_brw.period_id.id or False
        }
        return move
开发者ID:Pexego,项目名称:addons-va-ca-ti,代码行数:28,代码来源:facturas.py

示例6: _empty

    def _empty(self, cr, uid, context=None):
        close = []
        up = []
        obj_tb = self.pool.get('project.gtd.timebox')
        obj_task = self.pool.get('project.task')

        if context is None:
            context = {}
        if not 'active_id' in context:
            return {}

        ids = obj_tb.search(cr, uid, [], context=context)
        if not len(ids):
            raise osv.except_osv(_('Error !'), _('No timebox child of this one !'))
        tids = obj_task.search(cr, uid, [('timebox_id', '=', context['active_id'])])
        for task in obj_task.browse(cr, uid, tids, context):
            if (task.state in ('cancel','done')) or (task.user_id.id <> uid):
                close.append(task.id)
            else:
                up.append(task.id)
        if up:
            obj_task.write(cr, uid, up, {'timebox_id':ids[0]})
        if close:
            obj_task.write(cr, uid, close, {'timebox_id':False})
        return {}
开发者ID:CloudWareChile,项目名称:OpenChile,代码行数:25,代码来源:project_gtd_empty.py

示例7: subscribe

    def subscribe(self, cr, uid, ids, *args):
        """
        Subscribe Rule for auditing changes on object and apply shortcut for logs on that object.
        @param cr: the current row, from the database cursor,
        @param uid: the current user’s ID for security checks,
        @param ids: List of Auddittrail Rule’s IDs.
        @return: True
        """
        obj_action = self.pool.get('ir.actions.act_window')
        obj_model = self.pool.get('ir.model.data')
        #start Loop
        for thisrule in self.browse(cr, uid, ids):
            obj = self.pool.get(thisrule.object_id.model)
            if not obj:
                raise osv.except_osv(
                        _('WARNING: audittrail is not part of the pool'),
                        _('Change audittrail depends -- Setting rule as DRAFT'))
                self.write(cr, uid, [thisrule.id], {"state": "draft"})
            val = {
                 "name": 'View Log',
                 "res_model": 'audittrail.log',
                 "src_model": thisrule.object_id.model,
                 "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"

            }
            action_id = obj_action.create(cr, 1, val)
            self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": action_id})
            keyword = 'client_action_relate'
            value = 'ir.actions.act_window,' + str(action_id)
            res = obj_model.ir_set(cr, 1, 'action', keyword, 'View_log_' + thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
            #End Loop
        return True
开发者ID:sergiocorato,项目名称:ocb-addons-61,代码行数:32,代码来源:audittrail.py

示例8: _split

    def _split(self, cr, uid, id, quantity, context):
        """
        Sets the quantity to produce for production with id 'id' to 'quantity' and
        creates a new production order with the deference between current amount and
        the new quantity.
        """

        production = self.browse(cr, uid, id, context)
        if production.state != 'confirmed':
          #  raise osv.except_osv(_('Error !'), _('Production order "%s" is not in "Waiting Goods" state.') % production.name)
          pass
        if quantity >= production.product_qty:
            raise osv.except_osv(_('Error !'), _('Quantity must be greater than production quantity in order "%s" (%s / %s)') % (production.name, quantity, production.product_qty))

        # Create new production, but ensure product_lines is kept empty.
        new_production_id = self.copy(cr, uid, id, {
            'product_lines': [],
            'move_prod_id': False,
            'product_qty':  quantity,
        }, context)

        self.write(cr, uid, production.id, {
            'product_qty': production.product_qty -quantity,
            'product_lines': [],
        }, context)

        self.action_compute(cr, uid, [ new_production_id])
        self._change_prod_qty( cr, uid, production.id ,production.product_qty-quantity, context)
        workflow = netsvc.LocalService("workflow")
        workflow.trg_validate(uid, 'mrp.production', new_production_id, 'button_confirm', cr)

        return [id, new_production_id]
开发者ID:cgsoftware,项目名称:mrp_production_split_omaf,代码行数:32,代码来源:mrp.py

示例9: create

    def create(self, cr, uid, vals, context=None):
        if context is None:
            context = {}
        vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False)
        if not vals['parent_id']:
            vals['parent_id'] = self.pool.get('document.directory')._get_root_directory(cr,uid, context)
        if not vals.get('res_id', False) and context.get('default_res_id', False):
            vals['res_id'] = context.get('default_res_id', False)
        if not vals.get('res_model', False) and context.get('default_res_model', False):
            vals['res_model'] = context.get('default_res_model', False)
        if vals.get('res_id', False) and vals.get('res_model', False) \
                and not vals.get('partner_id', False):
            vals['partner_id'] = self.__get_partner_id(cr, uid, \
                vals['res_model'], vals['res_id'], context)

        datas = None
        if vals.get('link', False) :
            import urllib
            datas = base64.encodestring(urllib.urlopen(vals['link']).read())
        else:
            datas = vals.get('datas', False)

        if datas:
            vals['file_size'] = len(datas)
        else:
            if vals.get('file_size'):
                del vals['file_size']
        if not self._check_duplication(cr, uid, vals):
            raise osv.except_osv(_('ValidateError'), _('File name must be unique!'))
        result = super(document_file, self).create(cr, uid, vals, context)
        cr.commit() # ?
        return result
开发者ID:sgeerish,项目名称:sirr_production,代码行数:32,代码来源:document.py

示例10: view_init

    def view_init(self, cr, uid, fields_list, context=None):
        if context is None:
            context = {}
        super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
        active_id = context and context.get('active_id', False) or False
        if active_id:
            order = self.pool.get('pos.order').browse(cr, uid, active_id, context=context)

            partner_id = order.partner_id and order.partner_id or False
            if not partner_id:
                partner_id = order.partner_id or False

            ''' Check if the partner has other pickings with the same products'''
            pos_warn_sale_order = order.pos_warn_sale_order or False
            if pos_warn_sale_order and partner_id:
                address_ids = [adr.id for adr in partner_id.address]
                picking_obj = self.pool.get('stock.picking')
                picking_ids = picking_obj.search(cr, uid, [
                        ('state', 'in', ['auto','confirmed','assigned']),
                        ('id', '!=', order.picking_id.id),
                        ('address_id', 'in', address_ids),
                    ])
                if picking_ids:
                    product_ids = [line.product_id.id for line in order.lines]
                    for picking in picking_obj.browse(cr, uid, picking_ids, context):
                        for m in picking.move_lines:
                            if m.product_id.id in product_ids:
                                product = (m.product_id.name).encode('utf-8')
                                sale_order_info = (picking.origin and picking.name + '-' + picking.origin or picking.name).encode('utf-8')
                                raise osv.except_osv(_('Warning! Product already ordered'),
                                    _("Product %s is already ordered in picking %s." \
                                    " If you want to order it again ignoring this picking,"\
                                    " you must uncheck the boolean field"\
                                    " 'Product in sale order warning'.") % (product, sale_order_info))
        return True
开发者ID:Arsalan88,项目名称:openerp-extra-6.1,代码行数:35,代码来源:pos_payment.py

示例11: _change_prod_qty

    def _change_prod_qty(self, cr, uid, id ,quantity, context):

        prod_obj = self.pool.get('mrp.production')
        prod = prod_obj.browse(cr, uid, id , context=context)
        prod_obj.write(cr, uid, prod.id, {'product_qty' : quantity })
        prod_obj.action_compute(cr, uid, [prod.id])

        move_lines_obj = self.pool.get('stock.move')
        for move in prod.move_lines:
            bom_point = prod.bom_id
            bom_id = prod.bom_id.id
            if not bom_point:
                bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
                if not bom_id:
                    raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
                self.write(cr, uid, [prod.id], {'bom_id': bom_id})
                bom_point = self.pool.get('mrp.bom').browse(cr, uid, [bom_id])[0]

            if not bom_id:
                raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))

            factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
            res = self.pool.get('mrp.bom')._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
            for r in res[0]:
                if r['product_id']== move.product_id.id:
                    move_lines_obj.write(cr, uid,move.id, {'product_qty' :  r['product_qty']})

        product_lines_obj = self.pool.get('mrp.production.product.line')

        for m in prod.move_created_ids:
            move_lines_obj.write(cr, uid,m.id, {'product_qty' : quantity})

        return {}
开发者ID:cgsoftware,项目名称:mrp_production_split_omaf,代码行数:33,代码来源:mrp.py

示例12: create_balance_line

 def create_balance_line(self, cr, uid, move, res_user, name, context=None):    
     move_line_obj = self.pool.get('account.move.line')
     amount = self.get_balance_amount(cr, uid, move.id, context=context)
     if amount > 0:
         account_id = res_user.company_id.expense_currency_exchange_account_id.id
         if not account_id:
             raise osv.except_osv(_('Error!'), _('The company have not associated a expense account.\n'))
         credit = amount
         debit = 0.00
     else:
         account_id = res_user.company_id.income_currency_exchange_account_id.id
         if not account_id:
             raise osv.except_osv(_('Error!'), _('The company have not associated a income account.\n'))
         credit = 0.00
         debit = amount * -1    
         
     move_line = {
                          'name': name,
                          'ref': name,
                          'debit': debit,
                          'credit': credit,
                          'account_id': account_id,
                          'move_id': move.id,
                          'period_id': move.period_id.id,
                          'journal_id': move.journal_id.id,
                          'partner_id': False,
                          'currency_id': False,
                          'amount_currency': 0.00,
                          'state': 'valid',
                          'company_id': res_user.company_id.id,
                          }
     new_move_line_id = move_line_obj.create(cr, uid, move_line, context=context)
     return new_move_line_id
开发者ID:3dfxsoftware,项目名称:cbss-addons,代码行数:33,代码来源:account_exchange_rates_adjustment.py

示例13: _send_mails

    def _send_mails(self, cr, uid, data, context):
        
        import re
        p = pooler.get_pool(cr.dbname)
    
        user = p.get('res.users').browse(cr, uid, uid, context)
        file_name = user.company_id.name.replace(' ','_')+'_'+_('Sale_Order')
        
        default_smtpserver_id = p.get('email.smtpclient').search(cr, uid, [('users_id','=',uid), ('pstate','=','running')], context=None)
        if default_smtpserver_id:
            default_smtpserver_id = default_smtpserver_id[0]
        else:
            raise osv.except_osv(_('Error'), 
                                 _('Can\'t send email, please check whether SMTP client has been defined and you have permission to access!'))
        
        attachments = data['form']['attachment_file']
        attachments = [attachments] or []
        nbr = 0
        for email in data['form']['to'].split(','):
            state = p.get('email.smtpclient').send_email(cr, uid, default_smtpserver_id, email, data['form']['subject'], data['form']['text'], attachments)
            if not state:
                raise osv.except_osv(_('Error sending email'), _('Please check the Server Configuration!'))
            nbr += 1

        return {'email_sent': nbr}
开发者ID:aryaadiputra,项目名称:addons60_ptgbu_2013,代码行数:25,代码来源:wizard_print_journal_entries.py

示例14: product_id_change

    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
            lang=False, update_tax=True, date_order=False, packaging=False,
            fiscal_position=False, flag=False, context=None):
        warning = {}
        if not product:
            return {'value': {'th_weight' : 0, 'product_packaging': False,
                'product_uos_qty': qty}, 'domain': {'product_uom': [],
                   'product_uos': []}}
        product_obj = self.pool.get('product.product')
        product_info = product_obj.browse(cr, uid, product)
        title = False
        message = False

        if product_info.sale_line_warn != 'no-message':
            if product_info.sale_line_warn == 'block':
                raise osv.except_osv(_('Alert for %s !') % (product_info.name), product_info.sale_line_warn_msg)
            title = _("Warning for %s") % product_info.name
            message = product_info.sale_line_warn_msg
            warning['title'] = title
            warning['message'] = message

        result =  super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty,
            uom, qty_uos, uos, name, partner_id,
            lang, update_tax, date_order, packaging, fiscal_position, flag, context=context)

        if result.get('warning',False):
            warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title']
            warning['message'] = message and message +'\n\n'+result['warning']['message'] or result['warning']['message']

        return {'value': result.get('value',{}), 'warning':warning}
开发者ID:adrianorissi,项目名称:openobject-addons,代码行数:31,代码来源:warning.py

示例15: validate

    def validate(self, cr, uid, ids, context=None):
        # Add a validation process that all periods being posted is still open
        for _obj in self.browse(cr, uid, ids, context=context):
            if _obj.period_id.state in ('done'):
                raise osv.except_osv(_('Error!'), _("Move %s is dated in closed period.") % (_obj.name))

        return super(account_move, self).validate(cr, uid, ids, context=context)
开发者ID:open-synergy,项目名称:prln-via-custom-addons,代码行数:7,代码来源:account.py


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