diff --git a/shipment.py b/shipment.py index b520053..c649b21 100644 --- a/shipment.py +++ b/shipment.py @@ -83,13 +83,19 @@ class InternalShipment(metaclass=PoolMeta): def _get_lots(product_id): locations_ids = {'locations': [shipment.from_location.id]} + order = [] + fields = Lot.fields_get(fields_names=['expiration_date']) + if 'expiration_date' in fields.keys(): + order.append(('expiration_date', 'ASC NULLS LAST')) + order.append(('create_date', 'ASC')) + with Transaction().set_context(locations_ids): dom = [ ('product', '=', product_id), ('active', '=', True), ('quantity', '>', 0), ] - lots = Lot.search(dom, order=[('expiration_date', 'ASC NULLS LAST'), ('create_date', 'ASC')]) + lots = Lot.search(dom, order=order) return lots for move in shipment.moves: diff --git a/stock.py b/stock.py index 861e6b3..c3568da 100644 --- a/stock.py +++ b/stock.py @@ -29,7 +29,7 @@ class Lot(metaclass=PoolMeta): class Move(metaclass=PoolMeta): __name__ = 'stock.move' - description = fields.Char('Description', select=True, states=STATES_MOVE) + description = fields.Function(fields.Char('Description'), 'on_change_with_description') current_stock = fields.Function(fields.Float('Current Stock', depends=['product']), 'on_change_with_current_stock') reference = fields.Function(fields.Char('Reference', @@ -71,6 +71,14 @@ class Move(metaclass=PoolMeta): res += res_dict[self.product.id] return res + @fields.depends('product') + def on_change_with_description(self, name=None): + res = '' + if self.product and self.product.description: + description = self.product.description + res = description.rstrip('\n') + return res + class MoveByProductStart(ModelView): 'Move By Product Start' diff --git a/view/move_form.xml b/view/move_form.xml index 11e339a..72dd3aa 100644 --- a/view/move_form.xml +++ b/view/move_form.xml @@ -2,14 +2,19 @@ + + + +