Skip to content

Commit

Permalink
[IMP] stock_quant_reservation_status: In stock quant object, put fiel…
Browse files Browse the repository at this point in the history
…d "reserved_for" to store=True, for group by this field.
  • Loading branch information
alfredoavanzosc committed Jan 23, 2020
1 parent b69c3d7 commit 1d713e5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
Expand Up @@ -67,5 +67,6 @@ def _group_by(self):

def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (%s %s %s)
""" % (self._table, self._select(), self._from(), self._group_by()))
cr.execute('CREATE or REPLACE VIEW %s as (%s %s %s)',
(self._table, self._select(), self._from(),
self._group_by()))
12 changes: 8 additions & 4 deletions stock_quant_reservation_status/README.rst
@@ -1,8 +1,12 @@
Reserved Quants
===============
.. 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

This module allows you to distinguish if a quant is reserved or not.
==============================
Stock quant reservation status
==============================

This module allows you to distinguish if a quant is reserved or not.

Credits
=======
Expand All @@ -11,4 +15,4 @@ Contributors
------------
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <anajuaristi@avanzosc.es>
* Ana Juaristi <anajuaristi@avanzosc.es>
4 changes: 2 additions & 2 deletions stock_quant_reservation_status/__openerp__.py
Expand Up @@ -9,10 +9,10 @@
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# GNU Affero General Public License for more details
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

Expand Down
11 changes: 11 additions & 0 deletions stock_quant_reservation_status/i18n/es.po
Expand Up @@ -35,3 +35,14 @@ msgstr "Quant reservado"
msgid "Unreserved"
msgstr "No reservado"

#. module: stock_quant_reservation_status
#: view:stock.quant:stock_quant_reservation_status.stock_quant_reserved_search_view
msgid "Company"
msgstr "Compañía"

#. module: stock_quant_reservation_status
#: view:stock.quant:stock_quant_reservation_status.stock_quant_reserved_search_view
#: field:stock.quant,reserved_for:0
msgid "Reserved for"
msgstr "Reservado para"

5 changes: 3 additions & 2 deletions stock_quant_reservation_status/models/stock.py
Expand Up @@ -10,7 +10,8 @@ class StockQuant(models.Model):
_inherit = 'stock.quant'

@api.one
@api.depends('reservation_id')
@api.depends('reservation_id', 'reservation_id.origin',
'reservation_id.picking_id', 'reservation_id.picking_id.name')
def _is_reserved(self):
self.is_reserved = bool(self.reservation_id)
self.reserved_for = (
Expand All @@ -20,4 +21,4 @@ def _is_reserved(self):
is_reserved = fields.Boolean(
string='Reserved Quant', compute='_is_reserved', store=True)
reserved_for = fields.Char(
string='Reserved for', compute='_is_reserved')
string='Reserved for', compute='_is_reserved', store=True)
6 changes: 6 additions & 0 deletions stock_quant_reservation_status/views/stock_view.xml
Expand Up @@ -25,6 +25,12 @@
<filter name="unreserved" string="Unreserved"
domain="[('is_reserved','=', False)]" />
</filter>
<field name="owner_id" position="after">
<field name="reserved_for" />
</field>
<filter string='Company' position="after">
<filter string='Reserved for' icon="terp-go-home" domain="[]" context="{'group_by' : 'reserved_for'}"/>
</filter>
</field>
</record>
</data>
Expand Down

0 comments on commit 1d713e5

Please sign in to comment.