-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] sale_pre_order_amount: Migration to 15.0
- Loading branch information
1 parent
7f7e41c
commit 69f18af
Showing
12 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Foram Shah <foram.shah@initos.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../sale_pre_order_amount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |