Skip to content

Commit

Permalink
[ADD] sale_forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsirintanis committed Mar 11, 2024
1 parent 40e3219 commit 12f7a1e
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions sale_forecast/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions sale_forecast/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Sale Forecast",
"summary": "Sale forecast report",
"version": "16.0.1.0.0",
"category": "Generic Modules/Sale",
"author": "Therp BV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": ["sale", "stock_demand_estimate", "stock_demand_estimate_matrix"],
"data": [
"security/ir.model.access.csv",
"views/date_range.xml",
"views/sale_forecast.xml",
],
"license": "AGPL-3",
}
1 change: 1 addition & 0 deletions sale_forecast/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_forecast
11 changes: 11 additions & 0 deletions sale_forecast/models/sale_forecast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import fields, models


class SaleForecast(models.Model):
_name = "sale.forecast"
_inherits = {"stock.demand.estimate": "stock_demand_id"}
_description = "Sale forecast"

stock_demand_id = fields.Many2one(
comodel_name="stock.demand.estimate", required=True, ondelete="cascade"
)
3 changes: 3 additions & 0 deletions sale_forecast/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_forecast,sale.forcast,model_sale_forecast,stock.group_stock_user,1,0,0,0
access_sale_forecast_system,sale.forecast.system,model_sale_forecast,stock.group_stock_manager,1,1,1,1
10 changes: 10 additions & 0 deletions sale_forecast/views/date_range.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<odoo>
<menuitem
id="date_range_menu"
name="Date Ranges"
parent="sale.menu_sale_config"
action="date_range.date_range_action"
sequence="99"
/>
</odoo>
132 changes: 132 additions & 0 deletions sale_forecast/views/sale_forecast.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" ?>
<odoo>
<record id="sale_forecast_view_tree" model="ir.ui.view">
<field name="name">sale.forecast.tree</field>
<field name="model">sale.forecast</field>
<field name="arch" type="xml">
<tree edit="1" editable="bottom">
<field name="date_range_id" />
<field name="date_from" string="Date From" />
<field name="date_to" string="Date To" />
<field name="product_id" />
<field name="location_id" />
<field name="product_uom_qty" />
<field name="product_uom" />
<field name="product_qty" />
<field name="daily_qty" />
</tree>
</field>
</record>
<record id="sale_forecast_view_form" model="ir.ui.view">
<field name="name">sale.forecast.form</field>
<field name="model">sale.forecast</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group name="dates_read" class="oe_read_only">
<field name="date_from" string="Date From" />
<field name="date_to" string="Date To" />
<field name="duration" string="Duration" />
</group>
<group name="dates_edit" class="oe_edit_only">
<field name="manual_date_from" string="Date From" />
<field name="manual_date_to" string="Date To" />
<field name="manual_duration" string="Duration" />
</group>
<group>
<field name="product_id" />
<field name="location_id" />
<field name="product_uom_qty" />
<field name="product_uom" />
<field name="daily_qty" />
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="sale_forecast_view_pivot" model="ir.ui.view">
<field name="name">sale.forecast.pivot</field>
<field name="model">sale.forecast</field>
<field name="arch" type="xml">
<pivot string="Sale Forecast">
<field name="product_qty" type="measure" />
<field name="product_id" type="row" />
<field name="date_range_id" type="col" />
<field name="date_from" type="col" />
</pivot>
</field>
</record>

<record id="sale_forecast_view_graph" model="ir.ui.view">
<field name="name">sale.forecast.graph</field>
<field name="model">sale.forecast</field>
<field name="arch" type="xml">
<graph type="bar" stacked="True">
<field name="product_qty" type="measure" />
<field name="date_from" />
<field name="product_id" />
</graph>
</field>
</record>

<record id="sale_forecast_view_search" model="ir.ui.view">
<field name="name">sale.forecast.search</field>
<field name="model">sale.forecast</field>
<field name="arch" type="xml">
<search string="Search Sale Forecast">
<field name="product_id" />
<field name="location_id" />
<field name="date_range_id" />
<separator />
<filter
name="expired"
string="Expired"
domain="[('date_to', '&lt;', context_today().strftime('%Y-%m-%d'))]"
/>
<filter
name="not_expired"
string="Not Expired"
domain="['|', ('date_to', '=', False), ('date_to', '&gt;', context_today().strftime('%Y-%m-%d'))]"
/>
<separator />
<group expand="0" string="Group By">
<filter
string="Product"
name="groupby_product"
domain="[]"
context="{'group_by':'product_id'}"
/>
<filter
string="Location"
name="groupby_location"
domain="[]"
context="{'group_by':'location_id'}"
/>
<filter
string="Date (From)"
name="groupby_date_from"
domain="[]"
context="{'group_by':'date_from'}"
/>
</group>
</search>
</field>
</record>
<record id="sale_forecast_action" model="ir.actions.act_window">
<field name="name">Sale Forecast</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.forecast</field>
<field name="view_mode">tree,form,pivot,graph</field>
<field name="search_view_id" ref="sale_forecast_view_search" />
<field name="context">{"search_default_not_expired": 1}</field>
</record>
<menuitem
id="sale_forecast_menu"
name="Forecast"
parent="sale.sale_menu_root"
action="sale_forecast_action"
sequence="10"
/>
</odoo>
1 change: 1 addition & 0 deletions setup/sale_forecast/odoo/addons/sale_forecast
6 changes: 6 additions & 0 deletions setup/sale_forecast/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 12f7a1e

Please sign in to comment.