Odoo Help


Adding Cost Column and Gross profit to Point of Sale detail report

on 3/9/16, 7:00 PM 1,529 views

Pls, anyone in house that could guide me on how to extend Odoo 8 point of sale report? I want to add two columns to Details of Sales. The column will be Cost price and Gross profit per line.

Then later have a summary of Total sales and Gross profit.

I thank you all in advance.


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 3/11/16, 3:40 AM

To do that you need to inherit the class pos_details using python inheritance and registered as a parser by inheriting the abstract model report.point_of_sale.report_detailsofsales using odoo inheritance by extention to be able to set the new parser class extension. In the new parser class you need to override the method _pos_sales_details that it's the responsible for build the data used for the sale report detail table that you need to add the new columns, in that method you need to extend the result dict with the new data to the report. like:

from openerp.osv import osv

from openerp.addons.point_of_sale.report.pos_details import pos_details

class pos_details_parser(pos_details):

def __init__(self, cr, uid, name, context):

super(pos_details_parser, self).__init__(cr, uid, name, context=context)

self.gross_total = 0.0



'getgrosstotal': self._get_gross_total,


def _pos_sales_details(self, form):

pos_obj = self.pool.get('pos.order')

user_obj = self.pool.get('res.users')

data = []

result = {}

user_ids = form['user_ids'] or self._get_all_users()

company_id = user_obj.browse(self.cr, self.uid, self.uid).company_id.id

pos_ids = pos_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('user_id','in',user_ids),('state','in',['done','paid','invoiced']),('company_id','=',company_id)])

for pos in pos_obj.browse(self.cr, self.uid, pos_ids):

for pol in pos.lines:

result = {

'code': pol.product_id.default_code,

'name': pol.product_id.name,

'invoice_id': pos.invoice_id.id,

'price_unit': pol.price_unit,

'qty': pol.qty,

'discount': pol.discount,

'total': (pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)),

'date_order': pos.date_order,

'pos_name': pos.name,

'uom': pol.product_id.uom_id.name,

'cost_price': pol.product_id.standard_price,

'gross_profit': pol.product_id.list_price - pol.product_id.standard_price,

# or

#'gross_profit': ((pol.product_id.list_price - pol.product_id.standard_price) * pol.qty * (1 - (pol.discount) / 100.0)),



self.total += result['total']

self.qty += result['qty']

self.discount += result['discount']

self.total += result['total']

self.gross_total += result['gross_profit']

if data:

return data


return {}

def _get_gross_total(self):

return self.gross_total

class report_pos_details(osv.AbstractModel):

_inherit = 'report.point_of_sale.report_detailsofsales'

_wrapped_report_class = pos_details_parser

With that code in place you need to use it in the report template like:

<template id="report_detailsofsales" inherit_id="point_of_sale.report_detailsofsales">

<xpath expr="//table[@class='table table-condensed'][1]/thead" position="inside">

<th class="text-center"><strong>Cost Price</strong></th>

<th class="text-center"><strong>Gross Profit</strong></th>


<xpath expr="//table[@class='table table-condensed'][1]/tbody/tr" position="inside">

<td class="text-center">

<span t-esc="formatLang(line_ids['cost_price'], dp='Sale Price')"/>


<td class="text-center">

<span t-esc="formatLang(line_ids['gross_profit'], dp='Sale Price')"/>



<xpath expr="//table[@class='table table-condensed'][2]" position="inside">


<td><strong>Total Gross Profit</strong></td>

<td class="text-right">

<strong t-esc="formatLang(getgrosstotal(), dp='Sale Price', currency_obj = res_company.currency_id)"/>





And now test it all of this, review the gross_profit calculation because I put 2 versions of how to do it depending of what you need to display. I don't test it, this is just an example of the steps that I would do it but probably it will run ok without modifications.
Hope this helps, 

1netcloud Ltd
On 1/30/18, 4:38 PM

Hi Daniel,

Check this module below it may help you


Alfie Qashwa
On 7/14/17, 8:06 AM

what is the meaning of "pol" in pol.product_id.standard_price ??

i'd like to change the "standard_price" in product.template into "price" in product.supplierinfo.

how to change it? thanks

On 3/12/16, 2:08 AM


Where can we apply the below code please. Any idea is highly welcome.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/9/16, 7:00 PM
Seen: 1529 times
Last updated: 1/30/18, 4:38 PM