forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] purchase_picking_state: Migration to 11.0
- Loading branch information
1 parent
a72cdd3
commit 3b4f2a4
Showing
8 changed files
with
142 additions
and
90 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
:target: https://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
=============================== | ||
|
@@ -11,9 +11,13 @@ This module allows to add picking status on the purchase order | |
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/142/9.0 | ||
:target: https://runbot.odoo-community.org/runbot/142/11.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
@@ -25,25 +29,39 @@ help us smashing it by providing a detailed and welcomed `feedback | |
<https://github.com/OCA/ | ||
purchase-workflow/issues/new?body=module:%20 | ||
purchase_picking_state%0Aversion:%20 | ||
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
11.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Credits | ||
======= | ||
|
||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Chafique Delli [email protected] | ||
|
||
* Carlos Lopez Mite <[email protected]> | ||
|
||
Do not contact contributors directly about help with questions or problems concerning | ||
this addon, but use the `forum <https://www.odoo.com/forum/help-1>`_, | ||
the `community mailing list <mailto:[email protected]>`_, | ||
or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ for help, | ||
and the bug tracker linked in `Bug Tracker`_ above for technical issues. | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. | ||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. | ||
To contribute to this module, please visit https://odoo-community.org. |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Chafique DELLI @ Akretion | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
# Copyright 2016 Chafique DELLI @ Akretion | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import purchase | ||
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 |
---|---|---|
@@ -1,21 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Chafique DELLI @ Akretion | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
# Copyright 2016 Chafique DELLI @ Akretion | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
{ | ||
'name': 'Purchase Picking State', | ||
'summary': 'Add the status of all the incoming picking' | ||
' in the purchase order', | ||
'version': '10.0.1.0.0', | ||
'category': 'Purchase Management', | ||
'website': 'http://akretion.com', | ||
'author': 'Akretion', | ||
'version': '11.0.1.0.0', | ||
'author': 'Akretion, ' | ||
'Odoo Community Association (OCA)', | ||
'license': 'AGPL-3', | ||
'application': False, | ||
'installable': True, | ||
'category': 'Purchase Management', | ||
'website': 'https://github.com/OCA/purchase-workflow', | ||
'depends': [ | ||
'purchase', | ||
], | ||
'data': [ | ||
'purchase_view.xml', | ||
] | ||
'views/purchase_view.xml', | ||
], | ||
'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,4 @@ | ||
# Copyright 2016 Chafique DELLI @ Akretion | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import purchase |
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
This file was deleted.
Oops, something went wrong.
89 changes: 64 additions & 25 deletions
89
purchase_picking_state/tests/test_purchase_picking_state.py
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 |
---|---|---|
@@ -1,29 +1,68 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Chafique DELLI @ Akretion | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
# Copyright 2016 Chafique DELLI @ Akretion | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo.tests.common import TransactionCase | ||
from datetime import datetime | ||
|
||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DTF | ||
|
||
from odoo.addons.account.tests.account_test_classes import AccountingTestCase | ||
|
||
|
||
class TestPurchasePickingState(AccountingTestCase): | ||
|
||
def setUp(self): | ||
super(TestPurchasePickingState, self).setUp() | ||
# Useful models | ||
self.PurchaseOrder = self.env['purchase.order'] | ||
self.StockPicking = self.env['stock.picking'] | ||
self.partner_id = self.env.ref('base.res_partner_1') | ||
self.product_id_1 = self.env.ref('product.product_product_8') | ||
self.product_id_2 = self.env.ref('product.product_product_11') | ||
|
||
(self.product_id_1 | self.product_id_2).write({ | ||
'purchase_method': 'purchase', | ||
}) | ||
self.po_vals = { | ||
'partner_id': self.partner_id.id, | ||
'order_line': [ | ||
(0, 0, { | ||
'name': self.product_id_1.name, | ||
'product_id': self.product_id_1.id, | ||
'product_qty': 5.0, | ||
'product_uom': self.product_id_1.uom_po_id.id, | ||
'price_unit': 500.0, | ||
'date_planned': datetime.today().strftime(DTF), | ||
}), | ||
(0, 0, { | ||
'name': self.product_id_2.name, | ||
'product_id': self.product_id_2.id, | ||
'product_qty': 5.0, | ||
'product_uom': self.product_id_2.uom_po_id.id, | ||
'price_unit': 250.0, | ||
'date_planned': datetime.today().strftime(DTF), | ||
})], | ||
} | ||
|
||
class TestPurchasePickingState(TransactionCase): | ||
def test_picking_state_in_purchase_order(self): | ||
draft_order_ids = self.env['purchase.order'].search([ | ||
('state', 'in', ['draft', 'sent', 'bid', 'cancel']), | ||
]) | ||
for purchase in draft_order_ids: | ||
self.assertEquals(purchase.picking_state, 'draft') | ||
confirmed_order_ids = self.env['purchase.order'].search([ | ||
('state', 'in', ['confirmed', 'approved', 'done']), | ||
]) | ||
for purchase in confirmed_order_ids: | ||
pickings_state = set( | ||
[picking.state for picking in purchase.picking_ids]) | ||
if pickings_state == set(['cancel']): | ||
self.assertEquals(purchase.picking_state, 'cancel') | ||
elif (pickings_state == set(['cancel', 'done']) or | ||
pickings_state == set(['done'])): | ||
self.assertEquals(purchase.picking_state, 'done') | ||
elif 'done' in pickings_state: | ||
self.assertEquals(purchase.picking_state, 'partially_received') | ||
else: | ||
self.assertEquals(purchase.picking_state, 'not_received') | ||
self.po = self.PurchaseOrder.create(self.po_vals) | ||
# picking_state equals to draft | ||
self.assertEqual(self.po.picking_state, 'draft') | ||
# confirm po and picking_state equals to not_received | ||
self.po.button_confirm() | ||
self.assertEqual(self.po.picking_state, 'not_received') | ||
# cancel picking and picking_state equals to cancel | ||
self.po.picking_ids.action_cancel() | ||
self.assertEqual(self.po.picking_state, 'cancel') | ||
self.po.button_cancel() | ||
self.po.button_draft() | ||
self.po.button_confirm() | ||
pick = self.po.picking_ids.filtered( | ||
lambda x: x.state not in ('done', 'cancel')) | ||
pick.force_assign() | ||
pick.move_line_ids.write({'qty_done': 2}) | ||
pick.action_done() | ||
self.assertEqual(self.po.picking_state, 'partially_received') | ||
backorders = self.StockPicking.search([('backorder_id', '=', pick.id)]) | ||
backorders.move_line_ids.write({'qty_done': 3}) | ||
backorders.action_done() | ||
self.assertEqual(self.po.picking_state, 'done') |
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="purchase_order_form" model="ir.ui.view"> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="purchase.purchase_order_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="currency_id" position="after"> | ||
<field name="picking_state" attrs="{'invisible':[('picking_state','=', 'draft')]}" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="purchase_order_tree" model="ir.ui.view"> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="purchase.purchase_order_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="state" position="after"> | ||
<field name="picking_state" invisible="not context.get('show_purchase', False)" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |