[MIG] stock_request_purchase: Migration to 14.0

This commit is contained in:
Jesús Alan Ramos Rodríguez
2020-10-12 13:47:48 -05:00
committed by Jesús Alan Ramos Rodríguez
parent ca8a85e6e1
commit e043130b8e
12 changed files with 34 additions and 35 deletions

View File

@@ -14,13 +14,13 @@ Stock Request Purchase
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-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/13.0/stock_request_purchase :target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_request_purchase
: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-13-0/stock-logistics-warehouse-13-0-stock_request_purchase :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_request_purchase
: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/13.0 :target: https://runbot.odoo-community.org/runbot/153/14.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -52,7 +52,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_request_purchase%0Aversion:%2013.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_request_purchase%0Aversion:%2014.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.
@@ -70,6 +70,7 @@ Contributors
* Jordi Ballester <jordi.ballester@forgeflow.com>. * Jordi Ballester <jordi.ballester@forgeflow.com>.
* Enric Tobella <etobella@creublanca.es> * Enric Tobella <etobella@creublanca.es>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th> * Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Alan Ramos <alan.ramos@jarsa.com.mx>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -84,6 +85,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/13.0/stock_request_purchase>`_ project on GitHub. This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_request_purchase>`_ 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

@@ -4,7 +4,7 @@
{ {
"name": "Stock Request Purchase", "name": "Stock Request Purchase",
"summary": "Internal request for stock", "summary": "Internal request for stock",
"version": "13.0.1.0.0", "version": "14.0.1.0.0",
"license": "LGPL-3", "license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-warehouse", "website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "ForgeFlow, Odoo Community Association (OCA)", "author": "ForgeFlow, Odoo Community Association (OCA)",

View File

@@ -13,7 +13,7 @@ class PurchaseOrderLine(models.Model):
) )
def _prepare_stock_moves(self, picking): def _prepare_stock_moves(self, picking):
res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking) res = super()._prepare_stock_moves(picking)
for re in res: for re in res:
re["allocation_ids"] = [ re["allocation_ids"] = [
@@ -29,6 +29,17 @@ class PurchaseOrderLine(models.Model):
] ]
return res return res
@api.model
def _prepare_purchase_order_line_from_procurement(
self, product_id, product_qty, product_uom, company_id, values, po
):
vals = super()._prepare_purchase_order_line_from_procurement(
product_id, product_qty, product_uom, company_id, values, po
)
if "stock_request_id" in values:
vals["stock_request_ids"] = [(4, values["stock_request_id"])]
return vals
@api.constrains("stock_request_ids") @api.constrains("stock_request_ids")
def _check_purchase_company_constrains(self): def _check_purchase_company_constrains(self):
if any( if any(

View File

@@ -14,9 +14,7 @@ class StockRequest(models.Model):
string="Purchase Orders", string="Purchase Orders",
readonly=True, readonly=True,
) )
purchase_count = fields.Integer( purchase_count = fields.Integer(compute="_compute_purchase_ids", readonly=True)
string="Purchase count", compute="_compute_purchase_ids", readonly=True
)
purchase_line_ids = fields.Many2many( purchase_line_ids = fields.Many2many(
"purchase.order.line", string="Purchase Order Lines", readonly=True, copy=False "purchase.order.line", string="Purchase Order Lines", readonly=True, copy=False
) )
@@ -41,7 +39,7 @@ class StockRequest(models.Model):
) )
def action_view_purchase(self): def action_view_purchase(self):
action = self.env.ref("purchase.purchase_order_action_generic").read()[0] action = self.env.ref("purchase.purchase_rfq").read()[0]
purchases = self.mapped("purchase_ids") purchases = self.mapped("purchase_ids")
if len(purchases) > 1: if len(purchases) > 1:

View File

@@ -13,9 +13,7 @@ class StockRequestOrder(models.Model):
string="Purchase Orders", string="Purchase Orders",
readonly=True, readonly=True,
) )
purchase_count = fields.Integer( purchase_count = fields.Integer(compute="_compute_purchase_ids", readonly=True)
string="Purchase count", compute="_compute_purchase_ids", readonly=True
)
purchase_line_ids = fields.Many2many( purchase_line_ids = fields.Many2many(
"purchase.order.line", "purchase.order.line",
compute="_compute_purchase_ids", compute="_compute_purchase_ids",
@@ -32,7 +30,7 @@ class StockRequestOrder(models.Model):
req.purchase_count = len(req.purchase_ids) req.purchase_count = len(req.purchase_ids)
def action_view_purchase(self): def action_view_purchase(self):
action = self.env.ref("purchase.purchase_order_action_generic").read()[0] action = self.env.ref("purchase.purchase_rfq").read()[0]
purchases = self.mapped("purchase_ids") purchases = self.mapped("purchase_ids")
if len(purchases) > 1: if len(purchases) > 1:
action["domain"] = [("id", "in", purchases.ids)] action["domain"] = [("id", "in", purchases.ids)]

View File

@@ -7,20 +7,10 @@ from odoo import models
class StockRule(models.Model): class StockRule(models.Model):
_inherit = "stock.rule" _inherit = "stock.rule"
def _prepare_purchase_order_line(
self, product_id, product_qty, product_uom, company_id, values, po
):
vals = super(StockRule, self)._prepare_purchase_order_line(
product_id, product_qty, product_uom, company_id, values, po
)
if "stock_request_id" in values:
vals["stock_request_ids"] = [(4, values["stock_request_id"])]
return vals
def _update_purchase_order_line( def _update_purchase_order_line(
self, product_id, product_qty, product_uom, company_id, values, line self, product_id, product_qty, product_uom, company_id, values, line
): ):
vals = super(StockRule, self)._update_purchase_order_line( vals = super()._update_purchase_order_line(
product_id, product_qty, product_uom, company_id, values, line product_id, product_qty, product_uom, company_id, values, line
) )
if "stock_request_id" in values: if "stock_request_id" in values:

View File

@@ -1,3 +1,4 @@
* Jordi Ballester <jordi.ballester@forgeflow.com>. * Jordi Ballester <jordi.ballester@forgeflow.com>.
* Enric Tobella <etobella@creublanca.es> * Enric Tobella <etobella@creublanca.es>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th> * Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Alan Ramos <alan.ramos@jarsa.com.mx>

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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_request_purchase"><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_request_purchase"><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><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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_request_purchase"><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-14-0/stock-logistics-warehouse-14-0-stock_request_purchase"><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/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows for users to be able to display purchase orders that have <p>This module allows for users to be able to display purchase orders that have
been created as a consequence of Stock Requests.</p> been created as a consequence of Stock Requests.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@@ -402,7 +402,7 @@ in the Purchase Order.</li>
<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_request_purchase%0Aversion:%2013.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_request_purchase%0Aversion:%2014.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">
@@ -419,6 +419,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;.</li> <li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;.</li>
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li> <li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</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>Alan Ramos &lt;<a class="reference external" href="mailto:alan.ramos&#64;jarsa.com.mx">alan.ramos&#64;jarsa.com.mx</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -428,7 +429,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/13.0/stock_request_purchase">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/14.0/stock_request_purchase">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

@@ -117,7 +117,6 @@ class TestStockRequestPurchase(common.TransactionCase):
self.assertEqual(order.stock_request_ids.state, "open") self.assertEqual(order.stock_request_ids.state, "open")
order.refresh() order.refresh()
self.assertEqual(len(order.sudo().purchase_ids), 1) self.assertEqual(len(order.sudo().purchase_ids), 1)
self.assertEqual(len(order.picking_ids), 0) self.assertEqual(len(order.picking_ids), 0)
self.assertEqual(len(order.move_ids), 0) self.assertEqual(len(order.move_ids), 0)
@@ -138,7 +137,7 @@ class TestStockRequestPurchase(common.TransactionCase):
picking.action_assign() picking.action_assign()
packout1 = picking.move_line_ids[0] packout1 = picking.move_line_ids[0]
packout1.qty_done = 5 packout1.qty_done = 5
picking.action_done() picking.button_validate()
self.assertEqual(order.stock_request_ids.qty_in_progress, 0.0) self.assertEqual(order.stock_request_ids.qty_in_progress, 0.0)
self.assertEqual( self.assertEqual(
@@ -205,7 +204,7 @@ class TestStockRequestPurchase(common.TransactionCase):
picking.action_assign() picking.action_assign()
packout1 = picking.move_line_ids[0] packout1 = picking.move_line_ids[0]
packout1.qty_done = 10 packout1.qty_done = 10
picking.action_done() picking.button_validate()
self.assertEqual(stock_request_1.qty_in_progress, 0.0) self.assertEqual(stock_request_1.qty_in_progress, 0.0)
self.assertEqual(stock_request_1.qty_done, stock_request_1.product_uom_qty) self.assertEqual(stock_request_1.qty_done, stock_request_1.product_uom_qty)

View File

@@ -24,7 +24,7 @@
widget="statinfo" widget="statinfo"
string="Stock Requests" string="Stock Requests"
/> />
<field name="stock_request_ids" invisible="1" /> <field name="stock_request_ids" attrs="{'invisible': True}" />
</button> </button>
</xpath> </xpath>
<xpath expr="//field[@name='order_line']/form//notebook" position="inside"> <xpath expr="//field[@name='order_line']/form//notebook" position="inside">

View File

@@ -9,7 +9,7 @@
<field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]" /> <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<div name="button_box" position="inside"> <div name="button_box" position="inside">
<field name="purchase_ids" invisible="1" /> <field name="purchase_ids" attrs="{'invisible': True}" />
<button <button
type="object" type="object"
name="action_view_purchase" name="action_view_purchase"

View File

@@ -9,7 +9,7 @@
<field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]" /> <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<div name="button_box" position="inside"> <div name="button_box" position="inside">
<field name="purchase_ids" invisible="1" /> <field name="purchase_ids" attrs="{'invisible': True}" />
<button <button
type="object" type="object"
name="action_view_purchase" name="action_view_purchase"