Skip to content

Commit

Permalink
[FIX] purchase_reorder_lines: fix computation of max line sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Sep 3, 2015
1 parent 6e3ce7e commit ef98e7f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion purchase_order_reorder_lines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
#
#

from . import purchase
from . import models
4 changes: 2 additions & 2 deletions purchase_order_reorder_lines/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
#
{
'name': 'Purchase order lines with sequence number',
'version': '0.1',
'version': '8.0.1.0.1',
'category': 'Purchase Management',
'author': "Camptocamp,Odoo Community Association (OCA)",
'website': 'http://www.camptocamp.com',
'depends': [
'purchase',
'stock_picking_reorder_lines',
],
'data': ['purchase_view.xml'],
'data': ['views/purchase_view.xml'],
'demo': [],
'installable': True,
'auto_install': False,
Expand Down
24 changes: 24 additions & 0 deletions purchase_order_reorder_lines/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
#
#
# Author: Alexandre Fayolle
# Copyright 2013 Camptocamp SA
# Author: Damien Crier
# Copyright 2015 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# 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 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/>.
#
#

from . import purchase
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,21 @@ def _prepare_order_line_move(self, order, order_line,
res[0]['sequence'] = order_line.sequence
return res

@api.one
@api.depends('order_line')
def _get_max_line_sequence(self):
def compute_max_line_sequence(self):
"""Allow to know the highest sequence
entered in purchase order lines.
Web add 10 to this value for the next sequence
This value is given to the context of the o2m field
in the view. So when we create new purchase order lines,
the sequence is automatically max_sequence + 10
"""
for purchase in self:
purchase.max_line_sequence = (
max(purchase.mapped('order_line.sequence')) + 10
)
self.max_line_sequence = (
max(self.mapped('order_line.sequence') or [0]) + 10)

max_line_sequence = fields.Integer(string='Max sequence in lines',
compute='_get_max_line_sequence')
compute='compute_max_line_sequence')


class PurchaseLineInvoice(models.TransientModel):
Expand Down

0 comments on commit ef98e7f

Please sign in to comment.