Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set the default begin date in OpenERP(Odoo)?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 242
    Comment on it

    In below example I have written Python script to Include the default begin date in OpenERP.  You can directly use the below sales module in your addons and run in Odoo server.


     

    from openerp.osv import fields, osv
    
    from openerp.tools.translate import _
    
    from openerp import SUPERUSER_ID
    
    from openerp import api
    
    
    
    
    
    class sup_brand(osv.osv):
    
    	_name = "supplier.brand"
    
    	_rec_name = "supplier_brand"
    
    	_columns = {
    
    				'supplier_brand':fields.char('Supplier Brand'),
    
    	}
    
    sup_brand()
    
    
    
    class sup_refrence(osv.osv):
    
    	_name = "supplier.refrence"
    
    	_rec_name = "item_list"
    
    	_columns = {
    
    				'item_list' : fields.char('Supplier reference'),
    
    	}
    
    sup_refrence()
    
    
    
    class colour_code(osv.osv):
    
    	_name = "colour.code"
    
    	_rec_name = "color_code"
    
    	_columns = {
    
    				'color_code':fields.char('Color Code'),
    
    	}
    
    colour_code()
    
    
    
    class colour_name(osv.osv):
    
    	_name = "colour.name"
    
    	_rec_name = "color_name"
    
    	_columns = {
    
    				'color_name':fields.char('Color Name'),
    
    	}
    
    colour_name()
    
    
    
    class product_template(osv.osv):
    
        _name = "product.template"
    
        _inherit = "product.template"
    
        _columns = {
    
                    'l_price': fields.float('Lower Price'),
    
    				'supp_ref' : fields.char('I Type'),
    
                    'project_price' : fields.float('Project Price'),
    
                    'distributor_pirce' : fields.float('Distributor price'),
    
                    'squ_meter':fields.float('Square Meter', digits=(8,3)),
    
                    'qty_warehous_onhand': fields.float('Qty Sqm in Warehouse', compute='_compute_qty_warehous_onhand', require = True),
    
                    'qty_available_onhand': fields.float('Qty Sqm Available', compute='_compute_qty_available_onhand', require = True),
    
                    'qty_avb':fields.related('qty_available', relation='product.product', string='Quantity on Hand'),
    
                    'qty_avl':fields.related('virtual_available', relation='product.product', string='Quantity on Hand'),
    
                    'opening_stock':fields.float('Opening Stock'),
    
                    'size':fields.char('Size'),
    
                    'unit_measure':fields.char('Unit Of Measure'),
    
                    'item_list' : fields.many2one('supplier.refrence','Supplier reference'),
    
                    'supplier_brand':fields.many2one('supplier.brand','Supplier Brand'),
    
    				'color_code':fields.many2one('colour.code','Color Code'),
    
                    'color_name':fields.many2one('colour.name','Color Name'),
    
                    }
    
                    
    
                  
    
        def button_dummy(self, cr, uid, ids, context=None):
    
            return True
    
                    
    
                    
    
        @api.depends('qty_avb','squ_meter')
    
        def _compute_qty_warehous_onhand(self):
    
            for record in self:
    
                print "sssssssss", record.qty_avb
    
                print "sssssssss", record.squ_meter
    
                print "sssssssss", record._compute_qty_warehous_onhand
    
                record.qty_warehous_onhand = record.qty_avb * record.squ_meter
    
        
    
                        
    
        @api.depends('qty_avl', 'squ_meter')
    
        def _compute_qty_available_onhand(self):
    
            for record in self:
    
                record.qty_available_onhand = record.qty_avl * record.squ_meter
    
    #            print "plsssssssssssssssss", record.qty_warehous_onhand       
    
    
    
    product_template()
    
    
    
    
    
    class product_product(osv.osv):
    
        _name = "product.product"
    
        _inherit = "product.product"
    
        
    
        def name_get(self, cr, user, ids, context=None):
    
            if context is None:
    
                context = {}
    
            if isinstance(ids, (int, long)):
    
                ids = [ids]
    
            if not len(ids):
    
                return []
    
    
    
            def _name_get(d):
    
                name = d.get('name','')
    
                code = context.get('display_default_code', True) and d.get('default_code',False) or False
    
                item_list = d.get('item_list', '')
    
                print item_list , 'the following is the supplier refrence code'
    
    #            if code:
    
    #                name = '[%s] %s' % (code,name)
    
    #            return (d['id'], name)
    
                if item_list:
    
                    name = '[%s] - [%s] %s' % (code,item_list,name)
    
                return (d['id'], name)
    
            partner_id = context.get('partner_id', False)
    
            if partner_id:
    
                partner_ids = [partner_id, self.pool['res.partner'].browse(cr, user, partner_id, context=context).commercial_partner_id.id]
    
            else:
    
                partner_ids = []
    
    
    
            # all user don't have access to seller and partner
    
            # check access and use superuser
    
            self.check_access_rights(cr, user, "read")
    
            self.check_access_rule(cr, user, ids, "read", context=context)
    
    
    
            result = []
    
            for product in self.browse(cr, SUPERUSER_ID, ids, context=context):
    
                variant = ", ".join([v.name for v in product.attribute_value_ids])
    
                name = variant and "%s (%s)" % (product.name, variant) or product.name
    
                sellers = []
    
                if partner_ids:
    
                    sellers = filter(lambda x: x.name.id in partner_ids, product.seller_ids)
    
                if sellers:
    
                    for s in sellers:
    
                        seller_variant = s.product_name and (
    
                            variant and "%s (%s)" % (s.product_name, variant) or s.product_name
    
                            ) or False
    
    
    
                        mydict = {
    
                                  'id': product.id,
    
                                  'name': seller_variant or name,
    
                                  'default_code': s.product_code or product.default_code,
    
                                  'item_list' : product.item_list,
    
                                  }
    
                        result.append(_name_get(mydict))
    
                else:
    
                    mydict = {
    
                              'id': product.id,
    
                              'name': name,
    
                              'default_code': product.default_code,
    
                              'item_list' : product.item_list,
    
                              }
    
                    result.append(_name_get(mydict))
    
            return result
    
            
    
    product_product()
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: