Posts

Showing posts with the label Python

How to Return a View Using Python

  How to Return a View Using Python    @api.multi     def invoice_view_form(self):         ir_model = self.env['ir.model.data']         tree_view_id = ir_model.get_object_reference('account','invoice_tree')[1]         form_view_id = ir_model.get_object_reference('account','invoice_form')[1]         inv_ids = self.env['account.invoice'].search([('sale_id','=',self.id)])                 return {             'name': "Invoices",             'view_type': 'form',             'domain' : [('sale_id','=',self.id)],             'view_mode': 'tree,form',             'view_id': wiz_view_id,             'views' : [(wiz_view_id,'tree'),(form_view_id,'form')], ...

Display weekday of given date in Python

Display Week Day of Given Date : Getting Started:     * First We have to import  module such as datetime and calendar.           * Create new variable to store the string date.      * Convert the string date into datetime.datetime type using following code               datetime.strptime(<Date>,"%d/%m/%Y")      *  Call this function                 calendar.day_name[my_date.weekday()] > day_name :            1.An array that represents the days of the week in the current locale. >weekday :              1. The weekday() method is used to returns the day of the week (0 is Monday) for year (1970–...), month (1–12), day (1–31). Code :     >>> from datetime import datetime >>> imp...

Find System IP Using Python

⤷Find IP Address Using Python Open Terminal Goto pyton console Enter Following Codes. Source Code: Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> socket.gethostbyname(socket.gethostname()) '127.0.1.1' * For find you ip u need socket package import that *  socket. gethostbyname ( hostname ) Translate a host name to IPv4 address format. The IPv4 address is returned as a string, such as  '127.0.1.1' . If the host name is an IPv4 address itself it is returned unchanged.  gethostbyname()  does not support IPv6 name resolution.

Install Package using Python

Install Python Package using Python😀 .Py : try:      import xlsx writter except:      os.system("pip install xlsxwritter")      import xlsxwritter

Python Amount-In-Words

Amount In Words in Python Step-1:             *First You have to import inflect package. Step-2:              *Create one variable and initialise inflect.engine() Step-3:              *Get Values from User. Step-4:              *Call the number_to_words() Step-5:              *Print the value. Program: >>> import inflect >>> kd=inflect.engine() >>> value=10 >>> value=kd.number_to_words(value) >>> value 'ten'