Skip to Content
Menu
This question has been flagged
1 Reply
999 Views

Hi all,

How do I generate a sales report (eg: 1st Jan-1st Feb) for a warehouse which shows a list of products, by group, with:

  • opening stock
  • transfers in/out (eg: internal transfers and/or deliveries of goods in)
  • cost price
  • selling price
  • totals for a group (eg: bottled beers)
  • closing stock
  • total amount made by that warehouse for the data range

I'm trying to use Odoo in hospitality (bars). Would this kind of report be part of the INVENTORY module, or maybe the SALES module? I'm trying out the free version at the moment with only the INVENTORY module.

Thanks!

Avatar
Discard
Best Answer

Hi,

You can create the Python code like:

from odoo import models, fields, api

class WarehouseSalesReport(models.TransientModel):
    _name = 'custom_reports.warehouse_sales_report'
    _description = 'Warehouse Sales Report'

    start_date = fields.Date('Start Date', required=True)
    end_date = fields.Date('End Date', required=True)

    @api.multi
    def generate_report_data(self):
        # Fetch and process data based on the selected date range
        # you can add the condition and other details

        # Return a dictionary with data needed for the report
        return {
            'products': [
                {'name': 'Product 1', 'opening_stock': 10, 'closing_stock': 5, 'cost_price': 15.0, 'selling_price': 20.0},
                # Add the date with your specified requirements
            ],
            'total_amount': 5000.0,
        }

XML :

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <!-- Action to call the report -->
<record id="action_report_warehouse_sales" model="ir.actions.server">
            <field name="name">Generate Warehouse Sales Report</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_custom_reports_warehouse_sales_report"/>
            <field name="state">code</field>
            <field name="code">action = generate_report_data()</field>
        </record>

        <!-- Menu item to trigger the report action -->
<menuitem id="menu_report_warehouse_sales" name="Warehouse Sales Report" parent="menu_custom_reports" sequence="10"/>
<menuitem id="menu_action_report_warehouse_sales" name="Generate Report" parent="menu_report_warehouse_sales" action="action_report_warehouse_sales"/>
    </data>
</odoo>


for reports:  

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_warehouse_sales_template">
        <t t-call="web.html_container">
            <t t-foreach="data['products']" t-as="product">
                <div>
                    <p><t t-esc="product['name']"/></p>
<p>Opening Stock: <t t-esc="product['opening_stock']"/></p>
<p>Closing Stock: <t t-esc="product['closing_stock']"/></p>
<p>Cost Price: <t t-esc="product['cost_price']"/></p>
<p>Selling Price: <t t-esc="product['selling_price']"/></p>
                </div>
            </t>
            <div>
<p>Total Amount: <t t-esc="data['total_amount']"/></p>
            </div>
        </t>
    </template>
</odoo>


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
1
Jan 25
584
1
Dec 24
611
0
Jul 24
819
0
Jun 24
755
0
Mar 24
640