當前位置: 首頁>>代碼示例>>Python>>正文


Python osv.osv方法代碼示例

本文整理匯總了Python中openerp.osv.osv.osv方法的典型用法代碼示例。如果您正苦於以下問題:Python osv.osv方法的具體用法?Python osv.osv怎麽用?Python osv.osv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openerp.osv.osv的用法示例。


在下文中一共展示了osv.osv方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: action_cancel

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def action_cancel(self, cr, uid, ids, context=None):
        pick_obj = self.pool.get('stock.picking')
        for invoice in self.browse(cr, uid, ids, context=context):
            if invoice.picking_id.state == 'done':
                new_picking = self.create_returns(cr, uid, invoice, context=context)
                if pick_obj.browse(cr, uid, new_picking, context=context).state != 'done':
                    raise osv.except_osv('Error!', _('You cannot cancel an invoice that has a picking without reversing.'))
                invoice.write({'picking_id': False}, context=context)
        return super(account_invoice, self).action_cancel(cr, uid, ids, context=context)

# class sale_configuration(osv.TransientModel):
#     _inherit = 'sale.config.settings'
#
#     _columns = {
#         'picking_automatic': fields.boolean('Create picking automatically', implied_group='account_invoice_picking.group_picking_automatic', help='Allows create picking automatically to validate invoice'),
#     } 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:18,代碼來源:account_invoice.py

示例2: unlink

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def unlink(self, cr, uid, ids, context=None):
        for gift in self.browse(cr, uid, ids, context=context):
            if not gift.state == 'draft':
                raise osv.except_osv(_('Unable to Delete!'), _('To remove a gift voucher, it must be draft'))
        return super(pos_gift_voucher, self).unlink(cr, uid, ids, context=context) 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:7,代碼來源:pos_gift_voucher.py

示例3: action_opened

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def action_opened(self, cr, uid, ids, context=None):
        for gift in self.browse(cr, uid, ids, context=context):
            if gift.state not in 'draft':
                raise osv.except_osv(_('Operation Forbidden!'),
                                     _('Gift voucher must be in state \'Draft\''))
        self.write(cr, uid, ids, {'state': 'opened'}, context=context)
        return True 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:9,代碼來源:pos_gift_voucher.py

示例4: action_cancel

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def action_cancel(self, cr, uid, ids, context=None):
        """ Cancel the Gift Voucher
        :return: True
        """
        for gift in self.browse(cr, uid, ids, context=context):
            if gift.state == 'redeemed':
                raise osv.except_osv(_('Operation Forbidden!'),
                                     _('You cannot cancel a gift voucher that has been set to \'Redeemed\'.'))
        self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
        return True 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:12,代碼來源:pos_gift_voucher.py

示例5: action_opened_to_draft

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def action_opened_to_draft(self, cr, uid, ids, context=None):
        """ Change state opened to draft
        """
        for gift in self.browse(cr, uid, ids, context=context):
            if gift.order_ids:
                raise osv.except_osv(_('Operation Forbidden!'),
                                     _('You cannot change to Draft a gift voucher that has orders.'))
        self.write(cr, uid, ids, {'state': 'draft'}, context=context)
        return True 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:11,代碼來源:pos_gift_voucher.py

示例6: add_payment

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def add_payment(self, cr, uid, order_id, data, context=None):
        res = super(pos_order, self).add_payment(cr, uid, order_id, data, context=context)
        if data.get('gift_voucher_validate', False):
            gift_obj = self.pool.get('pos.gift.voucher')
            absl_obj = self.pool.get('account.bank.statement.line')
            gift_id = gift_obj.get_voucher_ids(cr, uid, data.get('gift_voucher_serial'), context=context)
            if not gift_id:
                raise osv.except_osv('Error', _('The gift voucher:') + data.get('gift_voucher_serial') + _(' is invalid or has already redeemed.'))
            vals = {'gift_voucher_id': gift_id[0] if gift_id else 0,
                    'amount_gift': data.get('amount', 0),
                    'total_gift': data.get('gift_voucher_spent', 0),
                    }
            absl_obj.write(cr, uid, res, vals)
        return res 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:16,代碼來源:point_of_sale.py

示例7: action_create_delivery_order

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def action_create_delivery_order(self, cr, uid, ids, context=None):
        picking_id = self.create_picking(cr, uid, ids, context=context)
        if not picking_id:
            raise osv.except_osv('Error!', _('Cannot create picking'))
        return True 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:7,代碼來源:account_invoice.py

示例8: buy_stock

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def buy_stock(self, cr, uid, code, price, amount, context=None):
        """
        ?????????
        :param cr:
        :param uid:
        :param context:
        :return: ????
        """
        trader = Trader().trader
        r = trader.buy(code, price=price, amount=amount)
        # {u'error_no': u'-61', u'error_pathinfo': u'F333002() -> F1333001() -> F2250061()', u'error_info': u'\u5ba2\u6237\u5fc5\u987b\u6709j\u6743\u9650\u624d\u80fd\u5141\u8bb8\u505a\u521b\u4e1a\u677f'}
        # ????
        if r.has_key("error_no"):
            raise osv.except_osv(u"??", r["error_pathinfo"])
        return r['entrust_no'] 
開發者ID:haogefeifei,項目名稱:OdooQuant,代碼行數:17,代碼來源:stock_entrust.py

示例9: write

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def write(self, cr, uid, ids, vals, context=None):
        if not context:
            context = {}

        current_order_object = self.browse(cr, uid, ids, context)
       
        if current_order_object.pos_order_ref and vals.get('lines',False):

            # Check new insert
            for pos_line in vals['lines']:
                # There are : 0 for insert , 1 for editing
                if pos_line[0] == 0:
                    raise osv.except_osv(_('Error!'), _('You can not insert new products to other refunds'))                
            # Check new insert

            # Check new update: can not change price or discount, change the quantity greater than the origin
            check_update = False
            for pos_line in vals['lines']:
                if pos_line[2] and (pos_line[2].get('price_unit',False) or pos_line[2].get('discount',False)):
                    raise osv.except_osv(_('Error!'), _('You can not change the price or the discount of order lines'))

            for pos_line in vals['lines']:
                if pos_line[2] and (pos_line[2].get('qty',False)):
                    pos_order_line_id = pos_line[1]
                    pos_order_line_object = self.pool['pos.order.line'].read(cr, uid, pos_order_line_id,['qty'],context)
                    if (pos_order_line_object['qty']) > (pos_line[2]['qty']): 
                        raise osv.except_osv(_('Error!'), _('You can not change the quantity greater than the origin'))
                    if pos_line[2]['qty'] > 0:
                        raise osv.except_osv(_('Error!'), _('You can not retrun products with negative quantity'))
                        
            # Check new update: can not change price or discount, change the quantity greater than the origin

        res = super(pos_order, self).write(cr, uid, ids, vals, context)
        return res 
開發者ID:nhat2008,項目名稱:odoo-addons-v8,代碼行數:36,代碼來源:point_of_sale.py

示例10: create

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def create(self, cr, uid, vals ,context=None):
        if vals.get('origin',False):
            invoice_list = self.search(cr, uid, [('number','=',vals['origin'])], context={})
            sale_order_list = self.pool['sale.order'].search(cr, uid, [('name','=',vals['origin'])], context={})
            pos_order_list = self.pool['pos.order'].search(cr, uid, [('name','=',vals['origin'])], context={})
            purchase_order_list = self.pool['purchase.order'].search(cr, uid, [('name','=',vals['origin'])], context={})
            if not (invoice_list or sale_order_list or pos_order_list or purchase_order_list):
                raise osv.except_osv(_('Error!'),_("Can not create a refund without a real invoice!"))	
        result = super(account_invoice, self).create(cr, uid, vals, context=context)
        return result 
開發者ID:nhat2008,項目名稱:odoo-addons-v8,代碼行數:12,代碼來源:account.py

示例11: write

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def write(self, cr, uid, ids, vals, context=None):
    	current_object = self.read(cr, uid, ids[0], context={})
        if current_object['origin']:
            refund_list = self.search(cr, uid, [('origin','=',current_object['origin']),('type','like','refund')])
            if len(refund_list) > 1:
                raise osv.except_osv(_('Error!'),_("A refund for this invoice have been created already!"))
        result = super(account_invoice, self).write(cr, uid, ids, vals, context=context)
        return result

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 
開發者ID:nhat2008,項目名稱:odoo-addons-v8,代碼行數:12,代碼來源:account.py

示例12: create

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def create(self, cr, uid, vals, context=None):
        # [ISSUE-032] POS - not allow add product with quantity <= 0 in pos order 
        if not vals.get('pos_order_ref',False) and vals.get('lines',False):
             for pos_line in vals['lines']:
                if pos_line[0] == 0 and pos_line[2]['qty']  <= 0:
                        raise osv.except_osv(_('Error!'), _('You can not add products with quantity <= 0'))
        # [ISSUE-032] POS - not allow add product with quantity <= 0 in pos order 

        res = super(pos_order, self).create(cr, uid, vals , context=context)
        return res 
開發者ID:nhat2008,項目名稱:odoo-addons-v8,代碼行數:12,代碼來源:point_of_sale.py

示例13: check_parent_length

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def check_parent_length(self):
        if not len(self.line_in_ids) or not len(self.line_out_ids):
            raise osv.except_osv(u'??', u'?????????????') 
開發者ID:Judystudy,項目名稱:gooderp,代碼行數:5,代碼來源:production.py

示例14: create_picking

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def create_picking(self, cr, uid, ids, context=None):
        """Create a picking for each invoice and validate it."""
        picking_obj = self.pool.get('stock.picking')
        picking_type_obj = self.pool.get('stock.picking.type')
        partner_obj = self.pool.get('res.partner')
        move_obj = self.pool.get('stock.move')
        picking_id = None
        for invoice in self.browse(cr, uid, ids, context=context):
            if not invoice.warehouse_id.id:
                raise osv.except_osv('Verifique!', 'Seleccione un Almacén')
            if all(t == 'service' for t in invoice.invoice_line.mapped('product_id.type')):
                continue
            addr = invoice.partner_id and partner_obj.address_get(cr, uid, [invoice.partner_id.id], ['delivery']) or {}
            picking_type_id = self._get_picking_type_out(cr, uid, invoice.warehouse_id.id, context=context)
            if not picking_type_id:
                raise osv.except_osv('Error!', _('No se pudo encontrar el tipo de operacion Salida para %s. Puede deverse a que no cuenta con el acceso a dicho almacen o no esta configurado.' % (invoice.warehouse_id.name,)))
            picking_type_obj = picking_type_obj.browse(cr, uid, picking_type_id, context=context)
            picking_id = picking_obj.create(cr, uid, {
                'origin': invoice.number,
                'partner_id': addr.get('delivery',False),
                'date_done': invoice.date_invoice,
                'picking_type_id': picking_type_obj.id,
                'company_id': invoice.company_id.id,
                'move_type': 'direct',
                'note': invoice.comment or "",
                'invoice_state': 'none',
            }, context=context)
            self.write(cr, uid, [invoice.id], {'picking_id': picking_id}, context=context)
            location_id = invoice.warehouse_id.lot_stock_id.id
            destination_id = invoice.partner_id.property_stock_customer.id
            if not destination_id:
                destination_id = picking_type_obj.default_location_dest_id.id
            else:
                destination_id = partner_obj.default_get(cr, uid, ['property_stock_customer'], context=context)['property_stock_customer']
            move_list = []
            for line in invoice.invoice_line:
                if line.product_id and line.product_id.type == 'service':
                    continue
                move_list.append(move_obj.create(cr, uid, {
                    'name': line.name,
                    'product_uom': line.product_id.uom_id.id,
                    'product_uos': line.product_id.uom_id.id,
                    'picking_id': picking_id,
                    'picking_type_id': picking_type_obj.id,
                    'product_id': line.product_id.id,
                    'product_uos_qty': abs(line.quantity),
                    'product_uom_qty': abs(line.quantity),
                    'state': 'draft',
                    'location_id': location_id if line.quantity >= 0 else destination_id,
                    'location_dest_id': destination_id if line.quantity >= 0 else location_id,
                }, context=context))
            if picking_id:
                picking_obj.action_confirm(cr, uid, [picking_id], context=context)
                picking_obj.force_assign(cr, uid, [picking_id], context=context)
                picking_obj.action_done(cr, uid, [picking_id], context=context)
            elif move_list:
                move_obj.action_confirm(cr, uid, move_list, context=context)
                move_obj.force_assign(cr, uid, move_list, context=context)
                move_obj.action_done(cr, uid, move_list, context=context)
        return picking_id 
開發者ID:vmcloudsolution,項目名稱:odoo-generico,代碼行數:62,代碼來源:account_invoice.py

示例15: refund

# 需要導入模塊: from openerp.osv import osv [as 別名]
# 或者: from openerp.osv.osv import osv [as 別名]
def refund(self, cr, uid, ids, context=None):
        """Create a copy of order  for refund order"""
        clone_list = []
        line_obj = self.pool.get('pos.order.line')
        
        for order in self.browse(cr, uid, ids, context=context):
            # Check refund
            pos_order_refund = self.pool.get('pos.order').search(cr, uid, [('pos_order_ref', '=', order.name)], context=context)
            if (pos_order_refund or order.pos_order_ref) and hasattr(order, 'one_time'):
                raise osv.except_osv(_('Error!'),_("A refund for this sale order has created already!"))
            # Check refunds
            current_session_ids = self.pool.get('pos.session').search(cr, uid, [('state', '!=', 'closed'),('user_id', '=', uid)], context=context)

            if not current_session_ids:
                raise osv.except_osv(_('Error!'), _('To return product(s), you need to open a session that will be used to register the refund.'))

            clone_id = self.copy(cr, uid, order.id, {
                'name': order.name + ' REFUND', # not used, name forced by create
                'session_id': current_session_ids[0],
                'date_order': time.strftime('%Y-%m-%d %H:%M:%S'),
                'pos_order_ref': order.name or '',
            }, context=context)
            clone_list.append(clone_id)

        for clone in self.browse(cr, uid, clone_list, context=context):
            for order_line in clone.lines:
                line_obj.write(cr, uid, [order_line.id], {
                    'qty': -order_line.qty
                }, context=context)

        abs = {
            'name': _('Return Products'),
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'pos.order',
            'res_id':clone_list[0],
            'view_id': False,
            'context':context,
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'current',
        }
        return abs 
開發者ID:nhat2008,項目名稱:odoo-addons-v8,代碼行數:45,代碼來源:point_of_sale.py


注:本文中的openerp.osv.osv.osv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。