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

[8.0] [IMP] New module that show move state on purchase order line #271

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions purchase_line_move_state/README.rst
@@ -0,0 +1,49 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=================================
Move State in Purchase Order Line
=================================

This module allows to add move status on the purchase order line

Usage
=====

.. 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/8.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/purchase-workflow/issues>`_. 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 `feedback
<https://github.com/OCA/
purchase-workflow/issues/new?body=module:%20
purchase_line_move_state%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Contributors
------------

* Chafique Delli chafique.delli@akretion.com

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.

To contribute to this module, please visit https://odoo-community.org.
5 changes: 5 additions & 0 deletions purchase_line_move_state/__init__.py
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Andrea Gallina @ Apulia Software S.r.l.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import purchase
22 changes: 22 additions & 0 deletions purchase_line_move_state/__openerp__.py
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © 2016 Andrea Gallina @ Apulia Software S.r.l.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': 'Purchase Line Move State',
'summary': 'Add the status of all the incoming move'
' in the purchase order line',
'version': '8.0.1.0.0',
'category': 'Purchase Management',
'website': 'http://www.apuliasoftware.it',
'author': 'Apulia Software S.r.l.',
'license': 'AGPL-3',
'application': False,
'installable': True,
'depends': [
'purchase',
],
# 'data': [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you comment this?

# 'purchase_view.xml',
# ]
}
46 changes: 46 additions & 0 deletions purchase_line_move_state/i18n/it.po
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_line_move_state
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-08 14:07+0000\n"
"PO-Revision-Date: 2016-09-08 14:07+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: purchase_line_move_state
#: code:addons/purchase_line_move_state/purchase.py:15
#, python-format
msgid "Cancelled"
msgstr "Annullato"

#. module: purchase_line_move_state
#: code:addons/purchase_line_move_state/purchase.py:16
#, python-format
msgid "Not Received"
msgstr "Non Ricevuto"

#. module: purchase_line_move_state
#: code:addons/purchase_line_move_state/purchase.py:17
#, python-format
msgid "Partially Received"
msgstr "Parzialmente Ricevuto"

#. module: purchase_line_move_state
#: model:ir.model,name:purchase_line_move_state.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Riga Ordine di Acquisto"

#. module: purchase_line_move_state
#: code:addons/purchase_line_move_state/purchase.py:18
#, python-format
msgid "Transferred"
msgstr "Completato"

44 changes: 44 additions & 0 deletions purchase_line_move_state/purchase.py
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# © 2016 Andrea Gallina @ Apulia Software S.r.l.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api, _


class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'

@api.model
def get_move_state(self):
return [
('draft', ''),
('cancel', _('Cancelled')),
('not_received', _('Not Received')),
('partially_received', _('Partially Received')),
('done', _('Transferred')),
]

@api.multi
@api.depends('move_ids', 'move_ids.state')
def _compute_move_state(self):
for purchase_line in self:
if purchase_line.move_ids:
move_state = set(
[picking.state for picking in purchase_line.move_ids])
if move_state == set(['cancel']):
purchase_line.picking_state = 'cancel'
elif (move_state == set(['cancel', 'done']) or
move_state == set(['done'])):
purchase_line.move_state = 'done'
elif 'done' in move_state:
purchase_line.move_state = 'partially_received'
else:
purchase_line.move_state = 'not_received'
else:
purchase_line.move_state = 'draft'

move_state = fields.Selection(
string="Move status", readonly=True,
compute='_compute_move_state',
selection='get_move_state',
help="Overall status based on all moves")
32 changes: 32 additions & 0 deletions purchase_line_move_state/purchase_view.xml
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>

<record id="purchase.purchase_rfq" model="ir.actions.act_window">
<field name="context">{'purchase_rfq': True}</field>
</record>

<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="journal_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="context.get('purchase_rfq')"/>
</field>
</field>
</record>

</data>
</openerp>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.