Skip to content

Commit 2245a47

Browse files
author
Pierrick Brun
committed
MIG 12.0
1 parent f529e7c commit 2245a47

27 files changed

+285
-350
lines changed

oca_dependencies.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
server-ux
2+
product-attribute

quick_purchase/README.rst renamed to purchase_quick/README.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Quick Purchase order
1414
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1515
:alt: License: AGPL-3
1616
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
17-
:target: https://github.com/OCA/purchase-workflow/tree/10.0/quick_purchase
17+
:target: https://github.com/OCA/purchase-workflow/tree/12.0/quick_purchase
1818
:alt: OCA/purchase-workflow
1919
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/purchase-workflow-10-0/purchase-workflow-10-0-quick_purchase
20+
:target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-quick_purchase
2121
:alt: Translate me on Weblate
2222
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/142/10.0
23+
:target: https://runbot.odoo-community.org/runbot/142/12.0
2424
:alt: Try me on Runbot
2525

2626
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -38,13 +38,13 @@ Usage
3838

3939
Inside a purchase order, you can click on "Add products", to open a product tree view, then update "qty to purchase" field.
4040

41-
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/10.0/quick_purchase/static/description/01_purchase_order_create.png
41+
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/12.0/quick_purchase/static/description/01_purchase_order_create.png
4242
:width: 800 px
4343
:alt: Purchase order create
4444

4545
|
4646
47-
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/10.0/quick_purchase/static/description/02_purchase_order_add_product.png
47+
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/12.0/quick_purchase/static/description/02_purchase_order_add_product.png
4848
:width: 800 px
4949
:alt: Purchase order Add product
5050

@@ -54,23 +54,30 @@ The update of "qty to purchase" will add new purchase line or update the existin
5454

5555
|
5656
57-
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/10.0/quick_purchase/static/description/03_purchase_order_updated.png
57+
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/12.0/quick_purchase/static/description/03_purchase_order_updated.png
5858
:width: 800 px
5959
:alt: Purchase order updated
6060

6161
|
6262
63-
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/10.0/quick_purchase/static/description/04_purchase_order_update_product_qty.png
63+
.. image:: https://raw.githubusercontent.com/OCA/purchase-workflow/12.0/quick_purchase/static/description/04_purchase_order_update_product_qty.png
6464
:width: 800 px
6565
:alt: Purchase order update product qty.
6666

67+
Known issues / Roadmap
68+
======================
69+
70+
Purchase module doesn't depend on stock now. This module depends on stock,
71+
if you need to use it without the stock module you can make a PR to
72+
split the module (mainly displaying qty_available of a product)
73+
6774
Bug Tracker
6875
===========
6976

7077
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
7178
In case of trouble, please check there if your issue has already been reported.
7279
If you spotted it first, help us smashing it by providing a detailed and welcomed
73-
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20quick_purchase%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
80+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20quick_purchase%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7481

7582
Do not contact contributors directly about support or help with technical issues.
7683

@@ -101,6 +108,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
101108
mission is to support the collaborative development of Odoo features and
102109
promote its widespread use.
103110

104-
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/10.0/quick_purchase>`_ project on GitHub.
111+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/12.0/quick_purchase>`_ project on GitHub.
105112

106113
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

purchase_quick/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

purchase_quick/__manifest__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# © 2014 Today Akretion
2+
# @author Sébastien BEAU <[email protected]>
3+
# @author Pierrick Brun <[email protected]>
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
5+
6+
{
7+
"name": "Quick Purchase order",
8+
"version": "12.0.1.0.0",
9+
"author": "Akretion, Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/purchase-workflow",
11+
"license": "AGPL-3",
12+
"category": "Purchase",
13+
"depends": ["base_product_mass_addition", "purchase"],
14+
"data": ["views/purchase_view.xml", "views/product_view.xml"],
15+
"installable": True,
16+
}
File renamed without changes.

purchase_quick/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import purchase_order
2+
from . import product_product
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# © 2014 Today Akretion
2+
# @author Sébastien BEAU <[email protected]>
3+
# @author Mourad EL HADJ MIMOUNE <[email protected]>
4+
# @author Pierrick Brun <[email protected]>
5+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
6+
7+
8+
from odoo import api, fields, models
9+
10+
11+
class ProductProduct(models.Model):
12+
_inherit = "product.product"
13+
14+
# for searching purpose
15+
variant_specific_seller_ids = fields.One2many(
16+
"product.supplierinfo", "product_id"
17+
)
18+
po_line_ids = fields.One2many(
19+
comodel_name="purchase.order.line",
20+
inverse_name="product_id",
21+
help="Technical: used to compute quantities to purchase.",
22+
)
23+
24+
@api.depends("po_line_ids")
25+
def _compute_process_qty(self):
26+
res = super(ProductProduct, self)._compute_process_qty()
27+
if self.env.context["parent_model"] == "purchase.order":
28+
po_lines = self.env["purchase.order.line"].search(
29+
[("order_id", "=", self.env.context.get("parent_id"))]
30+
)
31+
for product in self:
32+
product_po_lines = po_lines.filtered(
33+
lambda l, p=product: l.product_id == p
34+
)
35+
for product_po_line in product_po_lines:
36+
product.qty_to_process += product_po_line.product_qty
37+
return res
38+
39+
@api.model
40+
def search(self, args, offset=0, limit=None, order=None, count=False):
41+
purchase = self.env["purchase.order"].browse(
42+
self.env.context.get("parent_id")
43+
)
44+
if self.env.context.get("in_current_parent") and purchase:
45+
po_lines = self.env["purchase.order.line"].search(
46+
[("order_id", "=", purchase.id)]
47+
)
48+
args.append((("id", "in", po_lines.mapped("product_id").ids)))
49+
if self.env.context.get("for_current_supplier") and purchase:
50+
seller = purchase.partner_id
51+
seller = seller.commercial_partner_id or seller
52+
args += [
53+
"|",
54+
("variant_specific_seller_ids.name", "=", seller.id),
55+
"&",
56+
("seller_ids.name", "=", seller.id),
57+
("product_variant_ids", "!=", False),
58+
]
59+
return super(ProductProduct, self).search(
60+
args, offset=offset, limit=limit, order=order, count=count
61+
)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# © 2014 Today Akretion
2+
# @author Sébastien BEAU <[email protected]>
3+
# @author Mourad EL HADJ MIMOUNE <[email protected]>
4+
# @author Pierrick Brun <[email protected]>
5+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
6+
7+
from odoo import api, models, _
8+
9+
10+
class PurchaseOrder(models.Model):
11+
_name = "purchase.order"
12+
_inherit = ["purchase.order", "product.mass.addition"]
13+
14+
@api.multi
15+
def add_product(self):
16+
self.ensure_one()
17+
res = self._common_action_keys()
18+
res["context"].update(
19+
{
20+
"search_default_filter_to_purchase": 1,
21+
"search_default_filter_for_current_supplier": 1,
22+
}
23+
)
24+
commercial = self.partner_id.commercial_partner_id.name
25+
res["name"] = "🔙 %s (%s)" % (_("Product Variants"), commercial)
26+
res["view_id"] = (
27+
self.env.ref("purchase_quick.product_tree_view4purchase").id,
28+
)
29+
return res
30+
31+
def _get_quick_line(self, product):
32+
return self.env["purchase.order.line"].search(
33+
[("product_id", "=", product.id), ("order_id", "=", self.id)],
34+
limit=1,
35+
)
36+
37+
def _get_quick_line_qty_vals(self, product):
38+
return {"product_qty": product.qty_to_process}
39+
40+
def _complete_quick_line_vals(self, vals, lines_key=""):
41+
return super(PurchaseOrder, self)._complete_quick_line_vals(
42+
vals, lines_key="order_line"
43+
)
44+
45+
def _add_quick_line(self, product, lines_key=""):
46+
return super(PurchaseOrder, self)._add_quick_line(
47+
product, lines_key="order_line"
48+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* Sébastien BEAU <[email protected]>
22
* Mourad EL HADJ MIMOUNE <[email protected]>
3+
* Pierrick Brun <[email protected]>
File renamed without changes.

0 commit comments

Comments
 (0)