Skip to content

Commit

Permalink
[MIG] sale_pre_order_amount: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fshah-initos committed May 11, 2022
1 parent 7f7e41c commit 69f18af
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sale_pre_order_amount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=====================
Sale Pre-Order Amount
=====================

* This module adds a smart button in Product to open the confirmed/assigned Stock Moves (Sale Pre-Order Amount) of the related product.

Installation
============

* sale_management
* sale_stock

Contributors
------------

* Foram Shah <foram.shah@initos.com>
1 change: 1 addition & 0 deletions sale_pre_order_amount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions sale_pre_order_amount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Sale Pre Order Amount",
"version": "15.0.1.0.0",
"category": "Inventory",
"author": "ERP Harbor Consulting Services, Nitrokey GmbH, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"summary": """
This module adds a smart button in Product to open
the confirmed/assigned Stock Moves (Sale Pre-Order Amount)
of the related product.
""",
"depends": [
"sale_management",
"sale_stock",
],
"data": [
"views/nitrokey_pre_order_view.xml",
"views/product_view.xml",
],
"license": "AGPL-3",
"installable": True,
}
1 change: 1 addition & 0 deletions sale_pre_order_amount/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product
46 changes: 46 additions & 0 deletions sale_pre_order_amount/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

pre_order_count = fields.Float(
"Pre-Order Count", compute="_compute_pre_order_count"
)

def _compute_pre_order_count(self):
move_obj = self.env["stock.move"]
for product_tmpl in self:
stock_moves = move_obj.search(
[
("product_id.product_tmpl_id", "=", product_tmpl.id),
("picking_id", "!=", False),
("picking_id.picking_type_id.code", "=", "outgoing"),
("picking_id.state", "in", ["confirmed", "assigned"]),
]
)
product_tmpl.pre_order_count = sum(stock_moves.mapped("product_uom_qty"))
return True

def action_view_pre_order_moves(self):
stock_moves = self.env["stock.move"].search(
[
("product_id.product_tmpl_id", "=", self.id),
("picking_id", "!=", False),
("picking_id.picking_type_id.code", "=", "outgoing"),
("picking_id.state", "in", ["confirmed", "assigned"]),
]
)
picking = stock_moves.mapped("picking_id")
return {
"name": "Pre-Orders",
"type": "ir.actions.act_window",
"res_model": "stock.picking",
"view_type": "form",
"view_mode": "tree,form",
"views": [
(self.env.ref("stock.vpicktree").id, "tree"),
(self.env.ref("stock.view_picking_form").id, "form"),
],
"domain": [("id", "in", picking.ids)],
}
1 change: 1 addition & 0 deletions sale_pre_order_amount/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Foram Shah <foram.shah@initos.com>
1 change: 1 addition & 0 deletions sale_pre_order_amount/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module adds a smart button in Product to open the confirmed/assigned Stock Moves (Sale Pre-Order Amount) of the related product.
9 changes: 9 additions & 0 deletions sale_pre_order_amount/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

To use this module, you need to:

* Go to a sale order.
* Click on "create" button and create new sale order.
* Go to products menu and open product create sale order.
* When you open product see smart "Pre-Orders" button and click on it.
* And display creatd sale order list.

24 changes: 24 additions & 0 deletions sale_pre_order_amount/views/nitrokey_pre_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="action_nitrokey_pre_order_amount" model="ir.actions.act_window">
<field name="name">Pre-Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.picking</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="stock.vpicktree" />
<field name="domain">[
('picking_type_id.code', '=', 'outgoing'),
('state', 'in', ['confirmed', 'assigned'])
]</field>
</record>

<menuitem
id="menu_nitrokey_pre_order_amount"
name="Pre-Orders"
action="action_nitrokey_pre_order_amount"
parent="stock.menu_warehouse_report"
sequence="200"
/>

</odoo>
29 changes: 29 additions & 0 deletions sale_pre_order_amount/views/product_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" ?>
<odoo>

<record id="view_pre_order_product_form" model="ir.ui.view">
<field name="name">view.pre.order.product.form</field>
<field name="model">product.template</field>
<field
name="inherit_id"
ref="sale_stock.product_template_view_form_inherit_stock"
/>
<field name="arch" type="xml">
<button name="action_view_orderpoints" position="before">
<button
class="oe_stat_button"
name="action_view_pre_order_moves"
type="object"
icon="fa-shopping-cart"
>
<field
name="pre_order_count"
widget="statinfo"
string="Pre-Orders"
/>
</button>
</button>
</field>
</record>

</odoo>
6 changes: 6 additions & 0 deletions setup/sale_pre_order_amount/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 69f18af

Please sign in to comment.