[MIG] stock_orderpoint_manual_procurement: Migration to 13.0

This commit is contained in:
Joan Sisquella
2020-01-20 15:25:32 +01:00
committed by Hai Lang
parent 2852918831
commit c79f38f5cb
13 changed files with 117 additions and 104 deletions

View File

@@ -14,13 +14,13 @@ Stock Orderpoint Manual Procurement
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_orderpoint_manual_procurement :target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_orderpoint_manual_procurement
:alt: OCA/stock-logistics-warehouse :alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_orderpoint_manual_procurement :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_orderpoint_manual_procurement
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/12.0 :target: https://runbot.odoo-community.org/runbot/153/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -56,7 +56,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_orderpoint_manual_procurement%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_orderpoint_manual_procurement%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@@ -66,15 +66,16 @@ Credits
Authors Authors
~~~~~~~ ~~~~~~~
* Eficent * ForgeFlow
Contributors Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Lois Rilo Antelo <lois.rilo@eficent.com> * Lois Rilo Antelo <lois.rilo@forgeflow.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com> * Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th> * Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Joan Sisquella Andrés <joan.sisquella@forgeflow.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -89,6 +90,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_orderpoint_manual_procurement>`_ project on GitHub. This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_orderpoint_manual_procurement>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,13 +1,12 @@
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. # Copyright 2016-20 ForgeFlow S.L. (https://www.forgeflow.com)
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "Stock Orderpoint Manual Procurement", "name": "Stock Orderpoint Manual Procurement",
"summary": "Allows to create procurement orders from orderpoints instead " "summary": "Allows to create procurement orders from orderpoints instead "
"of relying only on the scheduler.", "of relying only on the scheduler.",
"version": "12.0.1.1.0", "version": "13.0.1.0.0",
"author": "Eficent, " "Odoo Community Association (OCA)", "author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse", "website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse Management", "category": "Warehouse Management",
"depends": ["purchase_stock"], "depends": ["purchase_stock"],

View File

@@ -1,8 +1,8 @@
<?xml version="1.0"?> <?xml version="1.0" ?>
<odoo noupdate="1"> <odoo noupdate="1">
<record id="product_supplierinfo_product_7" model="product.supplierinfo"> <record id="product_supplierinfo_product_7" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product.product_product_7"/> <field name="product_tmpl_id" ref="product.product_product_7" />
<field name="name" ref="base.res_partner_3"/> <field name="name" ref="base.res_partner_3" />
<field name="delay">3</field> <field name="delay">3</field>
<field name="min_qty">1</field> <field name="min_qty">1</field>
<field name="price">72</field> <field name="price">72</field>

View File

@@ -1,12 +1,12 @@
# Translation of Odoo Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * stock_orderpoint_manual_procurement # * stock_orderpoint_manual_procurement
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@@ -105,7 +105,7 @@ msgid "Minimum Inventory Rule"
msgstr "" msgstr ""
#. module: stock_orderpoint_manual_procurement #. module: stock_orderpoint_manual_procurement
#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:72 #: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:0
#, python-format #, python-format
msgid "No reordering rule found!" msgid "No reordering rule found!"
msgstr "" msgstr ""
@@ -143,7 +143,7 @@ msgid "Quantity"
msgstr "" msgstr ""
#. module: stock_orderpoint_manual_procurement #. module: stock_orderpoint_manual_procurement
#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:70 #: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:0
#, python-format #, python-format
msgid "Quantity must be positive." msgid "Quantity must be positive."
msgstr "" msgstr ""
@@ -172,7 +172,8 @@ msgstr ""
#. module: stock_orderpoint_manual_procurement #. module: stock_orderpoint_manual_procurement
#: model_terms:ir.ui.view,arch_db:stock_orderpoint_manual_procurement.view_make_procure_without_security #: model_terms:ir.ui.view,arch_db:stock_orderpoint_manual_procurement.view_make_procure_without_security
#: model_terms:ir.ui.view,arch_db:stock_orderpoint_manual_procurement.view_make_procurment_buffer_wizard #: model_terms:ir.ui.view,arch_db:stock_orderpoint_manual_procurement.view_make_procurment_buffer_wizard
msgid "Use this assistant to generate a procurement request for this\n" msgid ""
"Use this assistant to generate a procurement request for this\n"
" stock buffer. According to the product configuration,\n" " stock buffer. According to the product configuration,\n"
" this may trigger a draft purchase order, a manufacturing\n" " this may trigger a draft purchase order, a manufacturing\n"
" order or a transfer picking." " order or a transfer picking."
@@ -187,4 +188,3 @@ msgstr ""
#: model:ir.model.fields,field_description:stock_orderpoint_manual_procurement.field_make_procurement_orderpoint_item__wiz_id #: model:ir.model.fields,field_description:stock_orderpoint_manual_procurement.field_make_procurement_orderpoint_item__wiz_id
msgid "Wizard" msgid "Wizard"
msgstr "" msgstr ""

View File

@@ -108,7 +108,7 @@ msgid "Minimum Inventory Rule"
msgstr "最小库存规则" msgstr "最小库存规则"
#. module: stock_orderpoint_manual_procurement #. module: stock_orderpoint_manual_procurement
#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:72 #: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:0
#, python-format #, python-format
msgid "No reordering rule found!" msgid "No reordering rule found!"
msgstr "找不到重新订购规则!" msgstr "找不到重新订购规则!"
@@ -146,7 +146,7 @@ msgid "Quantity"
msgstr "数量" msgstr "数量"
#. module: stock_orderpoint_manual_procurement #. module: stock_orderpoint_manual_procurement
#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:70 #: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:0
#, python-format #, python-format
msgid "Quantity must be positive." msgid "Quantity must be positive."
msgstr "数量必须为正数。" msgstr "数量必须为正数。"

View File

@@ -1,5 +1,4 @@
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. # Copyright 2016-20 ForgeFlow S.L. (https://www.forgeflow.com)
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from datetime import datetime from datetime import datetime
@@ -7,10 +6,6 @@ from datetime import datetime
from odoo import api, fields, models from odoo import api, fields, models
from odoo.tools import float_compare, float_round from odoo.tools import float_compare, float_round
from odoo.addons import decimal_precision as dp
UNIT = dp.get_precision("Product Unit of Measure")
class StockWarehouseOrderpoint(models.Model): class StockWarehouseOrderpoint(models.Model):
_inherit = "stock.warehouse.orderpoint" _inherit = "stock.warehouse.orderpoint"
@@ -18,13 +13,12 @@ class StockWarehouseOrderpoint(models.Model):
procure_recommended_qty = fields.Float( procure_recommended_qty = fields.Float(
string="Procure Recommendation", string="Procure Recommendation",
compute="_compute_procure_recommended", compute="_compute_procure_recommended",
digits=UNIT, digits="Product Unit of Measure",
) )
procure_recommended_date = fields.Date( procure_recommended_date = fields.Date(
string="Recommended Request Date", compute="_compute_procure_recommended" string="Recommended Request Date", compute="_compute_procure_recommended"
) )
@api.multi
def _get_procure_recommended_qty(self, virtual_qty, op_qtys): def _get_procure_recommended_qty(self, virtual_qty, op_qtys):
self.ensure_one() self.ensure_one()
procure_recommended_qty = 0.0 procure_recommended_qty = 0.0
@@ -45,7 +39,6 @@ class StockWarehouseOrderpoint(models.Model):
procure_recommended_qty = qty_rounded procure_recommended_qty = qty_rounded
return procure_recommended_qty return procure_recommended_qty
@api.multi
@api.depends("product_min_qty", "product_id", "qty_multiple") @api.depends("product_min_qty", "product_id", "qty_multiple")
def _compute_procure_recommended(self): def _compute_procure_recommended(self):
op_qtys = self._quantity_in_progress() op_qtys = self._quantity_in_progress()

View File

@@ -1,4 +1,5 @@
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Lois Rilo Antelo <lois.rilo@eficent.com> * Lois Rilo Antelo <lois.rilo@forgeflow.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com> * Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th> * Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Joan Sisquella Andrés <joan.sisquella@forgeflow.com>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0"?> <?xml version="1.0" ?>
<odoo noupdate="1"> <odoo noupdate="1">
<record id="group_change_orderpoint_procure_qty" model="res.groups"> <record id="group_change_orderpoint_procure_qty" model="res.groups">
<field name="name">Change quantity in manual procurements from reordering rules</field> <field
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/> name="name"
<field name="category_id" ref="base.module_category_hidden"/> >Change quantity in manual procurements from reordering rules</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
<field name="category_id" ref="base.module_category_hidden" />
</record> </record>
</odoo> </odoo>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_orderpoint_manual_procurement"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_orderpoint_manual_procurement"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_orderpoint_manual_procurement"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_orderpoint_manual_procurement"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows users to manually start procurements from the list of reordering rules, <p>This module allows users to manually start procurements from the list of reordering rules,
based on the quantity that is recommended to be procured.</p> based on the quantity that is recommended to be procured.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@@ -403,7 +403,7 @@ procurement unit of measure indicated in the reordering rule.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_orderpoint_manual_procurement%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_orderpoint_manual_procurement%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -411,16 +411,17 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2> <h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Eficent</li> <li>ForgeFlow</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2> <h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficent.com">jordi.ballester&#64;eficent.com</a>&gt;</li> <li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Lois Rilo Antelo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li> <li>Lois Rilo Antelo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Bhavesh Odedra &lt;<a class="reference external" href="mailto:bodedra&#64;opensourceintegrators.com">bodedra&#64;opensourceintegrators.com</a>&gt;</li> <li>Bhavesh Odedra &lt;<a class="reference external" href="mailto:bodedra&#64;opensourceintegrators.com">bodedra&#64;opensourceintegrators.com</a>&gt;</li>
<li>Kitti Upariphutthiphong &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li> <li>Kitti Upariphutthiphong &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
<li>Joan Sisquella Andrés &lt;<a class="reference external" href="mailto:joan.sisquella&#64;forgeflow.com">joan.sisquella&#64;forgeflow.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -430,7 +431,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_orderpoint_manual_procurement">OCA/stock-logistics-warehouse</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_orderpoint_manual_procurement">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -1,5 +1,4 @@
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. # Copyright 2016-20 ForgeFlow S.L. (https://www.forgeflow.com)
# (http://www.eficent.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. # Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@@ -58,7 +57,7 @@ class TestStockWarehouseOrderpoint(common.TransactionCase):
# Add default quantity # Add default quantity
quantity = 20.00 quantity = 20.00
self._update_product_qty(self.product, self.location, quantity) self._update_product_qty(self.product, quantity)
# Create Reordering Rule # Create Reordering Rule
self.reorder = self.create_orderpoint() self.reorder = self.create_orderpoint()
@@ -97,12 +96,12 @@ class TestStockWarehouseOrderpoint(common.TransactionCase):
) )
return product return product
def _update_product_qty(self, product, location, quantity): def _update_product_qty(self, product, quantity):
"""Update Product quantity.""" """Update Product quantity."""
change_product_qty = self.stock_change_model.create( change_product_qty = self.stock_change_model.create(
{ {
"location_id": location.id,
"product_id": product.id, "product_id": product.id,
"product_tmpl_id": product.product_tmpl_id.id,
"new_quantity": quantity, "new_quantity": quantity,
} }
) )
@@ -111,7 +110,7 @@ class TestStockWarehouseOrderpoint(common.TransactionCase):
def create_orderpoint(self): def create_orderpoint(self):
"""Create a Reordering Rule""" """Create a Reordering Rule"""
reorder = self.reordering_rule_model.sudo(self.user).create( reorder = self.reordering_rule_model.with_user(self.user).create(
{ {
"name": "Order-point", "name": "Order-point",
"product_id": self.product.id, "product_id": self.product.id,
@@ -130,7 +129,7 @@ class TestStockWarehouseOrderpoint(common.TransactionCase):
"active_id": self.reorder.id, "active_id": self.reorder.id,
} }
wizard = ( wizard = (
self.make_procurement_orderpoint_model.sudo(self.user) self.make_procurement_orderpoint_model.with_user(self.user)
.with_context(context) .with_context(context)
.create({}) .create({})
) )
@@ -153,6 +152,7 @@ class TestStockWarehouseOrderpoint(common.TransactionCase):
[("orderpoint_id", "=", self.reorder.id), ("order_id", "=", purchase.id)] [("orderpoint_id", "=", self.reorder.id), ("order_id", "=", purchase.id)]
) )
self.assertEquals(len(purchase_line), 1) self.assertEquals(len(purchase_line), 1)
self.reorder._compute_procure_recommended()
self.assertNotEqual( self.assertNotEqual(
self.reorder.procure_recommended_qty, purchase_line.product_qty self.reorder.procure_recommended_qty, purchase_line.product_qty
) )

View File

@@ -1,20 +1,20 @@
<?xml version="1.0"?> <?xml version="1.0" ?>
<odoo> <odoo>
<record id="view_warehouse_orderpoint_tree" model="ir.ui.view"> <record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.tree</field> <field name="name">stock.warehouse.orderpoint.tree</field>
<field name="model">stock.warehouse.orderpoint</field> <field name="model">stock.warehouse.orderpoint</field>
<field name="inherit_id" <field name="inherit_id" ref="stock.view_warehouse_orderpoint_tree" />
ref="stock.view_warehouse_orderpoint_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="product_uom" position="after"> <field name="product_uom" position="after">
<field name="procure_recommended_qty"/> <field name="procure_recommended_qty" />
<field name="procure_recommended_date"/> <field name="procure_recommended_date" />
<button string="Create Procurement" <button
name="%(stock_orderpoint_manual_procurement.act_make_procurement_from_orderpoint)d" string="Create Procurement"
icon="fa-cogs" type="action"/> name="%(stock_orderpoint_manual_procurement.act_make_procurement_from_orderpoint)d"
icon="fa-cogs"
type="action"
/>
</field> </field>
</field> </field>
</record> </record>
</odoo> </odoo>

View File

@@ -1,5 +1,4 @@
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. # Copyright 2016-20 ForgeFlow S.L. (https://www.forgeflow.com)
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models from odoo import _, api, fields, models
@@ -59,13 +58,13 @@ class MakeProcurementOrderpoint(models.TransientModel):
res["item_ids"] = items res["item_ids"] = items
return res return res
@api.multi
def make_procurement(self): def make_procurement(self):
self.ensure_one() self.ensure_one()
errors = [] errors = []
# User requesting the procurement is passed by context to be able to # User requesting the procurement is passed by context to be able to
# update final MO, PO or trasfer with that information. # update final MO, PO or trasfer with that information.
pg_obj = self.env["procurement.group"].with_context(requested_uid=self.env.user) pg_obj = self.env["procurement.group"].with_context(requested_uid=self.env.user)
procurements = []
for item in self.item_ids: for item in self.item_ids:
if not item.qty: if not item.qty:
raise ValidationError(_("Quantity must be positive.")) raise ValidationError(_("Quantity must be positive."))
@@ -75,21 +74,25 @@ class MakeProcurementOrderpoint(models.TransientModel):
values["date_planned"] = fields.Datetime.to_string( values["date_planned"] = fields.Datetime.to_string(
fields.Date.from_string(item.date_planned) fields.Date.from_string(item.date_planned)
) )
# Run procurement procurements.append(
try: pg_obj.Procurement(
pg_obj.run(
item.orderpoint_id.product_id, item.orderpoint_id.product_id,
item.qty, item.qty,
item.uom_id, item.uom_id,
item.orderpoint_id.location_id, item.orderpoint_id.location_id,
item.orderpoint_id.name, item.orderpoint_id.name,
item.orderpoint_id.name, item.orderpoint_id.name,
item.orderpoint_id.company_id,
values, values,
) )
except UserError as error: )
errors.append(error.name) try:
if errors: # Run procurement
raise UserError("\n".join(errors)) pg_obj.run(procurements)
except UserError as error:
errors.append(error.name)
if errors:
raise UserError("\n".join(errors))
return {"type": "ir.actions.act_window_close"} return {"type": "ir.actions.act_window_close"}
@@ -123,7 +126,6 @@ class MakeProcurementOrderpointItem(models.TransientModel):
string="Location", comodel_name="stock.location", readonly=True string="Location", comodel_name="stock.location", readonly=True
) )
@api.multi
@api.onchange("uom_id") @api.onchange("uom_id")
def onchange_uom_id(self): def onchange_uom_id(self):
for rec in self: for rec in self:

View File

@@ -1,6 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0" ?>
<odoo> <odoo>
<!-- Make Procurement with security access right --> <!-- Make Procurement with security access right -->
<record id="view_make_procurment_buffer_wizard" model="ir.ui.view"> <record id="view_make_procurment_buffer_wizard" model="ir.ui.view">
<field name="name">Request Procurement</field> <field name="name">Request Procurement</field>
@@ -16,25 +15,35 @@
<group name="items" string="Items"> <group name="items" string="Items">
<field name="item_ids" nolabel="1"> <field name="item_ids" nolabel="1">
<tree string="Items" nocreate="1" editable="top"> <tree string="Items" nocreate="1" editable="top">
<field name="orderpoint_id" invisible="True"/> <field name="orderpoint_id" invisible="True" />
<field name="warehouse_id" groups="stock.group_stock_multi_locations"/> <field
<field name="location_id" groups="stock.group_stock_multi_locations"/> name="warehouse_id"
<field name="product_id"/> groups="stock.group_stock_multi_locations"
<field name="qty"/> />
<field name="qty_without_security" invisible="1"/> <field
<field name="uom_id" groups="uom.group_uom"/> name="location_id"
<field name="date_planned"/> groups="stock.group_stock_multi_locations"
/>
<field name="product_id" />
<field name="qty" />
<field name="qty_without_security" invisible="1" />
<field name="uom_id" groups="uom.group_uom" />
<field name="date_planned" />
</tree> </tree>
</field> </field>
</group> </group>
<footer> <footer>
<button string="Execute" name="make_procurement" type="object" class="btn-primary"/> <button
<button string="Cancel" class="btn-default" special="cancel"/> string="Execute"
name="make_procurement"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer> </footer>
</form> </form>
</field> </field>
</record> </record>
<!-- Make Procurement without security access right --> <!-- Make Procurement without security access right -->
<record id="view_make_procure_without_security" model="ir.ui.view"> <record id="view_make_procure_without_security" model="ir.ui.view">
<field name="name">Request Procurement</field> <field name="name">Request Procurement</field>
@@ -50,33 +59,40 @@
<group name="items" string="Items"> <group name="items" string="Items">
<field name="item_ids" nolabel="1"> <field name="item_ids" nolabel="1">
<tree string="Items" nocreate="1" editable="top"> <tree string="Items" nocreate="1" editable="top">
<field name="orderpoint_id" invisible="True"/> <field name="orderpoint_id" invisible="True" />
<field name="warehouse_id" groups="stock.group_stock_multi_locations"/> <field
<field name="location_id" groups="stock.group_stock_multi_locations"/> name="warehouse_id"
<field name="product_id"/> groups="stock.group_stock_multi_locations"
<field name="qty" invisible="1"/> />
<field name="qty_without_security" readonly="1"/> <field
<field name="uom_id" groups="uom.group_uom"/> name="location_id"
<field name="date_planned"/> groups="stock.group_stock_multi_locations"
/>
<field name="product_id" />
<field name="qty" invisible="1" />
<field name="qty_without_security" readonly="1" />
<field name="uom_id" groups="uom.group_uom" />
<field name="date_planned" />
</tree> </tree>
</field> </field>
</group> </group>
<footer> <footer>
<button string="Execute" name="make_procurement" type="object" class="btn-primary"/> <button
<button string="Cancel" class="btn-default" special="cancel"/> string="Execute"
name="make_procurement"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer> </footer>
</form> </form>
</field> </field>
</record> </record>
<record model="ir.actions.act_window" id="act_make_procurement_from_orderpoint">
<record model="ir.actions.act_window"
id="act_make_procurement_from_orderpoint">
<field name="name">Request Procurement</field> <field name="name">Request Procurement</field>
<field name="res_model">make.procurement.orderpoint</field> <field name="res_model">make.procurement.orderpoint</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="target">new</field> <field name="target">new</field>
<field name="binding_model_id" <field name="binding_model_id" ref="stock.model_stock_warehouse_orderpoint" />
ref="stock.model_stock_warehouse_orderpoint"/>
</record> </record>
</odoo> </odoo>