Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] sale_pre_order_amount: Migration to 15.0 #2011

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]

Check warning on line 12 in sale_pre_order_amount/models/product.py

View check run for this annotation

Codecov / codecov/patch

sale_pre_order_amount/models/product.py#L12

Added line #L12 was not covered by tests
for product_tmpl in self:
stock_moves = move_obj.search(

Check warning on line 14 in sale_pre_order_amount/models/product.py

View check run for this annotation

Codecov / codecov/patch

sale_pre_order_amount/models/product.py#L14

Added line #L14 was not covered by tests
[
("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

Check warning on line 23 in sale_pre_order_amount/models/product.py

View check run for this annotation

Codecov / codecov/patch

sale_pre_order_amount/models/product.py#L22-L23

Added lines #L22 - L23 were not covered by tests

def action_view_pre_order_moves(self):
stock_moves = self.env["stock.move"].search(

Check warning on line 26 in sale_pre_order_amount/models/product.py

View check run for this annotation

Codecov / codecov/patch

sale_pre_order_amount/models/product.py#L26

Added line #L26 was not covered by tests
[
("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 {

Check warning on line 35 in sale_pre_order_amount/models/product.py

View check run for this annotation

Codecov / codecov/patch

sale_pre_order_amount/models/product.py#L34-L35

Added lines #L34 - L35 were not covered by tests
"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.
7 changes: 7 additions & 0 deletions sale_pre_order_amount/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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,
)