Monday 28 November 2016

Unable to git clone , Failed to connect to github.com port 443: Network is unreachable

Recently, I have encountered following problem. Might be useful for others who face same error.

I have two different Internet service provider. With one ISP, it works fine but with others it fails.

For example:

git clone https://github.com/odoo/odoo.git

It throws me following error:

fatal: unable to access 'https://github.com/odoo/odoo.git': Failed to connect to github.com port 443: Network is unreachable

I have solved with following trick.

ping github.com
PING github.com (192.30.253.112) 56(84) bytes of data.


Add  192.30.253.112 github.com in /etc/hosts file.


Saturday 12 November 2016

How to create server actions in Odoo 10?

Below is example of server actions in Odoo 8.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <data>
        <record id="action" model="ir.actions.server">
            <field name="name">My Action</field>
            <field name="model_id" ref="model_module_model"/>
            <field name="code">self.action(cr, uid, context=context)</field>
       </record>
    </data>
</odoo>

Following is example for Server actions in Odoo 10.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>

    <data>
        <record id="action" model="ir.actions.server">
            <field name="name">My Action</field>
            <field name="model_id" ref="model_module_model"/>
            <field name="code">
           
            if context.get('active_model') == 'your.module.model' and context.get('active_ids'):
                    action = env['module.model'].browse(context['active_ids']).action()
          
            </field>
       </record>
    </data>
</odoo>


There is no need of self variable to declare server action in Odoo 10.

Tuesday 8 November 2016

How to activate the developer mode in Odoo version 10?

Developer mode has moved from the user screen to Settings.

Click on link "Active the developer mode" or "Active the developer mode (with assets)"


Active Developer mode


What is different between "Active the developer mode" or "Active the developer mode (with assets)" ?

Active the developer mode :- Used by Administrator User to enables Menus, Fields, kind of security access rights.


Active the developer mode (with assets) :- Used by Odoo developers to track js, css, files, which will helpful to improve further performance.





Thursday 7 July 2016

Error when override orm write method in Odoo 8 or 9

If you try override write method with following new API:

         @api.model
         def write(self, vals):
            ....
            return super(MyClass, self).write(vals)

You will see the following error:

        Traceback (most recent call last):
          File "/opt/odoo/odoo-server/openerp/http.py", line 530, in _handle_exception
            return super(JsonRequest, self)._handle_exception(exception)
          File "/opt/odoo/odoo-server/openerp/http.py", line 567, in dispatch
            result = self._call_function(**self.params)
          File "/opt/odoo/odoo-server/openerp/http.py", line 303, in _call_function
            return checked_call(self.db, *args, **kwargs)
          File "/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
            return f(dbname, *args, **kwargs)
          File "/opt/odoo/odoo-server/openerp/http.py", line 300, in checked_call
            return self.endpoint(*a, **kw)
          File "/opt/odoo/odoo-server/openerp/http.py", line 796, in __call__
            return self.method(*args, **kw)
          File "/opt/odoo/odoo-server/openerp/http.py", line 396, in response_wrap
            response = f(*args, **kw)
          File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 939, in call_button
            action = self._call_kw(model, method, args, {})
          File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 927, in _call_kw
            return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
          File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
            return old_api(self, *args, **kwargs)
          File "/opt/odoo/odoo-server/openerp/api.py", line 239, in wrapper
            return new_api(self, *args, **kwargs)
        TypeError: write() got an unexpected keyword argument 'context'

Question: How to resolved mentioned error ?

Solution:

The method write should be decorated with decorator @api.multi. The mapping new API → old API defined by @api.model is inadequate (argument ids is missing).

Try with following code:

         @api.multi
         def write(self, vals):
            ....
            return super(MyClass, self).write(vals)

For more details Odoo documentation 

Wednesday 8 June 2016

How to keep track of employee expenses?

Employee expenses are charges incurred on behalf of the company. The company then reimburses these expenses to the employee. The receipts encountered most frequently are:


  • car travel, reimbursed per unit of distance (mile or kilometer),
  • subsistence expenses, reimbursed based on the bill,
  • other purchases, such as stationery and books, destined for the company but carried out by the employee.

The expenses workflow

 

 * Record a new expense

Every employee of the company can register their expenses from Expenses application ‣ My Expenses. The workflow for personal expenses work that way:
  1. an employee record his expense, and submit it to the manager
  2. the manager approve or refuse the expense
  3. the accountant post journal entries
  4. the company reimburse the employee expense (the employee is like a vendor, with a payable account)
  5. if the expense is linked to an analytic account, the company can reinvoice the customer
For every expense, the employee should record at least:
  • a description: that should include the reference of the ticket / bill
  • a product: the expense type
  • a price (e.g. hotel) or a quantity (e.g. reimburse km if travel with his own car)
Depending of the policy of the company, he might have to attach a scan or a photo of the expense. To do that, just a write a message in the bottom of the expense with the scan of the bill/ticket in attachment.

If the expense is linked to a customer project, you should not forget to set an analytic account, related to the customer project or sale order (you might have to activate analytic accounts in the accounting settings to get this feature).
Once the expense is fully recorded, the employee has to click the button Submit to Manager.

In some companies, employees should submit their expenses grouped at the end of the month, or at the end of a business trip.

An employee can submit all his expenses in batch, using the Submit Expenses action from the list view of expenses, or the small icons in the list view.

* Validation by the manager

Managers should receive an email for every expense to be approved (the manager of an employee is defined on the employee form). They can use the menu To Approve to check all expenses that are waiting for validation.
The manager can:
  • discuss on an expense to ask for more information (e.g., if a scan of the bill is missing);
  • reject an expense;
  • approve an expense.

 

* Control by the accountant

Then, all expenses that have been validated by the manager should be posted by the accountant. When an expense is posted, the related journal entry is created and posted in your accounting.
If the accountant wants to create only one journal entry for a batch of expenses, he can post expenses in batch from the list view of all expenses.

 

* Reinvoice expenses to customers

If the expense was linked to an analytic account related to a sale order, the sale order has a new line related to the expense. This line is not invoiced to the customer yet and will be included in the next invoice that will be send to the customer (charge travel and accommodations on a customer project)
To invoice the customer, just click on the invoice button on his sale order. (or it will be done automatically at the end of the week/month if you invoice all your orders in batch)

 

* Reimburse the employee

If the expense was paid with the employee's own money, the company should reimburse the employee. In such a case, the employee will appear in the aged payable balance until the company reimburse him his expenses.
All you have to do is to create a payment to this employee for the amount due.

 

Youtube video 

 

Reference link

Wednesday 11 May 2016

How to find last day of current month and first day of current month in Python ?

For finding last day of current month, we need to use calendar and datetime python libraries.

Following is an example of it.

>>> import calendar
>>> import datetime

>>> calendar.mdays[datetime.date.today().month]
31

>>> datetime.datetime.today().replace(day=1)
It will replace today's date with starting date of month.

I hope you like this article. Share your views to improve content. Happy Learning !!!

ImportError: cannot import name 'utils' from 'PyPDF2'

Odoo 15: Traceback (most recent call last):   File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner     self...